/* CPAnext - dark, pixel-friendly UI chrome */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #14141c;
    color: #e8e8f0;
    font-family: "Segoe UI", system-ui, sans-serif;
}

h1:focus { outline: none; }

button {
    background: #2a2a3a;
    color: #e8e8f0;
    border: 1px solid #44445c;
    border-radius: 4px;
    padding: 6px 12px;
    cursor: pointer;
    font: inherit;
}

button:hover { background: #38384e; }
button.primary { background: #3d5afe; border-color: #3d5afe; }
button.primary:hover { background: #536dfe; }
button.danger { background: #6b2030; border-color: #8a2a3e; }

input, select {
    background: #1e1e2a;
    color: #e8e8f0;
    border: 1px solid #44445c;
    border-radius: 4px;
    padding: 6px 10px;
    font: inherit;
}

.error { color: #ff6b7a; }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0;
    background: #6b2030; padding: 8px 16px; z-index: 9999; }
#blazor-error-ui.visible { display: block; }

/* ---------- start screen (retro pixel look, item 14) ---------- */

:root { --accent: #ffd966; }

.start-screen { max-width: 960px; margin: 0 auto; padding: 16px 16px 32px; }

/* pixel chrome: square corners, chunky borders, hard offset shadows; the pixel
   font is used for headings/buttons only — body copy stays readable */
.start-screen h2, .start-screen .tagline, .start-screen button {
    font-family: 'VT323', monospace; }
.start-screen button { border-radius: 0; border: 2px solid #44445c; font-size: 19px;
    box-shadow: 3px 3px 0 #000; }
.start-screen button:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 #000; }
.start-screen button.primary { background: var(--accent); border-color: var(--accent);
    color: #14141c; }
.start-screen button.primary:hover { background: #ffe38a; }
.start-screen input { border-radius: 0; border: 2px solid #44445c; }
.start-screen input:focus { outline: none; border-color: var(--accent); }
.start-screen .color-dot { box-shadow: none; border-radius: 50%; }
.start-screen .lang-toggle button.active { background: var(--accent); border-color: var(--accent);
    color: #14141c; }

.start-header { display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 8px; }
.start-header .tagline { color: #9a9ab0; font-size: 22px; margin: 0; }

/* pre-join interstitial on /play/{code} — full-screen, centered, spinner */
.join-screen { position: fixed; inset: 0; background: #0a0a12; z-index: 2000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.join-logo { margin: 0; letter-spacing: 2px; font-size: 28px; }
.join-hint { margin: 0; color: #9a9ab0; font-size: 14px; }
.join-error { margin: 0; color: #ff8a80; font-size: 15px; max-width: 80%; text-align: center; }
.join-spinner { width: 30px; height: 30px; border-radius: 50%;
    border: 3px solid #22222e; border-top-color: #3d5afe;
    animation: joinspin 0.9s linear infinite; }
@keyframes joinspin { to { transform: rotate(360deg); } }
.primary-link { background: #3d5afe; padding: 8px 20px; border-radius: 4px;
    color: #fff; text-decoration: none; }
.primary-link:hover { background: #536dfe; }
.gallery-loading { display: flex; justify-content: center; padding: 48px 0; width: 100%; }
.lang-toggle button.active { background: #3d5afe; }
.identity { display: flex; gap: 16px; align-items: end; margin: 24px 0; flex-wrap: wrap; }
.identity label { display: flex; flex-direction: column; gap: 4px; }
.color-picker { display: flex; gap: 6px; }
.color-dot { width: 28px; height: 28px; border-radius: 50%; padding: 0; border: 2px solid transparent; }
.color-dot.selected { border-color: #fff; }
.color-dot.verb-default { background: #22222e; color: #9a9ab0; font-size: 13px; line-height: 1; }
.join-box { display: flex; gap: 8px; margin-bottom: 24px; }
.code-input { text-transform: uppercase; letter-spacing: 4px; min-width: 220px; font-size: 18px; }
.code-input::placeholder { letter-spacing: normal; font-size: 14px; text-transform: none; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.game-card { background: #1e1e2a; border: 2px solid #2e2e40; border-radius: 0; padding: 16px;
    box-shadow: 4px 4px 0 #000; }
.game-card:hover { border-color: var(--accent); }
.game-card h2 { margin: 10px 0 4px; font-size: 26px; color: var(--accent); }
.game-card img { width: 100%; border-radius: 0; border: 2px solid #101018;
    image-rendering: pixelated; }
.game-card .version { color: #707088; font-size: 12px; }

/* ---------- game screen ---------- */

/* overflow:hidden — a few px of leaking content (e.g. font-metric differences in the
   chat input row) must never put page scrollbars on the game screen */
.game-root { display: flex; flex-direction: column; height: 100vh; outline: none;
    overflow: hidden; }
.top-bar { display: flex; align-items: center; gap: 12px; padding: 6px 12px;
    background: #101018; border-bottom: 1px solid #2e2e40; flex-wrap: wrap; }
.game-title { font-weight: 600; }
.code-badge { letter-spacing: 3px; font-family: monospace; font-size: 15px; }
.roster { display: flex; gap: 4px; }
.player-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.player-dot.offline { opacity: 0.3; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }

.stage-wrap { flex: 1; display: flex; align-items: center; justify-content: center;
    overflow: hidden; background: #000; position: relative; min-height: 0; }
.stage { position: relative; overflow: hidden; background: #000; cursor: crosshair; }
.stage.hot { cursor: pointer; }
.scene { position: absolute; top: 0; left: 0; will-change: transform; }
.scene-bg { position: absolute; top: 0; left: 0; display: block; height: 100%; }
.hd-el { position: absolute; image-rendering: auto; }        /* HD stays smooth on purpose */
.hd-el.pix { image-rendering: pixelated; }                   /* pixel-art scene patches */
.hd-el.glow { animation: hdglow 1.6s ease-in-out infinite alternate; }
@keyframes hdglow { from { filter: drop-shadow(0 0 3px rgba(255,240,160,.6)); }
                    to { filter: drop-shadow(0 0 9px rgba(255,240,160,1)); } }
.focus-dim { position: absolute; inset: 0; background: rgba(0,0,0,.3); z-index: 599; pointer-events: none; }
.scene-item { position: absolute; width: 32px; height: 32px; }
.sprite { position: absolute; background-repeat: no-repeat; }
.protagonist { position: absolute; }
.protagonist .sprite-frame { background-repeat: no-repeat; }
.cursor-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1500; }
/* updates arrive at 20 Hz (50 ms) — the transition interpolates between them */
.remote-cursor { position: absolute; top: 0; left: 0; pointer-events: none;
    transition: transform 80ms linear; }
.remote-cursor span { font-size: 9px; color: #000; padding: 1px 4px; border-radius: 3px; margin-left: 10px; }

/* Above the cutscene letterbox (1050) and still (1100), below the skip button (1200):
   dialog text must never be covered by the black bars (user-reported bug). */
.subtitle { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    max-width: 85%; text-align: center; font-size: 24px; line-height: 1.15;
    font-family: 'VT323', monospace; /* retro look matching the verb/action text */
    text-shadow: 1px 1px 0 #000, -1px 1px 0 #000, 1px -1px 0 #000, -1px -1px 0 #000,
        2px 2px 0 #000;
    z-index: 1150; pointer-events: none; }
/* During a cutscene, lift the subtitle clear of the bottom bar (10% tall) as well. */
.stage:has(.letterbox) .subtitle { bottom: calc(10% + 12px); }
.skip-indicator { margin-left: 10px; font-size: 11px; opacity: .8; }

.cutscene-still { position: absolute; inset: 0; width: 100%; height: 100%;
    object-fit: contain; background: #000; z-index: 1100; animation: fadein .5s; }
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.letterbox { position: absolute; left: 0; right: 0; height: 10%; background: #000; z-index: 1050; }
.letterbox.top { top: 0; } .letterbox.bottom { bottom: 0; }
/* Sits INSIDE the bottom letterbox bar (bottom 10% of the stage), below the action —
   it must never cover the scene or the subtitle text. */
.skip-btn { position: absolute; right: 12px; bottom: 1.5%; z-index: 1200; opacity: .85;
    max-height: 7%; padding: 2px 10px; font-size: 12px; }

.loading-overlay { position: absolute; inset: 0; background: #0a0a12; z-index: 2000;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.progress { width: 240px; height: 10px; background: #22222e; border-radius: 5px; overflow: hidden; }
.progress div { height: 100%; background: #3d5afe; transition: width .15s; }
.waiting { color: #9a9ab0; font-size: 13px; }

.end-overlay { position: absolute; inset: 0; background: rgba(6,6,12,.92); z-index: 2100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 24px; box-sizing: border-box; text-align: center; }
.end-overlay p { max-width: 42ch; margin: 0; }
.end-overlay a.primary { background: #3d5afe; padding: 8px 20px; border-radius: 4px;
    color: #fff; text-decoration: none; }

.toast { position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
    background: rgba(20,20,30,.92); border: 1px solid #44445c; padding: 6px 14px;
    border-radius: 6px; z-index: 2200; animation: fadein .2s; }

/* ---------- command bar (Indy4-style pixel look, item 5) ---------- */

@font-face {
    font-family: 'VT323';
    src: url('fonts/VT323-Regular.ttf') format('truetype');
    font-display: swap;
}

.bottom-bar { display: flex; height: 160px; background: #101018;
    border-top: 2px solid #2e2e40; }
.bottom-main { flex: 1; min-width: 0; overflow: hidden; }

.command-bar { background: #101018; padding: 4px 16px 8px;
    height: 100%; box-sizing: border-box; --verb-color: #ffd966;
    display: flex; flex-direction: column; }
.sentence-line { min-height: 30px; color: var(--verb-color); text-align: center;
    font-family: 'VT323', monospace; font-size: 24px; line-height: 30px; padding: 0 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.command-grid { display: flex; gap: 24px; align-items: flex-start; justify-content: center;
    flex: 1; min-height: 0; }
.verb-grid { display: grid; grid-template-columns: repeat(3, minmax(110px, 150px)); gap: 2px 14px; }
.verb-btn { padding: 2px 4px; background: none; border: none; cursor: pointer;
    font-family: 'VT323', monospace; font-size: 24px; line-height: 32px; text-align: center;
    color: var(--verb-color); }
.verb-btn:hover { filter: brightness(1.35); text-shadow: 0 0 6px var(--verb-color); }
.verb-btn.armed { background: var(--verb-color); color: #101018; text-shadow: none; }
.inventory-grid { display: grid; grid-template-columns: repeat(4, 48px); grid-auto-rows: 48px;
    gap: 4px; max-height: 104px; overflow-y: auto; align-content: start; }
.inv-slot { padding: 2px; background: #181824; border: 2px solid #2e2e40; border-radius: 0;
    display: flex; align-items: center; justify-content: center; }
.inv-slot.filled { cursor: pointer; }
.inv-slot.filled:hover { border-color: var(--verb-color); }
.inv-slot.empty { opacity: 0.6; }
.inv-slot img { width: 32px; height: 32px; image-rendering: pixelated; }
.inv-slot.armed { border-color: var(--verb-color); background: #26263a; }

/* ---------- dialogs ---------- */

.dialog-choices { background: #101018; padding: 10px 16px; box-sizing: border-box;
    display: flex; flex-direction: column; gap: 6px; height: 100%; overflow-y: auto; }
.dialog-choice { text-align: left; background: none; border: none; cursor: pointer;
    color: #cfcfe0; font-family: 'VT323', monospace; font-size: 20px;
    animation: choice-in 0.3s ease-out; } /* visual cue matching the click grace period */
.dialog-choice:hover:not(:disabled) { color: #ffd966; }
.dialog-choice:disabled { cursor: default; }
@keyframes choice-in { from { opacity: 0; } to { opacity: 1; } }

.settings-hint { color: #9a9ab0; font-size: 13px; margin: 4px 0 0; }

/* ---------- chat ---------- */

.chat-panel { position: fixed; right: 12px; bottom: 12px; width: 280px; z-index: 2300;
    display: flex; flex-direction: column; }
.chat-panel .chat-toggle { align-self: flex-end; }
.chat-messages { background: rgba(16,16,24,.95); border: 1px solid #2e2e40; border-radius: 6px;
    height: 240px; overflow-y: auto; padding: 8px; font-size: 13px; margin: 6px 0;
    display: flex; flex-direction: column-reverse; }

/* embedded in the fixed bottom bar (item 6): a static right-hand column */
.chat-panel.embedded { position: static; width: 280px; height: 100%; z-index: auto;
    border-left: 2px solid #2e2e40; padding: 6px 8px; box-sizing: border-box;
    overflow: hidden; }
.chat-panel.embedded .chat-messages { flex: 1; height: auto; min-height: 0; margin: 0 0 6px; }
@media (max-width: 900px) { .chat-panel.embedded { width: 180px; } }
.chat-msg.system { color: #8a8aa0; font-style: italic; }
.chat-name { font-weight: 600; }
.chat-input { display: flex; gap: 4px; }
.chat-input input { flex: 1; min-width: 0; } /* inputs have a large intrinsic min-width */
.chat-input button { flex-shrink: 0; }

/* ---------- modals ---------- */

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 2400;
    display: flex; align-items: center; justify-content: center; }
.modal { background: #1a1a26; border: 1px solid #2e2e40; border-radius: 8px; padding: 20px;
    min-width: 380px; max-width: 90vw; max-height: 80vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: 10px; }
.save-new { display: flex; gap: 8px; }
.save-new input { flex: 1; }
.save-row { display: flex; gap: 8px; align-items: center; padding: 4px 0;
    border-bottom: 1px solid #26263a; }
.save-row span:first-child { flex: 1; }
.save-date { color: #707088; font-size: 12px; }

/* ---------- dev overlay ---------- */

.dev-overlay { position: fixed; left: 12px; top: 52px; width: 300px; max-height: 80vh;
    overflow-y: auto; background: rgba(14,14,22,.97); border: 1px solid #3d5afe;
    border-radius: 8px; padding: 12px; z-index: 2500; font-size: 13px;
    display: flex; flex-direction: column; gap: 8px; }
.dev-header { display: flex; justify-content: space-between; align-items: center; }
.dev-row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.dev-json { word-break: break-all; display: block; background: #0a0a12; padding: 4px; }
.dev-status { color: #7fd97f; }
.dev-shapes { position: absolute; inset: 0; z-index: 1400; pointer-events: none; }
.dev-walkbox { fill: rgba(60,180,75,.15); stroke: #3cb44b; stroke-width: 1; }
.dev-hotspot { fill: rgba(61,90,254,.15); stroke: #3d5afe; stroke-width: 1; }
.dev-exit { fill: rgba(245,130,49,.15); stroke: #f58231; stroke-width: 1; }

.dev-vertex { fill: #fff; stroke: #3d5afe; stroke-width: 2; }

/* ---------- lobby ---------- */

.lobby-overlay { position: absolute; inset: 0; background: rgba(8,8,14,.94); z-index: 2050;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.lobby-overlay h1 { margin: 0; }
.lobby-hint { color: #9a9ab0; }
.lobby-code { font-family: monospace; font-size: 34px; letter-spacing: 10px; padding: 10px 26px; }
.lobby-players { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.lobby-player { display: flex; align-items: center; gap: 6px; }
.lobby-start { font-size: 18px; padding: 10px 32px; }
.lobby-start:disabled { opacity: .45; cursor: not-allowed; }
.lobby-player.ready .player-dot { box-shadow: 0 0 0 2px #3cb44b; }
.ready-mark { color: #3cb44b; font-weight: bold; }
.lobby-ready { font-size: 15px; padding: 8px 22px; }
.lobby-ready.is-ready { border-color: #3cb44b; color: #3cb44b; }
.lobby-wait-ready { font-size: 13px; }

/* soft pause: full-stage overlay; modals (chat/whiteboard/settings) stack ABOVE it —
   talking and drawing while paused is the point of a soft pause */
.pause-overlay { position: absolute; inset: 0; background: rgba(8,8,14,.88); z-index: 2100;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.pause-overlay h1 { margin: 0; }
.pause-overlay p { color: #9a9ab0; }

/* the chosen dialog answer — top-anchored so a long multi-line subtitle
   (bottom-anchored, grows upward) can never collide with it */
.choice-banner { position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
    max-width: 80%; text-align: center; font-size: 17px; font-style: italic;
    background: rgba(0,0,0,.55); border-radius: 6px; padding: 4px 12px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    z-index: 1150; pointer-events: none; }
.choice-banner-name { font-weight: bold; font-style: normal; }
.choice-banner-text { color: #d8d8e4; }

.skip-fast { margin-left: 10px; font-size: 13px; opacity: .85; }

/* whiteboard */
.wb-btn { position: relative; }
.badge-dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px;
    border-radius: 50%; background: #e6194b; border: 1px solid #000; }
.wb-modal { width: min(860px, 92vw); }
.wb-head { display: flex; align-items: center; justify-content: space-between; }
.wb-head h2 { margin: 0; }
.wb-actions { display: flex; gap: 8px; }
.wb-canvas { width: 100%; aspect-ratio: 16 / 9; background: #f4f2ea; border-radius: 4px;
    touch-action: none; cursor: crosshair; }

.remote-cursor { transition: opacity .25s; }

/* ---------- loading backdrop ---------- */

.loading-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    filter: blur(6px) brightness(.45); }
.loading-content { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.loading-content h2 { margin: 0; }

/* ---------- touch devices: no blue tap flash, no accidental text selection ---------- */

html, body { -webkit-tap-highlight-color: transparent; }
.stage, .stage-wrap, .verb-grid, .inventory-grid {
    -webkit-user-select: none; user-select: none; touch-action: manipulation; }

.home-link { color: #9a9ab0; text-decoration: none; font-size: 20px; line-height: 1; }
.home-link:hover { color: #fff; }
