/* AV Engineer web: Hamilton Robson palette (Ink, Signal teal, Clay, Paper, Muted), Poppins + IBM Plex Mono */
:root {
  --ink: #0b0e1a;
  --navy: #001a70;
  --teal: #2ed9c3;
  --teal-deep: #0f766e;
  --clay: #c9714f;
  --paper: #f3f1ec;
  --card: #ffffff;
  --muted: #868ca6;
  --line: #e2ded5;
  --text: #1c2030;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 14, 26, .06), 0 8px 24px rgba(11, 14, 26, .06);
  --display: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--text); font: 15px/1.5 var(--display); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }

/* ---------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left));
  background: var(--ink); color: #fff;
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand-mark { font-weight: 700; letter-spacing: .02em; }
.brand-sep { color: var(--muted); }
.brand-app { color: var(--teal); font-weight: 600; white-space: nowrap; }
.user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.badge { font: 600 11px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em; padding: 4px 7px; border-radius: 999px; background: var(--clay); color: #fff; }

/* ---------- layout */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start;
  max-width: 1240px; margin: 0 auto; padding: 20px 16px 40px;
}
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- game */
.game-panel { padding: 14px; }
.stage { position: relative; width: 100%; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden; background: #0b0e1a; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.hint { margin: 0 0 0 auto; color: var(--muted); font-size: 13px; }
@media (max-width: 640px) { .hint { margin-left: 0; width: 100%; } }
kbd { font: 500 11px/1 var(--mono); padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--paper); color: var(--text); }
.status { min-height: 1.5em; margin: 8px 2px 0; color: var(--teal-deep); font-weight: 500; font-size: 14px; }

/* ---------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: 600 14px/1 var(--display); text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #cfc9bd; background: #faf9f6; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, select:focus-visible, .tabs button:focus-visible { outline: 3px solid color-mix(in srgb, var(--teal) 70%, transparent); outline-offset: 2px; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-primary:hover { background: #00238f; border-color: #00238f; }
.btn-ghost { background: transparent; }
.btn-on-dark { color: #fff; border-color: #2d3247; }
.btn-on-dark:hover { background: #1a1e2e; border-color: #3a4058; }
.btn[aria-pressed="true"] { border-color: var(--teal); color: var(--teal-deep); }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: inline-flex; align-items: center; gap: 8px; }
.field-label { font-size: 13px; color: var(--muted); }
select {
  min-height: 40px; padding: 0 34px 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card);
  font: 500 14px var(--display); color: var(--text); appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}

/* ---------- leaderboard */
.board-panel { padding: 16px; }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
h2 { margin: 0; font-size: 17px; color: var(--navy); }
h3 { margin: 0 0 8px; font-size: 13px; color: var(--navy); }
.tabs { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--paper); border: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 6px 10px; border-radius: 7px; font: 600 12px var(--display); color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--card); color: var(--navy); box-shadow: 0 1px 2px rgba(11, 14, 26, .08); }
.board { list-style: none; margin: 0; padding: 0; }
.board li {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto; align-items: center; gap: 8px;
  padding: 9px 8px; border-radius: 8px;
}
.board li + li { border-top: 1px solid #f0ede6; }
.board li.you { background: color-mix(in srgb, var(--teal) 16%, white); border-top-color: transparent; }
.board li.you + li { border-top-color: transparent; }
.rank { font: 600 13px var(--mono); color: var(--muted); text-align: center; }
.board li:nth-child(1) .rank { color: #b7791f; }
.board li:nth-child(2) .rank { color: #7c8597; }
.board li:nth-child(3) .rank { color: var(--clay); }
.who { min-width: 0; }
.who .name { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who .venue { display: block; font-size: 12px; color: var(--muted); }
.score { font: 600 15px var(--mono); color: var(--navy); }
.del { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; cursor: pointer; padding: 4px; border-radius: 6px; }
.del:hover { color: #b91c1c; background: #fef2f2; }
.board li.empty { display: block; }
.empty { padding: 18px 8px; color: var(--muted); font-size: 14px; text-align: center; }
.me { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: var(--paper); font-size: 13px; color: var(--text); }
.me strong { font-family: var(--mono); color: var(--navy); }
.board-note { margin: 8px 2px 0; font-size: 12px; color: var(--muted); }
.legend { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; color: #4a5068; }
.legend li { display: flex; gap: 8px; align-items: baseline; }
.dot { flex: none; width: 9px; height: 9px; border-radius: 50%; transform: translateY(1px); }
.dot-jump { background: var(--navy); }
.dot-coffee { background: var(--teal); }
.dot-tape { background: #facc15; }
.dot-ticket { background: var(--clay); }
.dot-hoist { background: #374151; }
.dot-truck { background: #8a929c; border-radius: 2px; }
.dot-plug { background: #38bdf8; }
.dot-vest { background: #f97316; }
.dot-radio { background: #a78bfa; }

/* ---------- arcade board */
.initials-name { font-family: var(--mono); letter-spacing: .12em; font-size: 16px; }
.you-tag { margin-left: 8px; padding: 2px 6px; border-radius: 999px; background: var(--teal-deep); color: #fff; font: 600 10px/1 var(--display); letter-spacing: .04em; vertical-align: 2px; }

/* ---------- initials at game over */
.initials {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 12px;
  background: rgba(11, 14, 26, .55); backdrop-filter: blur(2px);
}
.initials[hidden] { display: none; }
.initials-card {
  width: min(340px, 100%); padding: 18px 20px 16px; text-align: center;
  background: var(--card); border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.initials-eyebrow { margin: 0; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--clay); }
.initials-card h2 { margin: 4px 0 10px; font-size: 20px; }
.initials-card h2 span { font-family: var(--mono); }
.initials-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.initials-input {
  width: 4.6em; height: 1.6em; padding: 0 0 0 .35em; text-align: center; text-transform: uppercase;
  font: 600 34px/1 var(--mono); letter-spacing: .35em; color: var(--navy);
  border: 0; border-bottom: 3px solid var(--teal); background: var(--paper); border-radius: 8px 8px 0 0;
}
.initials-input:focus { outline: none; background: color-mix(in srgb, var(--teal) 12%, white); }
.initials-error { margin: 8px 0 0; font-size: 13px; color: #b91c1c; }
.initials-actions { display: flex; justify-content: center; gap: 10px; margin-top: 14px; }
@media (max-width: 480px) {
  .initials-card { padding: 12px 14px; }
  .initials-card h2 { font-size: 17px; margin-bottom: 6px; }
  .initials-input { font-size: 26px; }
  .initials-actions { margin-top: 10px; }
}

/* ---------- sign-in */
body.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(1200px 600px at 50% -10%, #e6edf5, var(--paper)); }
.signin-card { width: min(440px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; text-align: center; }
.signin-card h1 { margin: 2px 0 8px; font-size: 30px; color: var(--navy); letter-spacing: -.01em; }
.eyebrow { margin: 0; font: 600 12px var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--teal-deep); }
.lede { margin: 0 0 22px; color: #4a5068; }
.btn-ms { min-height: 46px; padding: 0 20px; font-size: 15px; }
.fineprint { margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.pin-form { display: grid; gap: 10px; justify-items: center; }
.pin-label { font-size: 13px; color: var(--muted); }
.pin-input {
  width: min(260px, 100%); height: 56px; padding: 0 0 0 .5em; text-align: center;
  font: 600 28px/1 var(--mono); letter-spacing: .5em; color: var(--navy);
  border: 1px solid var(--line); border-radius: 10px; background: var(--paper);
}
.pin-input:focus { outline: 3px solid color-mix(in srgb, var(--teal) 70%, transparent); outline-offset: 2px; border-color: var(--teal); background: #fff; }
.pin-input.is-error { border-color: #dc2626; background: #fef2f2; }
.pin-error { margin: 0; font-size: 13px; color: #b91c1c; }
.pin-form .btn { width: min(260px, 100%); }

/* ---------- small screens and touch */
@media (max-width: 640px) {
  .brand-mark, .brand-sep { display: none; }
  .btn-on-dark { min-height: 34px; padding: 0 12px; font-size: 13px; }
  .layout { padding: 12px 10px 28px; gap: 12px; }
  .game-panel, .board-panel { padding: 10px; }
  .controls { display: grid; grid-template-columns: 1fr 1fr; }
  .controls .field { grid-column: 1 / -1; }
  .controls .field select { flex: 1; }
}
@media (hover: none) and (pointer: coarse) {
  .hint { display: none; }
}
