:root {
    --bg: #0b1020;
    --bg-2: #0e1530;
    --panel: #151a2e;
    --panel-2: #090d1c;
    --border: #262c45;
    --text: #f5f5f8;
    --muted: #a0a7c0;
    --accent: #6366f1;
    --ok: #22c55e;
    --err: #ef4444;
    --warn: #f59e0b;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0;
    background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 65%);
    color: var(--text);
    min-height: 100vh;
}
body {
    font-family: "Inter", system-ui, -apple-system, sans-serif;
    font-feature-settings: "cv11", "ss03";
}

button {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
button.secondary { background: transparent; color: var(--text); border-color: var(--border); }
button.primary { font-size: 15px; }
button.btn-block { display: block; width: 100%; padding: 12px; }
button:active { transform: translateY(1px); }

/* ─── Gate ─────────────────────────────────────────────────────────── */

.gate { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.gate-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    max-width: 420px; width: 100%; text-align: center;
    box-shadow: 0 24px 48px -16px rgba(0,0,0,0.6);
}
.big-emoji { font-size: 64px; margin-bottom: 12px; }
.gate-card h1 { font-size: 24px; margin: 0 0 12px; }
.gate-card p { color: var(--muted); margin: 0 0 16px; }

.robot-list { display: flex; flex-direction: column; gap: 8px; }
.row {
    display: flex; align-items: center; gap: 10px;
    padding: 12px; border-radius: 10px;
    border: 1px solid var(--border); background: transparent;
    cursor: pointer; text-align: left; color: inherit; font-family: inherit;
}
.row:hover { background: rgba(255,255,255,0.025); }
.row .emoji { font-size: 24px; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; }
.row .meta { font-size: 11px; color: var(--muted); }
.row .chev { font-size: 20px; color: var(--muted); }

/* ─── Game ─────────────────────────────────────────────────────────── */

.game { max-width: 960px; margin: 0 auto; padding: 24px 18px 80px; }

.topbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; margin-bottom: 18px;
}
.brand { font-size: 18px; }
.brand b { font-weight: 700; margin: 0 4px; }
.meta { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
    font-size: 12px; font-weight: 600;
    padding: 5px 10px; border-radius: 999px;
    background: var(--panel); border: 1px solid var(--border);
}
.pill.ghost { color: var(--muted); }

/* Status bar — big, central, the user's primary feedback channel. */
.status {
    display: flex; align-items: center; gap: 14px;
    padding: 18px 22px; margin-bottom: 22px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    transition: border-color 0.2s, background 0.2s;
}
.status.ok   { border-color: var(--ok);   background: rgba(34,197,94,0.08); }
.status.err  { border-color: var(--err);  background: rgba(239,68,68,0.08); }
.status.warn { border-color: var(--warn); background: rgba(245,158,11,0.08); }
.status-icon { font-size: 32px; line-height: 1; }
.status-text { font-size: 17px; font-weight: 500; }

/* Groups — head/body/antennas */
.group {
    margin-bottom: 22px;
    transition: opacity 0.2s;
}
.group.dim { opacity: 0.35; }
.group-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em;
    color: var(--muted); margin-bottom: 10px;
}
.hint { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* Cross layout for head tilts. */
.cross { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cross-row { display: flex; gap: 12px; align-items: center; justify-content: center; }
.cross-center {
    width: 96px; height: 96px;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px;
    background: var(--panel-2); border: 1px dashed var(--border);
    border-radius: 50%;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* The lit-up tiles. Color comes from --c which the tile template sets
 * per-direction. Unlit state is a desaturated outline; lit state flashes
 * the tile in its color. */
.tile {
    --c: #6366f1;
    flex: 1 1 120px;
    max-width: 160px;
    min-height: 80px;
    display: flex; align-items: center; justify-content: center;
    padding: 14px 12px;
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 14px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    transition: border-color 0.15s, transform 0.05s, background 0.15s;
    cursor: default;
    user-select: none;
}
.tile-label { white-space: nowrap; }

.tile.lit {
    animation: flash 0.45s ease-out;
    border-color: var(--c);
}
@keyframes flash {
    0%   { background: var(--c); color: #fff;        transform: scale(1.06); box-shadow: 0 0 30px var(--c); }
    60%  { background: var(--c); color: #fff;        transform: scale(1.03); box-shadow: 0 0 20px var(--c); }
    100% { background: var(--panel); color: var(--text); transform: scale(1.0); box-shadow: 0 0 0 transparent; }
}

/* ─── Leaderboard ──────────────────────────────────────────────────── */

.leaderboard {
    margin-top: 22px;
    padding: 16px 18px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.lb-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.lb-status { font-size: 12px; color: var(--muted); }
.lb-status.ok  { color: var(--ok); }
.lb-status.err { color: var(--err); }

.lb-list { list-style: none; padding: 0; margin: 0; }
.lb-row {
    display: grid;
    grid-template-columns: 32px 28px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
}
.lb-row:nth-child(odd) { background: rgba(255,255,255,0.02); }
.lb-row.lb-me { background: rgba(99,102,241,0.16); border: 1px solid rgba(99,102,241,0.5); }
.lb-rank {
    font-weight: 700;
    text-align: center;
    color: var(--muted);
}
.lb-rank.gold   { color: #fbbf24; }
.lb-rank.silver { color: #d1d5db; }
.lb-rank.bronze { color: #b45309; }
.lb-avatar, .lb-avatar-placeholder {
    width: 28px; height: 28px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
    background: var(--panel-2); border: 1px solid var(--border);
    object-fit: cover; overflow: hidden;
}
.lb-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.lb-score { font-weight: 700; }
.lb-empty {
    text-align: center;
    color: var(--muted);
    padding: 12px 0;
    font-size: 13px;
}
.lb-ellipsis {
    text-align: center;
    color: var(--muted);
    letter-spacing: 0.5em;
    padding: 4px 0;
}

@media (max-width: 640px) {
    .topbar { flex-direction: column; align-items: flex-start; }
    .tile { min-height: 64px; padding: 10px; font-size: 13px; }
    .cross-center { width: 72px; height: 72px; font-size: 28px; }
    .status-text { font-size: 15px; }
}
