/* =========================================================================
   LIGHTS OUT — shared styles
   Visual system: dark "asphalt" canvas, F1 timing-screen accents,
   timing-tower layout. Signature: the 5 red start lights.
   ========================================================================= */

:root {
  --bg:        #0B0E13;
  --bg-2:      #0E1117;
  --surface:   #161B23;
  --surface-2: #1C222C;
  --line:      #262D38;
  --line-2:    #333B49;
  --text:      #E9EBEE;
  --muted:     #8A909B;
  --muted-2:   #5B626D;

  --red:    #E10600;   /* brand / wrong / start lights */
  --red-lo: #4A0F0D;
  --green:  #2BD17E;   /* correct */
  --purple: #B26BFF;   /* fastest */
  --yellow: #FFC400;   /* caution / lives */

  --t-green:  #2BA84A; /* Driverdle tiles */
  --t-orange: #E8A33D;
  --t-red:    #B0413C;

  --display: "Chakra Petch", system-ui, sans-serif;
  --body:    "Archivo", system-ui, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, monospace;

  --r: 12px;
  --maxw: 1080px;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #131925 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

/* ---- top bar --------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.wordmark {
  font-family: var(--display); font-weight: 700;
  font-size: 22px; letter-spacing: .16em; text-transform: uppercase;
  line-height: 1;
}
.wordmark .lo { color: var(--red); }
.topbar .tag {
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  color: var(--muted); text-transform: uppercase; margin-left: auto;
}

/* ---- start-lights gantry (signature) --------------------------------- */
.gantry { display: inline-flex; gap: 6px; align-items: center; }
.gantry .bulb {
  width: 12px; height: 12px; border-radius: 50%;
  background: #2a1111; border: 1px solid #3a1614;
  box-shadow: inset 0 0 3px #000;
}
.gantry .bulb.on {
  background: radial-gradient(circle at 35% 30%, #ff5b4d, var(--red) 70%);
  border-color: #ff6a5e;
  box-shadow: 0 0 10px rgba(225,6,0,.8), 0 0 22px rgba(225,6,0,.35);
}

/* ---- HERO (home) ----------------------------------------------------- */
.hero { padding: 54px 0 26px; text-align: center; }
.hero .gantry { transform: scale(1.7); margin-bottom: 30px; }
.hero h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(34px, 7vw, 64px); line-height: .98;
  letter-spacing: .02em; margin: 0 0 14px; text-transform: uppercase;
}
.hero h1 em { font-style: normal; color: var(--red); }
.hero p {
  color: var(--muted); max-width: 460px; margin: 0 auto;
  font-size: 16px;
}
.hero .date-chip {
  display: inline-block; margin-top: 18px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .1em;
  color: var(--muted); text-transform: uppercase;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
}

/* ---- games grid ------------------------------------------------------ */
.section-label {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--mono); font-size: 12px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--muted);
  margin: 40px 0 16px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.games {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  padding-bottom: 64px;
}
.game-card {
  position: relative; display: block; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 20px 20px 18px;
  transition: border-color .15s, transform .15s, background .15s;
}
.game-card::before {                 /* left team-style colour bar */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent, var(--red));
}
.game-card.live:hover { border-color: var(--line-2); transform: translateY(-2px); background: var(--surface-2); }
.game-card .pnum {
  font-family: var(--mono); font-size: 12px; color: var(--muted-2);
  letter-spacing: .1em;
}
.game-card h3 {
  font-family: var(--display); font-weight: 600; font-size: 22px;
  margin: 6px 0 6px; letter-spacing: .01em;
}
.game-card p { margin: 0; color: var(--muted); font-size: 14px; min-height: 40px; }
.game-card .foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 16px;
}
.chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: .12em;
  text-transform: uppercase; padding: 5px 10px; border-radius: 6px;
  border: 1px solid var(--line-2); color: var(--muted);
}
.chip.win  { color: var(--green);  border-color: rgba(43,209,126,.4); background: rgba(43,209,126,.08); }
.chip.loss { color: var(--red);    border-color: rgba(225,6,0,.45);   background: rgba(225,6,0,.10); }
.chip.play { color: var(--text);   border-color: var(--line-2); }
.cta { font-family: var(--mono); font-size: 12px; color: var(--text); letter-spacing: .08em; }
.cta .arw { color: var(--red); }

.game-card.locked { opacity: .5; pointer-events: none; }
.game-card.locked::before { background: var(--line-2); }
.game-card.locked .cta { color: var(--muted-2); }

/* ---- game page header ------------------------------------------------ */
.game-top {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.back { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.back:hover { color: var(--text); }
.lives {
  display: flex; align-items: center; gap: 14px; margin-left: auto;
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 12px; padding: 10px 16px;
}
.lives .label { font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .18em; text-transform: uppercase; }
.gantry.big { gap: 11px; }
.gantry.big .bulb { width: 24px; height: 24px; }
.lives.shake { animation: shake .34s; }

.race-head { padding: 26px 0 18px; }
.race-head .kicker {
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
  color: var(--red); text-transform: uppercase;
}
.race-head h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(26px, 4.5vw, 40px); margin: 8px 0 10px; line-height: 1.02;
}
.race-meta {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  color: var(--muted); font-size: 14px;
}
.race-meta .m { display: inline-flex; align-items: center; gap: 7px; }
.race-meta img.fl { width: 20px; height: 14px; object-fit: cover; border-radius: 2px; }

.daynav { display: flex; align-items: center; gap: 8px; margin: 18px 0 6px; }
.daynav button {
  font-family: var(--mono); font-size: 12px; letter-spacing: .06em;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 12px;
  cursor: pointer;
}
.daynav button:hover:not(:disabled) { border-color: var(--text); }
.daynav button:disabled { opacity: .35; cursor: not-allowed; }
.daynav .today { color: var(--muted); margin-left: 6px; font-family: var(--mono); font-size: 12px; }
.daynav .archive-tag { color: var(--yellow); }

/* ---- timing tower (the board) --------------------------------------- */
.tower { margin: 14px 0 160px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.tower-row {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2);
}
.tower-row:last-child { border-bottom: 0; }
.tower-row .pos {
  font-family: var(--mono); font-weight: 600; font-size: 18px;
  color: var(--muted); width: 30px; text-align: center; flex: none;
}

/* team mark: logo image or coloured fallback chip */
.team-mark {
  width: 46px; height: 32px; border-radius: 6px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--tc, #333); overflow: hidden;
}
.team-mark img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.team-mark .abbr {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  color: #fff; letter-spacing: .04em; mix-blend-mode: difference;
}
.team-name {
  font-family: var(--body); font-weight: 600; font-size: 15px; color: var(--text);
  max-width: 210px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none;
}
.flag-mark { width: 26px; height: 18px; object-fit: cover; border-radius: 3px; flex: none; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }

.answer {
  margin-left: auto; padding-left: 12px; min-width: 0;
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
}
.answer .ph { display: inline-block; width: 84px; border-bottom: 2px dotted var(--line-2); }
.answer .name {
  font-size: 16px; color: var(--text); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tower-row .state { width: 20px; text-align: center; font-family: var(--mono); font-size: 15px; color: var(--muted-2); flex: none; }

.tower-row.correct { background: linear-gradient(90deg, rgba(43,209,126,.10), transparent 45%); }
.tower-row.correct .pos { color: var(--green); }
.tower-row.correct .state { color: var(--green); }
.tower-row.revealed .pos { color: var(--muted-2); }
.tower-row.revealed .answer .name { color: var(--muted); }
.tower-row.revealed .state { color: var(--red); }

/* animations */
@keyframes shake {
  0%,100%{transform:translateX(0)} 20%{transform:translateX(-6px)}
  40%{transform:translateX(6px)} 60%{transform:translateX(-4px)} 80%{transform:translateX(4px)}
}
@keyframes nameIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes revealIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
@keyframes flashGreen { 0% { opacity: .30; } 100% { opacity: 0; } }
@keyframes bulbDie {
  0%,30%,60%{filter:brightness(1)} 15%,45%{filter:brightness(.15)} 100%{filter:brightness(.12);opacity:.55}
}
.tower-row.just-correct::before {
  content: ""; position: absolute; inset: 0; background: var(--green);
  opacity: 0; animation: flashGreen .6s ease both; pointer-events: none;
}
.answer .name.pop { animation: nameIn .36s ease both; }
.answer .name.reveal { animation: revealIn .32s ease both; }
.bulb.dying { animation: bulbDie .6s ease both; }

/* win confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.confetti i {
  position: absolute; top: -16px; width: 9px; height: 14px; border-radius: 2px;
  opacity: .95; animation: fall 2.2s cubic-bezier(.2,.6,.3,1) forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: 0; } }

/* ---- search dock ----------------------------------------------------- */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 16px 20px 18px;
}
.dock-inner { max-width: var(--maxw); margin: 0 auto; position: relative; }
.search-row { display: flex; gap: 10px; }
.search-box { position: relative; flex: 1; }
.search-box input {
  width: 100%; background: var(--surface); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 14px 16px; font-family: var(--body); font-size: 16px;
}
.search-box input:focus { outline: 2px solid var(--red); outline-offset: 0; border-color: var(--red); }
.search-box input::placeholder { color: var(--muted-2); }

.submit {
  font-family: var(--display); font-weight: 600; letter-spacing: .04em;
  background: var(--red); color: #fff; border: 0; border-radius: 10px;
  padding: 0 22px; font-size: 16px; cursor: pointer; text-transform: uppercase;
}
.submit:disabled { background: var(--surface-2); color: var(--muted-2); cursor: not-allowed; }

.results {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
  background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 10px; max-height: 280px; overflow-y: auto; display: none;
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
}
.results.show { display: block; }
.results .opt {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.results .opt:last-child { border-bottom: 0; }
.results .opt:hover, .results .opt.hi { background: var(--surface-2); }
.results .opt img { width: 22px; height: 15px; object-fit: cover; border-radius: 2px; flex: none; }
.results .opt .on { font-size: 15px; }
.results .opt .od { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.results .empty { padding: 14px; color: var(--muted); font-size: 14px; }

/* ---- end banner / overlay ------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(6,8,12,.78); backdrop-filter: blur(4px);
}
.overlay.show { display: flex; }
.modal {
  position: relative;
  width: 100%; max-width: 460px; background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 16px; padding: 28px 26px;
  text-align: center; max-height: 92vh; overflow-y: auto;
}
.modal-x {
  position: absolute; top: 12px; right: 14px; z-index: 2;
  background: none; border: 0; color: var(--muted); font-size: 24px;
  line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px;
}
.modal-x:hover { color: var(--text); background: var(--surface-2); }
.modal .res-kicker { font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.modal h2 { font-family: var(--display); font-size: 40px; margin: 8px 0 4px; text-transform: uppercase; letter-spacing: .02em; }
.modal h2.win { color: var(--green); }
.modal h2.loss { color: var(--red); }
.modal .score { font-family: var(--mono); color: var(--muted); margin-bottom: 18px; }

/* end-of-game stats */
.stats { margin: 4px 0 18px; }
.stat-row { display: flex; justify-content: space-around; gap: 6px; margin-bottom: 16px; }
.stat-row.two { justify-content: center; gap: 40px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat .num { font-family: var(--display); font-weight: 700; font-size: 26px; line-height: 1; }
.stat .lab { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; color: var(--muted); text-transform: uppercase; margin-top: 6px; }
.hist { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.hist-row { display: flex; align-items: center; gap: 8px; }
.hist-row .hl { font-family: var(--mono); font-size: 12px; color: var(--muted); width: 20px; text-align: right; flex: none; }
.hist-row .bar {
  background: var(--line-2); height: 20px; border-radius: 3px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 7px; min-width: 22px; color: var(--text);
  font-family: var(--mono); font-size: 11px; transition: width .5s ease;
}
.hist-row.cur .bar { background: var(--red); color: #fff; }
.modal .btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.modal .btns button {
  font-family: var(--mono); font-size: 13px; letter-spacing: .06em;
  padding: 11px 18px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text);
}
.modal .btns button.primary { background: var(--red); border-color: var(--red); color: #fff; }
.modal .btns button:hover { border-color: var(--text); }
.modal .note { margin-top: 14px; font-size: 12px; color: var(--muted-2); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: 110px; z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line-2);
  color: var(--text); font-family: var(--mono); font-size: 13px;
  padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
.toast.bad { border-color: rgba(225,6,0,.5); }

footer.site { color: var(--muted-2); font-size: 12px; font-family: var(--mono); padding: 30px 0 50px; text-align: center; border-top: 1px solid var(--line); }

@media (max-width: 560px) {
  .tower-row { gap: 8px; padding: 10px; }
  .team-name { max-width: 96px; font-size: 13px; }
  .answer .name { font-size: 14px; }
  .answer .ph { width: 54px; }
  .submit { padding: 0 16px; }
  .gantry.big .bulb { width: 20px; height: 20px; }
}

/* ---- Driverdle ------------------------------------------------------ */
.dd-instr { color: var(--muted); font-size: 14px; margin: 6px 0 0; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 16px 0 2px;
  font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: .03em; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.g { background: var(--t-green); } .legend i.o { background: var(--t-orange); } .legend i.r { background: var(--t-red); }

.guesses-left { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--muted); letter-spacing: .14em; text-transform: uppercase; }
.guesses-left b { color: var(--text); }

.ddgrid { max-width: 600px; margin: 18px auto 150px; }
.dd-head, .dd-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; margin-bottom: 7px; }
.dd-head span { font-family: var(--mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.tile {
  height: 60px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--mono); font-weight: 600; color: var(--text); overflow: hidden;
}
.tile .v { font-size: clamp(13px, 3.6vw, 17px); line-height: 1; }
.tile .arrow { font-size: 12px; line-height: 1; }
.tile img.fl { width: 30px; height: 21px; object-fit: cover; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0,0,0,.3); }
.tile .logo { width: 76%; height: 70%; display: flex; align-items: center; justify-content: center; }
.tile .logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tile .logo .abbr { font-size: 12px; font-weight: 700; color: #fff; mix-blend-mode: difference; }
.tile.g { background: var(--t-green); border-color: transparent; color: #06210f; }
.tile.o { background: var(--t-orange); border-color: transparent; color: #3a2400; }
.tile.r { background: var(--t-red); border-color: transparent; color: #fff; }
@keyframes ddReveal { 0% { transform: rotateX(90deg); opacity: 0; } 100% { transform: rotateX(0); opacity: 1; } }
.tile.reveal { animation: ddReveal .42s ease both; }

@media (max-width: 560px) {
  .tile { height: 46px; border-radius: 6px; }
  .tile img.fl { width: 24px; height: 16px; }
  .dd-head span { font-size: 9px; }
  .dd-head, .dd-row { gap: 5px; }
}

/* ---- Higher or Lower ------------------------------------------------ */
.hl-wrap { max-width: 520px; margin: 14px auto 150px; }
.hl-streak { text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hl-streak b { color: var(--text); }
.hl-pips { display: flex; gap: 6px; justify-content: center; margin: 8px 0 16px; flex-wrap: wrap; }
.hl-pips i { width: 14px; height: 14px; border-radius: 50%; background: #15201a; border: 1px solid #24332b; }
.hl-pips i.on { background: radial-gradient(circle at 35% 30%, #7be3a4, var(--t-green) 70%); border-color: #7be3a4; box-shadow: 0 0 8px rgba(43,168,74,.55); }
.hl-statlabel { text-align: center; font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: .06em; text-transform: uppercase; color: var(--text); margin-bottom: 12px; }

.hl-card { position: relative; border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; background: var(--surface); overflow: hidden; transition: border-color .2s; }
.hl-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--tc, #444); }
.hl-card .who { display: flex; align-items: center; gap: 14px; }
.hl-card .nm { font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.05; }
.hl-card .sub { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.hl-card .val { font-family: var(--mono); font-weight: 600; font-size: 38px; text-align: center; margin-top: 8px; }
.hl-card .val .q { color: var(--muted-2); }
.hl-card .val small { font-size: 14px; color: var(--muted); font-weight: 400; }
.hl-card.correct { border-color: var(--t-green); }
.hl-card.wrong { border-color: var(--t-red); }
@keyframes countpop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.hl-card .val.reveal { animation: countpop .3s ease both; }

.hl-vs { text-align: center; font-family: var(--mono); font-size: 12px; color: var(--muted-2); letter-spacing: .2em; margin: 10px 0; }
.hl-q { text-align: center; color: var(--muted); font-size: 14px; margin: 4px 0 14px; }
.hl-btns { display: flex; gap: 12px; justify-content: center; }
.hl-btn { flex: 1; max-width: 200px; font-family: var(--display); font-weight: 600; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; padding: 14px 18px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.hl-btn:hover:not(:disabled) { border-color: var(--text); }
.hl-btn:disabled { opacity: .5; cursor: default; }
.hl-btn.higher .ar { color: var(--green); }
.hl-btn.lower .ar { color: var(--red); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}