/* Crayon Kart — same palette family as the rest of automate.help, with a
   chalk-on-asphalt feel of its own. */

:root {
    --blue: #275EF5;
    --blue-dark: #1a4acf;
    --cyan: #22d3ee;
    --gold: #facc15;
    --green: #22c55e;
    --bg: #0b0b0e;
    --bg-deep: #070709;
    --surface: #101016;
    --surface-2: #16161f;
    --text: #f4f6fb;
    --muted: #a8b3cf;
    --line: rgba(255, 255, 255, 0.08);
    --line-strong: rgba(255, 255, 255, 0.16);
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg);
    background-image:
        radial-gradient(900px circle at 8% -8%, rgba(250, 204, 21, 0.09), transparent 60%),
        radial-gradient(760px circle at 100% 4%, rgba(39, 94, 245, 0.12), transparent 55%),
        radial-gradient(1100px circle at 50% 120%, rgba(34, 211, 238, 0.07), transparent 60%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--cyan); }

/* ── chrome ─────────────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0.65rem 1.1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 7, 9, 0.85);
    backdrop-filter: blur(10px);
    position: sticky; top: 0; z-index: 50;
}
.brand {
    display: flex; align-items: center; gap: 0.6rem;
    text-decoration: none; color: var(--text); font-weight: 700; letter-spacing: 0.02em;
}
.brand svg { width: 26px; height: 26px; }
.brand-sub { color: var(--gold); font-weight: 600; letter-spacing: 0.16em; font-size: 0.72rem; text-transform: uppercase; }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.roomchip {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.3rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 999px;
    font-weight: 700; letter-spacing: 0.22em; color: var(--gold); background: rgba(250, 204, 21, 0.08);
}
.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.1rem 3rem; }

/* ── screens ────────────────────────────────────────────────────────────── */
.screen { display: none; animation: fade 0.25s ease; }
.screen.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; }
.title {
    font-size: 2.6rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1;
    background: linear-gradient(135deg, #facc15, #f97316);
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.sub { color: var(--muted); }
.h2 { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.9rem; }
.small { font-size: 0.85rem; color: var(--muted); }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.2rem; }

/* ── controls ───────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.8rem 1.35rem; border-radius: 10px; font-weight: 600;
    background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--text);
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, opacity 0.15s;
}
.btn:hover { transform: translateY(-1px); background: #1c1c27; }
.btn:active { transform: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
    background: linear-gradient(135deg, #facc15, #f59e0b); color: #1a1205;
    border-color: transparent; box-shadow: 0 6px 22px rgba(250, 204, 21, 0.28);
}
.btn-primary:hover { background: linear-gradient(135deg, #fde047, #facc15); }
.btn-cyan { background: linear-gradient(135deg, #22d3ee, #0ea5b7); color: #05161b; border-color: transparent; }
.btn-google { background: #fff; color: #1f2937; border-color: transparent; font-weight: 600; }
.btn-google:hover { background: #f1f5f9; }
.btn-lg { padding: 1rem 1.8rem; font-size: 1.05rem; }
.btn-sm { padding: 0.45rem 0.8rem; font-size: 0.85rem; border-radius: 8px; }
.icon-btn { padding: 0.4rem; }
.icon-btn svg { width: 18px; height: 18px; display: block; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-size: 0.82rem; color: var(--muted); margin-bottom: 0.35rem; }
.input {
    width: 100%; padding: 0.8rem 1rem; background: var(--bg-deep);
    border: 1px solid var(--line-strong); border-radius: 10px; outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.16); }
.input.code { text-transform: uppercase; letter-spacing: 0.5em; text-align: center; font-weight: 800; font-size: 1.5rem; padding-left: 1.5rem; }
.row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 0.4rem; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ── home ───────────────────────────────────────────────────────────────── */
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 2rem; align-items: center; }
.home-copy .title { margin-bottom: 0.9rem; }
.home-copy p { color: var(--muted); max-width: 48ch; margin-bottom: 1.2rem; }
.mode-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.mode-chips span {
    padding: 0.3rem 0.7rem; border: 1px solid var(--line-strong); border-radius: 999px;
    font-size: 0.78rem; color: var(--muted); background: rgba(255, 255, 255, 0.03);
}
.auth-box { margin-bottom: 1.2rem; }
.signed-row { display: flex; align-items: center; gap: 0.6rem; font-size: 0.9rem; }
.signed-row .verified { color: var(--ok); font-weight: 700; }
.signed-row b { color: var(--gold); }
.signed-row .btn { margin-left: auto; }

.divider { display: flex; align-items: center; gap: 0.8rem; color: var(--muted); font-size: 0.8rem; margin: 1.2rem 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.entry { display: flex; flex-direction: column; }
.entry.invited #joinBlock { order: -2; }
.entry.invited #entryDivider { order: -1; }
.invite-note {
    display: block; text-align: center; padding: 0.7rem 1rem; margin-bottom: 0.8rem; border-radius: 12px;
    background: linear-gradient(135deg, rgba(250, 204, 21, 0.14), rgba(249, 115, 22, 0.1));
    border: 1px solid rgba(250, 204, 21, 0.4);
}
.invite-note .lab { display: block; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); }
.invite-note .txt { display: block; font-size: 1.05rem; font-weight: 700; }
.invite-note b { letter-spacing: 0.2em; color: var(--gold); }

/* ── lobby ──────────────────────────────────────────────────────────────── */
.lobby-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 0.7rem; }
.player {
    position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
    padding: 0.9rem 0.5rem; background: var(--surface-2); border: 1px solid var(--line);
    border-radius: 12px; text-align: center;
}
.player .dot { width: 26px; height: 12px; border-radius: 4px; }
.player .pn { font-weight: 600; font-size: 0.9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .tag { font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); }
.player .tag.ready { color: var(--ok); }
.player.off { opacity: 0.4; }
.player .kick { position: absolute; top: 4px; right: 6px; color: var(--muted); font-size: 1rem; opacity: 0; transition: opacity 0.15s; }
.player:hover .kick { opacity: 1; }
.player .kick:hover { color: var(--danger); }

.invite { display: flex; gap: 0.5rem; align-items: center; background: var(--bg-deep); border: 1px dashed var(--line-strong); border-radius: 10px; padding: 0.6rem 0.75rem; }
.invite input { flex: 1; background: none; border: none; outline: none; color: var(--muted); font-size: 0.85rem; min-width: 0; }

.setting { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0.75rem; padding: 0.55rem 0; border-bottom: 1px solid var(--line); }
.setting:last-of-type { border-bottom: none; }
.setting .hint { display: block; font-size: 0.75rem; color: var(--muted); }
.setting input { width: 110px; padding: 0.4rem 0.6rem; background: var(--bg-deep); border: 1px solid var(--line-strong); border-radius: 8px; outline: none; }

.control-pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 0.5rem; }
.control-card {
    padding: 0.6rem 0.4rem; border-radius: 10px; background: var(--surface-2);
    border: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; font-weight: 600; text-align: center;
}
.control-card.sel { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.12); }
.control-card:disabled { opacity: 0.4; cursor: not-allowed; }

.chat { display: flex; flex-direction: column; height: 200px; }
.chat-log { flex: 1; overflow-y: auto; font-size: 0.88rem; padding-right: 0.3rem; }
.chat-log p { margin-bottom: 0.2rem; word-break: break-word; }
.chat-log b { color: var(--gold); }
.chat-log .sys { color: var(--muted); font-style: italic; }

/* ── drawing ────────────────────────────────────────────────────────────── */
.taskbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; flex-wrap: wrap; }
.steps { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.step-dot {
    padding: 0.3rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
    border: 1px solid var(--line-strong); color: var(--muted);
}
.step-dot.on { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.12); }
.step-dot.done { border-color: var(--ok); color: var(--ok); }
.timer {
    font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.5rem;
    padding: 0.15rem 0.8rem; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--bg-deep);
}
.timer.warn { color: var(--warn); border-color: rgba(245, 158, 11, 0.5); }
.timer.hot { color: var(--danger); border-color: rgba(239, 68, 68, 0.6); animation: pulse 0.9s infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; flex-wrap: wrap; }
.pane-head h3 { font-size: 1.15rem; }
.loop-badge {
    padding: 0.35rem 0.8rem; border-radius: 999px; font-size: 0.8rem; font-weight: 600;
    border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap;
}
.loop-badge.loop { border-color: var(--ok); color: var(--ok); background: rgba(16, 185, 129, 0.12); }
.loop-badge.sprint { border-color: var(--cyan); color: var(--cyan); background: rgba(34, 211, 238, 0.12); }

.size-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.size-pick { display: flex; gap: 0.4rem; }
.size-btn {
    padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
    border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted);
}
.size-btn.sel { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.14); }

.draw-row { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 0.9rem; align-items: start; }
.kinds { display: flex; flex-direction: column; gap: 0.4rem; }
.kind {
    display: flex; align-items: center; gap: 0.45rem; padding: 0.45rem 0.5rem;
    border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line);
    color: var(--muted); font-size: 0.78rem; font-weight: 600; text-align: left;
}
.kind i { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.kind.sel { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.1); }
/* Art pads only need swatches, so pack them into a grid rather than stacking
   full-width rows. */
#sideColours, #frontColours, #topColours {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
    align-content: start;
}
#sideColours .tool-toggle, #frontColours .tool-toggle, #topColours .tool-toggle,
#sideColours .nib-row, #frontColours .nib-row, #topColours .nib-row { grid-column: 1 / -1; }
#sideColours .kind:not(.tool-btn), #frontColours .kind:not(.tool-btn), #topColours .kind:not(.tool-btn) {
    justify-content: center;
    padding: 0.4rem 0.3rem;
}
#sideColours .kind i, #frontColours .kind i, #topColours .kind i { width: 18px; height: 18px; }

.tool-toggle { display: flex; gap: 0.35rem; margin-bottom: 0.5rem; width: 100%; }
.nib-row { display: flex; gap: 0.3rem; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 0.5rem; }
.nib {
    flex: 1 1 auto; height: 28px; border-radius: 8px;
    background: var(--surface-2); border: 1px solid var(--line);
    display: grid; place-items: center;
}
.nib i { display: block; background: var(--text); border-radius: 50%; }
.nib.sel { border-color: var(--gold); background: rgba(250, 204, 21, 0.14); }
.nib.sel i { background: var(--gold); }
.tool-btn { flex: 1 1 auto; justify-content: center; }
.tool-btn.sel { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.14); }

.pad-holder {
    background: #f7f7fb; border: 1px solid var(--line-strong); border-radius: 12px;
    overflow: hidden; touch-action: none; width: 100%;
}
.pad-holder canvas { display: block; width: 100%; height: auto; touch-action: none; cursor: crosshair; }
.pad-holder.car, .pad-holder.wheel { max-width: 520px; }

/* ── waiting ────────────────────────────────────────────────────────────── */
.waitwrap { text-align: center; padding: 3rem 1rem; }
.spinner {
    width: 46px; height: 46px; margin: 0 auto 1.2rem;
    border: 3px solid rgba(255, 255, 255, 0.12); border-top-color: var(--gold);
    border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-line { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-line i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #f97316); width: 0; transition: width 0.3s ease; }

/* ── race ───────────────────────────────────────────────────────────────── */
.race-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); background: #0b0b0e; }
#raceCanvas { display: block; width: 100%; height: min(72vh, 720px); touch-action: none; }
.hud { position: absolute; inset: 0; pointer-events: none; display: flex; justify-content: space-between; align-items: flex-start; padding: 0.8rem; }
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 0.4rem; }
.hud-right { align-items: flex-end; }
.hud-chip {
    background: rgba(10, 10, 14, 0.72); border: 1px solid var(--line-strong); border-radius: 10px;
    padding: 0.25rem 0.7rem; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem;
    backdrop-filter: blur(6px);
}
.hud-btn { pointer-events: auto; cursor: pointer; font-size: 0.8rem; opacity: 0.85; }
.hud-btn:hover { opacity: 1; border-color: var(--gold); }

.race-msg {
    position: absolute; left: 50%; top: 58%; transform: translate(-50%, -50%);
    background: rgba(10, 10, 14, 0.85); border: 1px solid var(--gold); color: var(--text);
    padding: 0.8rem 1.4rem; border-radius: 12px; font-weight: 700; text-align: center;
}

.touch-pad { position: absolute; inset: auto 0 0 0; display: flex; justify-content: space-between; padding: 0.9rem; pointer-events: none; }
.tp-left, .tp-right { display: flex; gap: 0.6rem; pointer-events: auto; }
.tp-btn {
    width: 74px; height: 74px; border-radius: 50%;
    background: rgba(20, 20, 28, 0.75); border: 1px solid var(--line-strong);
    color: var(--text); font-weight: 800; font-size: 1.1rem;
    display: grid; place-items: center; user-select: none; -webkit-user-select: none;
    backdrop-filter: blur(6px);
}
.tp-btn:active, .tp-btn.on { background: rgba(250, 204, 21, 0.3); border-color: var(--gold); }
.tp-btn.gas { background: rgba(34, 197, 94, 0.28); font-size: 1rem; }
.tp-btn.brake { background: rgba(239, 68, 68, 0.22); font-size: 0.7rem; }

/* ── boards ─────────────────────────────────────────────────────────────── */
.board { display: flex; flex-direction: column; gap: 0.45rem; }
.board .rowx {
    display: grid; grid-template-columns: 28px 14px 1fr auto; align-items: center; gap: 0.6rem;
    padding: 0.6rem 0.8rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
    font-size: 0.92rem;
}
.board .rowx.top { border-color: rgba(250, 204, 21, 0.5); box-shadow: 0 0 20px rgba(250, 204, 21, 0.12); }
.board .rowx.me { border-color: var(--cyan); }
.board .rk { color: var(--muted); font-weight: 700; text-align: center; }
.board .swatch-dot { width: 12px; height: 12px; border-radius: 3px; }
.board .sc { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }
.board .verified { color: var(--ok); }

/* ── toast ──────────────────────────────────────────────────────────────── */
#toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
    background: #17171f; border: 1px solid var(--line-strong); border-radius: 10px;
    padding: 0.7rem 1.1rem; font-size: 0.9rem; opacity: 0; pointer-events: none;
    transition: opacity 0.25s, transform 0.25s; z-index: 300; max-width: min(92vw, 460px);
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.err { border-color: rgba(239, 68, 68, 0.6); color: #ffb4b4; }

/* ── responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 940px) {
    .home-grid, .lobby-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
    .wrap { padding: 1rem 0.75rem 2.5rem; }
    .title { font-size: 2rem; }
    .card { padding: 1.1rem; }
    .size-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-bottom: 0.8rem; }
.size-pick { display: flex; gap: 0.4rem; }
.size-btn {
    padding: 0.35rem 0.85rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600;
    border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted);
}
.size-btn.sel { border-color: var(--gold); color: var(--text); background: rgba(250, 204, 21, 0.14); }

.draw-row { grid-template-columns: 1fr; }
    .kinds { flex-direction: row; flex-wrap: wrap; }
    .kind { flex: 1 1 auto; justify-content: center; }
    #raceCanvas { height: min(62vh, 520px); }
    .tp-btn { width: 66px; height: 66px; }
}
