/* =====================================================================
   style.css – Kaffeepausen-Spiele im NES-Look
   Pixelschrift "Press Start 2P" (lokal, OFL), NES-Farbpalette,
   kantige Pixel-Ränder durch abgeschnittene Ecken.
   ===================================================================== */

@font-face {
    font-family: 'PressStart';
    src: url('../assets/fonts/press-start-2p.woff2') format('woff2');
    font-display: swap;
}

:root {
    /* NES-Palette */
    --bg: #0f0f1b;
    --panel: #1c1c34;
    --panel-2: #2b2b50;
    --ink: #fcfcfc;
    --muted: #a8a8d0;
    --black: #000000;
    --blue: #0058f8;
    --blue-d: #0030a8;
    --red: #d82800;
    --red-d: #881400;
    --green: #00a844;
    --green-d: #006828;
    --yellow: #f8b800;
    --yellow-d: #ac7c00;
    --gray: #7c7c7c;
    --gray-d: #4c4c4c;
    --sky: #3cbcfc;
    --pink: #f878f8;

    --font: 'PressStart', 'Courier New', monospace;
    --px: 4px;
    /* Pixel-Ecken: 4px an jeder Ecke abgeschnitten */
    --notch: polygon(0 4px, 4px 4px, 4px 0, calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
                     100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
                     4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 12px;
    line-height: 1.8;
    -webkit-font-smoothing: none;
    -webkit-tap-highlight-color: transparent;
}
body {
    min-height: 100vh;
    background-image:
        radial-gradient(#ffffff10 1px, transparent 1px);
    background-size: 16px 16px;
}

h1, h2, h3 { margin: 0; font-weight: normal; line-height: 1.5; }
h2 { font-size: 14px; color: var(--yellow); margin-bottom: 12px; }
h3 { font-size: 13px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.mt { margin-top: 20px; }
.visually-hidden { position: fixed; left: -9999px; top: 0; }

.blink { animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* ---------------------------------------------------------------------
   Kopfleiste
   --------------------------------------------------------------------- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 16px;
    padding: 10px 16px;
    background: var(--black);
    border-bottom: 4px solid var(--blue);
}
.brand { color: var(--ink); text-decoration: none; font-size: 12px; white-space: nowrap; }
.brand span { margin-left: 6px; }
.conn-status { margin-left: auto; font-size: 10px; color: var(--green); white-space: nowrap; }
.conn-status.is-offline { color: var(--yellow); animation: blink 1.1s steps(2, start) infinite; }
.icon-btn {
    font-family: var(--font); font-size: 16px; line-height: 1;
    background: none; border: 0; color: var(--ink); cursor: pointer; padding: 6px;
}

.screen { max-width: 1000px; margin: 0 auto; padding: 24px 16px 60px; }

/* ---------------------------------------------------------------------
   Pixel-Panels und Buttons
   --------------------------------------------------------------------- */
.panel {
    position: relative;
    background: var(--panel);
    padding: 22px;
    margin-bottom: 20px;
    clip-path: var(--notch);
    box-shadow: inset 0 0 0 4px var(--ink), inset 0 0 0 8px var(--black);
}

.btn {
    --c: var(--blue);
    --d: var(--blue-d);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    font-family: var(--font); font-size: 12px; line-height: 1.4;
    color: var(--ink);
    background: var(--c);
    border: 0;
    cursor: pointer;
    text-align: center;
    clip-path: var(--notch);
    box-shadow: inset -4px -4px 0 0 var(--d), inset 4px 4px 0 0 rgba(255, 255, 255, 0.28);
    user-select: none;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { box-shadow: inset 4px 4px 0 0 var(--d); transform: translateY(2px); }
.btn:focus-visible { filter: brightness(1.25); box-shadow: inset 0 0 0 4px var(--yellow); }
.btn:disabled { --c: var(--gray-d); --d: #2c2c2c; color: var(--muted); cursor: not-allowed; filter: none; transform: none; }
.btn-red { --c: var(--red); --d: var(--red-d); }
.btn-green { --c: var(--green); --d: var(--green-d); }
.btn-yellow { --c: var(--yellow); --d: var(--yellow-d); color: var(--black); }
.btn-gray { --c: var(--gray); --d: var(--gray-d); }
.btn-big { min-height: 60px; font-size: 14px; }

.button-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.button-row.center { justify-content: center; }
.button-col { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }

.label { display: block; font-size: 10px; color: var(--muted); margin-bottom: 8px; }
.input {
    display: block; width: 100%;
    font-family: var(--font); font-size: 14px;
    color: var(--ink); background: var(--black);
    border: 4px solid var(--ink);
    padding: 12px;
    outline: none;
    caret-color: var(--yellow);
    border-radius: 0;
}
.input:focus { border-color: var(--yellow); }
.input::placeholder { color: var(--gray); }
.code-input { font-size: 26px; letter-spacing: 10px; text-align: center; text-transform: uppercase; margin-bottom: 14px; }

/* Auswahlliste im NES-Menü-Stil (▶ Cursor) */
.game-picker, .role-toggle { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.role-toggle { flex-direction: row; flex-wrap: wrap; }
.pick {
    display: flex; align-items: center; gap: 10px;
    min-height: 48px; padding: 8px 12px;
    font-family: var(--font); font-size: 12px; color: var(--ink);
    background: var(--black); border: 4px solid var(--panel-2);
    cursor: pointer; text-align: left;
}
.pick:hover { border-color: var(--muted); }
.pick.is-selected { border-color: var(--yellow); color: var(--yellow); }
.pick:disabled { cursor: not-allowed; opacity: 0.6; }
.pick-cursor { width: 14px; color: var(--yellow); }
.pick-emoji { font-size: 18px; }
.pick .badge { margin-left: auto; }

.badge { font-size: 9px; padding: 3px 6px; white-space: nowrap; background: var(--panel-2); }
.badge.is-ok { color: #7cf87c; }
.badge.is-warn { color: var(--yellow); }
.badge.is-muted { color: var(--muted); }

/* ---------------------------------------------------------------------
   Startseite
   --------------------------------------------------------------------- */
.hero { text-align: center; margin: 12px 0 28px; }
.title {
    font-size: 26px; line-height: 1.5; color: var(--ink);
    text-shadow: 4px 4px 0 var(--red), 8px 8px 0 var(--black);
}
.title-emoji { text-shadow: none; }
.subtitle { color: var(--sky); margin-top: 16px; }
.name-panel .button-row .btn { flex: 1 1 200px; }
.section-title { text-align: center; margin: 32px 0 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.game-card { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 0; }
.card-emoji { font-size: 52px; line-height: 1.3; margin-bottom: 8px; }
.game-card h3 { color: var(--yellow); margin-bottom: 8px; }
.card-desc { font-size: 10px; min-height: 36px; }
.game-card .btn { margin-top: auto; width: 100%; }
.footer-hint { text-align: center; color: var(--muted); font-size: 9px; margin-top: 32px; }

/* ---------------------------------------------------------------------
   Lobby
   --------------------------------------------------------------------- */
.room-head { text-align: center; }
.game-title { font-size: 18px; color: var(--sky); margin-bottom: 14px; }
.room-label { font-size: 10px; color: var(--muted); }
.room-code {
    font-size: 44px; letter-spacing: 12px; line-height: 1.5; color: var(--yellow);
    text-shadow: 4px 4px 0 var(--red-d); margin: 6px 0 10px; padding-left: 12px;
}
.lobby-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.lobby-grid .panel { margin-bottom: 0; }
.member-list { list-style: none; margin: 0; padding: 0; }
.member {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    padding: 8px 6px; border-bottom: 2px dashed var(--panel-2);
}
.member.is-you { background: #ffffff0d; }
.member.is-offline .member-name { color: var(--muted); }
.member-name { overflow-wrap: anywhere; }
.member .badge { margin-left: auto; }
.you { color: var(--sky); font-size: 9px; }
.crown { font-size: 12px; }
.game-info { text-align: center; margin-bottom: 12px; }
.big-emoji { font-size: 48px; line-height: 1.3; }
.controls-hint { font-size: 9px; color: var(--muted); margin-top: 4px; }
.hint { font-size: 10px; color: var(--yellow); margin: 0; text-align: center; }

/* ---------------------------------------------------------------------
   Hinweise
   --------------------------------------------------------------------- */
#toasts {
    position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 100;
    display: flex; flex-direction: column; gap: 8px; width: min(92vw, 520px);
}
.toast {
    padding: 12px 16px; font-size: 11px; line-height: 1.6;
    background: var(--black); color: var(--ink);
    clip-path: var(--notch);
    box-shadow: inset 0 0 0 4px var(--sky);
}
.toast.is-ok { box-shadow: inset 0 0 0 4px var(--green); }
.toast.is-error { box-shadow: inset 0 0 0 4px var(--red); color: #ffd0c8; }

/* ---------------------------------------------------------------------
   Spielansicht
   --------------------------------------------------------------------- */
.screen:has(.game-screen) { max-width: 1400px; }
.game-screen { display: flex; flex-direction: column; gap: 12px; }
.game-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.game-name { font-size: 12px; color: var(--sky); }
.spacer { flex: 1; }
.bar-buttons { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.btn-small { min-height: 36px; padding: 8px 12px; font-size: 10px; }

.stage {
    position: relative;
    display: flex; justify-content: center; align-items: center;
    padding: 8px;
    background: var(--black);
    clip-path: var(--notch);
    box-shadow: inset 0 0 0 4px var(--ink);
}
.game-canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: var(--black);
}
/* leichte Röhrenbildschirm-Zeilen */
.stage::after {
    content: ""; position: absolute; inset: 8px; pointer-events: none;
    background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.16) 0 1px, transparent 1px 3px);
}
.result-overlay {
    position: absolute; z-index: 2;
    left: 50%; top: 50%; transform: translate(-50%, -50%);
    width: min(92%, 560px);
    padding: 22px; text-align: center;
    background: var(--black);
    clip-path: var(--notch);
    box-shadow: inset 0 0 0 4px var(--yellow);
}
.result-overlay h2 { font-size: 18px; }
.result-line { font-size: 12px; }
.result-highlight { font-size: 14px; color: var(--yellow); margin: 14px 0; }

.game-legend { font-size: 10px; color: var(--muted); text-align: center; }
.legend-teams { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 28px; }
.legend-team { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.legend-team-name { font-weight: bold; }
.team-0 .legend-team-name { color: #fc7460; }
.team-1 .legend-team-name { color: #6888fc; }
.legend-player.is-you { color: var(--yellow); }
.legend-dot { display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.center { text-align: center; }

/* Touch-Steuerung (nur bei Touch-Geräten oder per 🎮 eingeschaltet) */
.touch-controls { display: none; }
body.touch .touch-controls:not([hidden]) { display: block; }
.touch-inner {
    display: flex; justify-content: space-between; align-items: center;
    padding: 4px 8px; user-select: none; -webkit-user-select: none; touch-action: none;
}
.dpad {
    position: relative; width: 168px; height: 168px; flex: none;
    touch-action: none;
    background:
        linear-gradient(#2c2c2c, #2c2c2c) center / 56px 100% no-repeat,
        linear-gradient(#2c2c2c, #2c2c2c) center / 100% 56px no-repeat;
}
.dpad-arrow {
    position: absolute; width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; color: var(--muted); pointer-events: none;
}
.dpad-arrow.is-up { left: 56px; top: 0; }
.dpad-arrow.is-down { left: 56px; bottom: 0; }
.dpad-arrow.is-left { left: 0; top: 56px; }
.dpad-arrow.is-right { right: 0; top: 56px; }
.dpad-arrow.is-active { color: var(--yellow); background: #444; }
.dpad-center { position: absolute; left: 56px; top: 56px; width: 56px; height: 56px; background: #222; pointer-events: none; }
.action-btn {
    width: 104px; height: 104px; border-radius: 50%; flex: none;
    font-family: var(--font); font-size: 12px; color: var(--ink);
    background: var(--red); border: 0;
    box-shadow: inset -6px -6px 0 var(--red-d), 0 0 0 4px var(--black), 0 0 0 8px var(--gray-d);
    touch-action: none; user-select: none;
}
.action-btn.is-active { box-shadow: inset 6px 6px 0 var(--red-d), 0 0 0 4px var(--black), 0 0 0 8px var(--yellow); }

/* ---------------------------------------------------------------------
   Kleine Bildschirme
   --------------------------------------------------------------------- */
@media (max-width: 760px) {
    html, body { font-size: 10px; }
    .brand span { display: none; }
    .title { font-size: 17px; }
    .lobby-grid { grid-template-columns: 1fr; }
    .room-code { font-size: 32px; letter-spacing: 8px; }
    .panel { padding: 18px; }
}
