/* =========================================================
   Wiki Race — black & white retro pixelated theme.
   - VT323 for body / log / status (terminal feel).
   - Press Start 2P for headings, buttons, tags (chunky pixel).
   - Hard 2px borders, no radii, no soft shadows. Hover inverts.
   ========================================================= */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #000000;
    --fg: #ffffff;
    --dim: #0d0d0d;
    --dimmer: #1a1a1a;
    --muted: #8a8a8a;
    --border: #ffffff;
    --rule: #ffffff;
    --danger: #ff5050;
    --goal: #c8ffc8;
}

html, body {
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font-family: 'VT323', ui-monospace, "Courier New", monospace;
    font-size: 19px;
    line-height: 1.25;
    image-rendering: pixelated;
    /* Subtle scanlines */
    background-image:
        repeating-linear-gradient(0deg,
            rgba(255, 255, 255, 0.025) 0px,
            rgba(255, 255, 255, 0.025) 1px,
            transparent 1px,
            transparent 3px);
}

body {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 0;
}

button, input, kbd, .pixel { font-family: 'Press Start 2P', 'VT323', monospace; }

/* ---------------- Panel ---------------- */

.panel {
    background: var(--bg);
    border-right: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 14px;
    border-bottom: 2px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.brand h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.tagline {
    font-size: 14px;
    color: var(--muted);
    text-transform: lowercase;
    letter-spacing: 0.04em;
}

.status {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    padding: 5px 8px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.status.connecting,
.status.working { background: var(--fg); color: var(--bg); animation: blink 1s steps(2) infinite; }
.status.connected { background: var(--bg); color: var(--fg); }
.status.won { background: var(--fg); color: var(--bg); }
.status.error { background: var(--danger); color: var(--bg); }

@keyframes blink { 50% { opacity: 0.55; } }

/* ---------------- Game card ---------------- */

.game-card {
    padding: 14px;
    border-bottom: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.goal-card,
.current-card,
.runners {
    border: 2px solid var(--border);
    background: var(--bg);
    padding: 10px 12px;
}

.goal-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 0;
}

.goal-row + .goal-row { border-top: 1px dashed var(--muted); }

.label {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.value {
    font-size: 18px;
    text-align: right;
    word-break: break-word;
}

.value.goal { font-weight: bold; }

.current-card .label { display: block; margin-bottom: 4px; }

.value.current {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 4px;
    word-break: break-word;
}

.meta { font-size: 14px; color: var(--muted); }

.controls { display: flex; gap: 8px; }

button {
    flex: 1;
    padding: 8px 10px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 9px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    cursor: pointer;
    image-rendering: pixelated;
    transition: none;
}

button:hover:not(:disabled) { background: var(--fg); color: var(--bg); }
button:active:not(:disabled) { transform: translate(1px, 1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

button.primary,
button.secondary { background: var(--fg); color: var(--bg); }
button.primary:hover:not(:disabled),
button.secondary:hover:not(:disabled) { background: var(--bg); color: var(--fg); }

button.ghost { background: transparent; }

/* ---------------- Runner list ---------------- */

.runners-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
}

.runner-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }

.runner-list li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border: 2px solid var(--border);
    background: var(--bg);
    font-size: 16px;
}

.runner-list li.me { background: var(--fg); color: var(--bg); }
.runner-list li.me .id,
.runner-list li.me .current { color: rgba(0, 0, 0, 0.65); }

.runner-list .dot {
    width: 8px;
    height: 8px;
    background: var(--fg);
    flex: none;
}
.runner-list li.me .dot { background: var(--bg); }

.runner-list .name { font-weight: bold; }
.runner-list .id { color: var(--muted); font-size: 13px; }
.runner-list .current {
    margin-left: auto;
    color: var(--muted);
    font-size: 13px;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.runner-list .winner { font-weight: bold; }

/* ---------------- Log ---------------- */

.log-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-top: 2px solid var(--border);
}

.log-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    border-bottom: 2px solid var(--border);
}

.tiny {
    flex: none;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-size: 8px;
    padding: 2px 6px;
    letter-spacing: 0.06em;
}

.log {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 10px 14px 14px;
    font-size: 16px;
}

.log li {
    padding: 4px 0;
    border-bottom: 1px dashed var(--muted);
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.log li::before {
    content: ">";
    flex: none;
    color: var(--muted);
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    margin-top: 2px;
}

.log li.thought { color: var(--muted); font-style: italic; }
.log li.thought::before { content: "·"; }
.log li.system::before { content: "i"; color: var(--fg); }
.log li.goal::before { content: "★"; color: var(--fg); }
.log li.goal { color: var(--goal); }
.log li.error::before { content: "!"; color: var(--danger); }
.log li.error { color: var(--danger); }
.log li b { font-weight: bold; }

/* ---------------- Stage ---------------- */

.stage {
    display: flex;
    flex-direction: column;
    padding: 18px;
    min-height: 100vh;
    gap: 18px;
}

/* ---------------- Landing ---------------- */

body[data-mode="landing"] .landing { display: flex; }
body[data-mode="landing"] .sessions { display: none; }
body[data-mode="solo"]    .landing  { display: none; }
body[data-mode="solo"]    .sessions { display: grid; grid-template-columns: 1fr; }
body[data-mode="race"]    .landing  { display: none; }
body[data-mode="race"]    .sessions { display: grid; grid-template-columns: 1fr 1fr; }

.landing {
    flex: 1;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px;
    border: 2px solid var(--border);
    background: var(--bg);
    overflow: hidden;
}

.landing-inner {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
    padding-top: 4vh;
}

.landing-title {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(20px, 3vw, 32px);
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin-bottom: 14px;
    text-shadow:
        2px 2px 0 var(--dimmer),
        4px 4px 0 var(--dimmer);
}

.landing-sub {
    color: var(--muted);
    font-size: 19px;
    max-width: 560px;
    margin: 0 auto 20px;
}

.landing-runners {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 28px;
}

.landing-runners .dot {
    width: 8px;
    height: 8px;
    background: var(--muted);
}
.landing-runners .dot.pending { background: var(--fg); animation: blink 0.6s steps(2) infinite; }
.landing-runners .dot.ready { background: var(--fg); }

.landing-ctas {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    max-width: 720px;
    margin: 0 auto;
}

.cta {
    flex: 0;
    text-align: left;
    padding: 18px 18px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    text-transform: none;
    letter-spacing: normal;
    font-size: inherit;
}

.cta:hover:not(:disabled) {
    background: var(--fg);
    color: var(--bg);
    transform: translate(-2px, -2px);
    box-shadow: 4px 4px 0 var(--border);
}

.cta:active:not(:disabled) { transform: translate(0, 0); box-shadow: none; }

.cta:disabled { opacity: 0.35; cursor: not-allowed; }

.cta-eyebrow {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--muted);
}

.cta:hover:not(:disabled) .cta-eyebrow { color: var(--bg); }

.cta-title {
    font-family: 'Press Start 2P', monospace;
    font-size: 11px;
    text-transform: uppercase;
    line-height: 1.4;
}

.cta-sub {
    font-size: 16px;
    color: var(--muted);
}

.cta:hover:not(:disabled) .cta-sub { color: rgba(0, 0, 0, 0.7); }

/* ---------------- Idle animation ---------------- */

.dino-wrap {
    margin-top: 28px;
    pointer-events: none;
}

#dino {
    width: 100%;
    height: 140px;
    display: block;
    image-rendering: pixelated;
}

/* ---------------- Sessions ---------------- */

.sessions {
    flex: 1;
    gap: 14px;
    min-height: 0;
}

.session-slot {
    display: flex;
    flex-direction: column;
    border: 2px solid var(--border);
    overflow: hidden;
    background: var(--bg);
    min-height: 0;
}

.slot-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg);
    border-bottom: 2px solid var(--border);
    font-size: 16px;
}

.slot-tag {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 8px;
    border: 2px solid var(--border);
}

.tag-ai { background: var(--fg); color: var(--bg); }
.tag-human { background: var(--bg); color: var(--fg); }

.slot-current { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.slot-frame { flex: 1; min-height: 0; }
.slot-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

@media (max-width: 880px) {
    body { grid-template-columns: 1fr; }
    .panel { min-height: auto; }
    .stage { min-height: 60vh; }
    .sessions { grid-template-columns: 1fr !important; }
    .landing-ctas { grid-template-columns: 1fr; }
}
