/* ---------- CarFun styles ---------- */
:root {
  --bg: #0f1216;
  --bg-elev: #171b21;
  --bg-card: #1e232b;
  --line: #2b323c;
  --text: #eef2f6;
  --text-dim: #9aa4b2;
  --brand: #ffb703;
  --brand-2: #fb8500;
  --primary: #4f9dff;
  --primary-ink: #06121f;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);

  /* tier colours (worst -> best) */
  --t-horrible: #e74c3c;
  --t-bad: #e67e22;
  --t-mid: #f1c40f;
  --t-good: #27ae60;
  --t-awesome: #8e44ad;
}

* { box-sizing: border-box; }

/* The hidden attribute must always win over component display rules
   (.overlay/.active/.topbar__nav/.view--login all set display). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79, 157, 255, 0.12), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(255, 183, 3, 0.10), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 20px;
  background: rgba(15, 18, 22, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; }
.brand__logo { font-size: 26px; }
.brand__name {
  font-size: 22px; letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.topbar__nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar__who { color: var(--text-dim); font-size: 14px; margin: 0 4px; }

/* ---------- buttons ---------- */
.btn {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  padding: 9px 14px; border-radius: 12px; font-size: 14px; font-weight: 600;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s;
}
.btn:hover { background: #212832; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid rgba(79, 157, 255, 0.6); outline-offset: 2px; }
.btn--primary {
  background: linear-gradient(180deg, #67abff, var(--primary));
  border-color: transparent; color: var(--primary-ink);
}
.btn--primary:hover { background: linear-gradient(180deg, #7cb8ff, #58a3ff); }
.btn--ghost { background: transparent; }
.btn--lg { padding: 13px 22px; font-size: 16px; border-radius: 14px; }
.btn--sm { padding: 7px 12px; font-size: 13px; }

/* ---------- layout ---------- */
.main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 64px; }
.view { animation: fade 0.25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- login ---------- */
.view--login { display: grid; place-items: center; min-height: 62vh; }
.card--login { max-width: 560px; padding: 34px; text-align: center; }
.title { font-size: 30px; margin: 6px 0 10px; }
.subtitle { color: var(--text-dim); line-height: 1.6; margin: 0 0 22px; }
.login-form { display: flex; gap: 10px; flex-wrap: wrap; }
.input {
  flex: 1 1 220px; min-width: 0;
  background: var(--bg-elev); border: 1px solid var(--line); color: var(--text);
  padding: 13px 15px; border-radius: 14px; font-size: 16px;
}
.input:focus-visible { outline: 3px solid rgba(79, 157, 255, 0.6); outline-offset: 2px; }
.login-hint { color: var(--t-horrible); min-height: 20px; margin: 12px 0 0; font-size: 14px; }

/* ---------- play view ---------- */
.play { display: grid; gap: 20px; max-width: 720px; margin: 0 auto; }
.eyebrow, .rate-prompt {
  text-transform: uppercase; letter-spacing: 1.5px; font-size: 12px;
  color: var(--text-dim); font-weight: 700;
}
.play__scenario { text-align: center; }
.scenario-text { font-size: 28px; line-height: 1.25; margin: 8px 0 0; }
.play__car { padding: 18px; display: grid; gap: 12px; }
.car-art-wrap { display: grid; place-items: center; }
.car-art-wrap svg { width: 100%; max-width: 420px; height: auto; }
.car-meta { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--line); padding-top: 12px; }
.car-meta__emoji { font-size: 30px; }
.car-meta__name { font-size: 20px; font-weight: 800; margin: 0; }
.car-meta__model { color: var(--text-dim); margin: 2px 0 0; font-weight: 600; }
.car-meta__blurb { color: var(--text-dim); margin: 6px 0 0; font-size: 14px; font-style: italic; }

.play__rate { text-align: center; display: grid; gap: 12px; }
.tierpick { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.tier-btn {
  cursor: pointer; border: 2px solid transparent; border-radius: 14px;
  padding: 16px 8px; font-weight: 800; font-size: 15px; color: #10141a;
  transition: transform 0.1s ease, filter 0.15s ease, box-shadow 0.15s;
  box-shadow: var(--shadow);
}
.tier-btn small { display: block; font-size: 22px; margin-bottom: 4px; }
.tier-btn:hover { transform: translateY(-3px) scale(1.02); filter: brightness(1.08); }
.tier-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.tier--horrible { background: var(--t-horrible); }
.tier--bad { background: var(--t-bad); }
.tier--mid { background: var(--t-mid); }
.tier--good { background: var(--t-good); color: #06210f; }
.tier--awesome { background: var(--t-awesome); color: #fff; }

/* ---------- board (tier list) ---------- */
.board-head { margin-bottom: 18px; }
.board-title { font-size: 26px; margin: 0; }
.board-sub { color: var(--text-dim); margin: 6px 0 0; }
.tierboard { display: grid; gap: 12px; }
.tier-row {
  display: grid; grid-template-columns: 120px 1fr; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.tier-label {
  display: grid; place-items: center; text-align: center;
  font-weight: 900; font-size: 16px; color: #10141a; padding: 12px;
  letter-spacing: 0.5px;
}
.tier-label--horrible { background: var(--t-horrible); }
.tier-label--bad { background: var(--t-bad); }
.tier-label--mid { background: var(--t-mid); }
.tier-label--good { background: var(--t-good); color: #06210f; }
.tier-label--awesome { background: var(--t-awesome); color: #fff; }
.tier-items { display: flex; flex-wrap: wrap; gap: 10px; padding: 12px; min-height: 84px; align-items: center; }
.tier-empty { color: var(--text-dim); font-size: 14px; font-style: italic; }

/* pairing card */
.pairing {
  width: 210px; background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: 14px; overflow: hidden; display: flex; flex-direction: column;
}
.pairing__art { background: linear-gradient(180deg, #10141a, #1a1f27); padding: 6px; }
.pairing__art svg { width: 100%; height: auto; display: block; }
.pairing__body { padding: 10px 12px; display: grid; gap: 6px; }
.pairing__car { font-weight: 800; font-size: 14px; }
.pairing__car span { color: var(--text-dim); font-weight: 600; }
.pairing__scenario { font-size: 13px; color: var(--text); line-height: 1.4; }
.pairing__foot { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.like-btn {
  cursor: pointer; border: 1px solid var(--line); background: var(--bg-card);
  color: var(--text); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px; transition: transform 0.08s, background 0.15s, border-color 0.15s;
}
.like-btn:hover { transform: translateY(-1px); background: #212832; }
.like-btn:focus-visible { outline: 3px solid rgba(79, 157, 255, 0.6); outline-offset: 2px; }
.like-btn.is-liked { background: rgba(231, 76, 60, 0.16); border-color: var(--t-horrible); color: #ff9a8f; }
.like-btn__pulse { animation: pop 0.3s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* ---------- browse ---------- */
.players { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.player-card {
  text-align: left; cursor: pointer; padding: 18px; display: grid; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  transition: transform 0.1s, border-color 0.15s, box-shadow 0.15s;
}
.player-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); }
.player-card__name { font-size: 18px; font-weight: 800; }
.player-card__stats { color: var(--text-dim); font-size: 14px; }
.empty-state { text-align: center; color: var(--text-dim); padding: 40px 16px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #11161d; border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); z-index: 50;
  animation: fade 0.2s ease;
}

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .scenario-text { font-size: 22px; }
  .tierpick { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .tier-btn { padding: 12px 4px; font-size: 12px; }
  .tier-btn small { font-size: 18px; }
  .tier-row { grid-template-columns: 84px 1fr; }
  .tier-label { font-size: 13px; padding: 8px; }
  .pairing { width: 100%; }
  .tier-items { flex-direction: column; align-items: stretch; }
  .topbar { flex-wrap: wrap; }
  .brand__name { font-size: 20px; }
}

/* ---------- round (5 scenarios × 5 cars) ---------- */
.round { display: grid; gap: 18px; max-width: 840px; margin: 0 auto; }
.round__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.round-title { margin: 0; font-size: 24px; }
.round-hint { margin: 4px 0 0; color: var(--text-dim); }
.round-progress {
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px; font-weight: 800; white-space: nowrap;
}

/* scenario board */
.scenboard { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.scen {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.scen__num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--bg-elev);
  border: 1px solid var(--line); display: grid; place-items: center; font-weight: 800; color: var(--text-dim);
}
.scen__main { display: grid; gap: 8px; min-width: 0; }
.scen__text { margin: 0; font-weight: 600; line-height: 1.35; }
.scen.is-target { cursor: pointer; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(79, 157, 255, 0.35); }
.scen.is-target:hover { background: #212a35; transform: translateY(-1px); }
.scen.is-target .scen__num { background: var(--primary); color: var(--primary-ink); border-color: transparent; }
.scen.is-filled .scen__num { background: var(--t-good); color: #06210f; border-color: transparent; }
.scen.is-chosen { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.45); }
.scen.is-chosen .scen__num { background: var(--brand); color: #10141a; border-color: transparent; }
.scen__slot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.scen__art { width: 76px; height: 52px; border-radius: 8px; overflow: hidden; flex: none; background: #0d1117; }
.scen__car { font-size: 13px; color: var(--text-dim); font-weight: 700; }
.badge { margin-left: auto; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #10141a; }
.badge--horrible { background: var(--t-horrible); color: #fff; }
.badge--bad { background: var(--t-bad); }
.badge--mid { background: var(--t-mid); }
.badge--good { background: var(--t-good); color: #06210f; }
.badge--awesome { background: var(--t-awesome); color: #fff; }

/* active revealed car */
.active { padding: 16px; display: grid; gap: 14px; }
.active__car { display: flex; gap: 16px; align-items: center; }
.active__art { width: 210px; aspect-ratio: 16 / 10; border-radius: 12px; overflow: hidden; background: #0d1117; flex: none; }
.active__meta { min-width: 0; }
.active__name { font-size: 20px; font-weight: 800; margin: 0; }
.active__model { color: var(--text-dim); margin: 2px 0 0; font-weight: 600; }
.active__blurb { color: var(--text-dim); font-style: italic; margin: 6px 0 0; font-size: 14px; }
.active__step { display: grid; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; }
.active__prompt { margin: 0; text-align: center; font-weight: 600; }

/* car hand */
.hand-wrap { display: grid; gap: 8px; }
.hand-label { text-align: center; color: var(--text-dim); font-size: 13px; margin: 0; }
.hand { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.handcard {
  border-radius: 14px; border: 1px solid var(--line); overflow: hidden; aspect-ratio: 3 / 4;
  display: grid; place-items: center; background: var(--bg-card); position: relative; padding: 0;
}
.handcard.is-down {
  cursor: pointer; color: #9ec3f0;
  background: repeating-linear-gradient(135deg, #243043, #243043 10px, #1d2735 10px, #1d2735 20px);
  transition: transform 0.1s ease, box-shadow 0.15s, border-color 0.15s;
}
.handcard.is-down:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--primary); }
.handcard.is-down:focus-visible { outline: 3px solid rgba(79, 157, 255, 0.6); outline-offset: 2px; }
.handcard__q { font-size: 40px; font-weight: 900; }
.handcard__hint { position: absolute; bottom: 8px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.85; }
.handcard.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.45); animation: flipin 0.3s ease; }
.handcard.is-used { opacity: 0.5; }
.handcard__art { width: 100%; height: 100%; }
.handcard__check {
  position: absolute; top: 6px; right: 8px; background: var(--t-good); color: #06210f;
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 13px;
}
@keyframes flipin { from { transform: rotateY(80deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* real photos + inline svg fill their frames */
.car-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.scen__art > *, .active__art > *, .handcard__art > *, .pairing__art > * {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.pairing__art { aspect-ratio: 16 / 10; padding: 0; }

@media (max-width: 640px) {
  .active__car { flex-direction: column; text-align: center; }
  .active__art { width: 100%; }
  .hand { gap: 6px; }
  .handcard__q { font-size: 26px; }
  .handcard__hint { font-size: 9px; bottom: 5px; }
  .scen__car { width: 100%; }
  .badge { margin-left: 0; }
}

/* ---------- used scenario strike-through ---------- */
.scen.is-filled { opacity: 0.95; }
.scen.is-filled .scen__text {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.55);
  text-decoration-thickness: 2px;
  opacity: 0.6;
}

/* ---------- image loading skeleton ---------- */
.art-loading { position: relative; background: #11161d; overflow: hidden; min-height: 40px; }
.art-loading::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  transform: translateX(-100%); animation: shimmer 1.1s infinite;
}
@keyframes shimmer { 100% { transform: translateX(100%); } }
.car-photo { animation: fadephoto 0.3s ease; }
@keyframes fadephoto { from { opacity: 0; } to { opacity: 1; } }

/* ---------- loading overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(8, 10, 14, 0.62); backdrop-filter: blur(3px); animation: fade 0.15s ease;
}
.overlay__box {
  display: grid; justify-items: center; gap: 14px; padding: 26px 34px;
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.overlay__msg { margin: 0; color: var(--text-dim); font-weight: 600; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* subtle active-panel entrance */
.active { animation: fade 0.2s ease; }
