/* The Endless taster. Shares the home page's palette and its one object — the
   number plate — so the browser game and the marketing around it look like the
   same thing, which they are. */

:root {
  --indigo-lift: #1E4269;
  --indigo: #17304F;
  --indigo-deep: #0A1826;
  --panel: #1B3B5E;
  --panel-high: #244D77;
  --edge: #335C86;
  --well: #102741;
  --gold: #F7C948;
  --lantern: #F2A03D;
  --chochin: #E2503A;
  --jade: #4CAF85;
  --paper: #FBF4E6;
  --paper-shade: #F0E4CC;
  --paper-edge: #C2AB80;
  --sumi: #241C14;
  --dusk: #9FB6D0;
  --dusk-deep: #5E7692;
  --display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --text: "Barlow", "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1100px 700px at 50% -10%, rgba(255,255,255,.06), transparent 60%),
    linear-gradient(180deg, var(--indigo-lift) 0%, var(--indigo) 38%, var(--indigo-deep) 100%);
  background-color: var(--indigo);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--text);
  font-size: 18px;
  line-height: 1.6;
  min-height: 100vh;
}
.wrap {
  max-width: 1040px; margin: 0 auto;
  padding-inline: max(20px, env(safe-area-inset-left));
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the plate ---------- */
.plate {
  position: relative; display: grid; place-items: center;
  background: linear-gradient(180deg, #FFFBF2, var(--paper-shade));
  color: var(--sumi); border-radius: 9px;
  box-shadow: 0 3px 0 var(--paper-edge), 0 6px 14px rgba(6,17,29,.55);
  font-family: var(--display); line-height: 1; overflow: hidden;
}
.plate::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1.5px;
  background: rgba(255,255,255,.85);
}
.plate.live::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 7%;
  min-height: 3px; background: var(--gold);
}
.plate.live { box-shadow: 0 3px 0 var(--paper-edge), 0 0 22px rgba(247,201,72,.35), 0 6px 14px rgba(6,17,29,.55); }
/* A wild is the one plate that isn't a number, so it is the one plate that
   isn't paper either. */
.plate.wild {
  background: linear-gradient(180deg, #FFE59A, var(--gold) 60%, #E9B72E);
  color: var(--indigo-deep);
}
/* Born from a wild: a quiet gold hairline down the left, so a ladder's
   history is readable without colouring the whole plate. A background layer
   rather than an ::after, which a live plate's gold bar already owns. */
.plate.wildborn {
  background:
    linear-gradient(90deg, var(--lantern) 0 3px, transparent 3px),
    linear-gradient(180deg, #FFFBF2, var(--paper-shade));
}

/* ---------- header ---------- */
header { display: flex; align-items: center; gap: 12px; padding-block: 22px 0; }
.home { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.mark {
  width: 30px; height: 42px; font-family: inherit;
  font-size: 13px; font-weight: 500; line-height: 1.05;
  writing-mode: vertical-rl; text-orientation: upright; padding-bottom: 3px;
}
.wordmark { font-family: var(--display); font-size: 22px; letter-spacing: .12em; }
.top-cta {
  margin-left: auto; padding: 9px 16px; border-radius: 10px; white-space: nowrap;
  background: linear-gradient(180deg, #FFDA6A, var(--gold) 55%, #EDB935);
  color: var(--indigo-deep); text-decoration: none;
  font-family: var(--display); font-size: 17px; letter-spacing: .1em;
  box-shadow: 0 4px 0 #A9791B, 0 8px 18px rgba(6,17,29,.45);
  position: relative; top: 0; transition: top .08s, box-shadow .08s, filter .15s;
}
.top-cta:hover { filter: brightness(1.05); }
.top-cta:active { top: 3px; box-shadow: 0 1px 0 #A9791B, 0 4px 10px rgba(6,17,29,.45); }

h1 {
  font-family: var(--display); font-weight: 400;
  font-size: clamp(44px, 8vw, 72px); line-height: .92; letter-spacing: .02em;
  margin: 34px 0 0;
}
.lede { font-size: clamp(17px, 2vw, 20px); color: var(--dusk); max-width: 40ch; margin: 12px 0 26px; }
.lede strong { color: var(--paper); font-weight: 500; }
.muted { color: var(--dusk); }

/* ---------- the game ---------- */
.game {
  max-width: 460px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
}

.hud { display: flex; gap: 10px; }
.stat {
  flex: none; min-width: 86px; padding: 9px 13px; border-radius: 13px;
  background: rgba(16,39,65,.7); box-shadow: inset 0 0 0 1px rgba(51,92,134,.45);
  display: flex; flex-direction: column; gap: 1px;
}
.stat.grow { flex: 1; }
.lbl {
  font-family: var(--display); letter-spacing: .14em; font-size: 12px;
  color: var(--dusk-deep); line-height: 1.3;
}
.val { font-family: var(--display); font-size: 27px; line-height: 1; letter-spacing: .02em; }
.val.mult { color: var(--gold); }
.val.best { color: var(--dusk); }
/* The multiplier is the one number that moves on its own, so it is the one
   that is allowed to announce itself. */
.val.mult.up { animation: bump .5s cubic-bezier(.2,1.5,.4,1); }
@keyframes bump { 40% { transform: scale(1.22); } }

.deckbar { display: flex; align-items: center; gap: 11px; font-size: 14px; }
.deckbar .track {
  flex: 1; height: 7px; border-radius: 4px; position: relative;
  background: rgba(6,17,29,.6); box-shadow: inset 0 0 0 1px rgba(51,92,134,.4);
  overflow: hidden;
}
.deckbar .fill { position: absolute; inset-block: 0; border-radius: 4px; transition: left .4s, width .4s, background .6s; }
.deckbar .range { font-family: var(--display); letter-spacing: .06em; font-size: 17px; color: var(--dusk); min-width: 54px; text-align: right; }

.board {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  padding: 12px; border-radius: 22px;
  background: rgba(6,17,29,.35); box-shadow: inset 0 0 0 1px rgba(51,92,134,.5);
}
.ladder {
  display: flex; flex-direction: column-reverse; gap: 7px;
  padding: 7px; border-radius: 13px; aspect-ratio: 1 / 2.9;
  background: var(--well);
  box-shadow: inset 0 3px 7px rgba(6,17,29,.85), inset 0 0 0 1px rgba(51,92,134,.35);
  font: inherit; color: inherit; border: 0; margin: 0; cursor: pointer; position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform .15s, box-shadow .2s, opacity .3s;
}
/* Playable with the card in hand. Goes out above the hint score, exactly as
   it does in the app: early on it teaches the rule, late on it reads the
   board for you. */
.ladder.ok { box-shadow: inset 0 3px 7px rgba(6,17,29,.85), inset 0 0 0 1.5px rgba(247,201,72,.5); }
.ladder.ok:hover { transform: translateY(-2px);
  box-shadow: inset 0 3px 7px rgba(6,17,29,.85), inset 0 0 0 2px rgba(247,201,72,.95), 0 0 20px rgba(247,201,72,.3); }
/* Still has room, but topped at 17 or over: nearly out of the game. */
.ladder.choked { box-shadow: inset 0 3px 7px rgba(6,17,29,.85), inset 0 0 0 1.5px rgba(226,80,58,.75), 0 0 16px rgba(226,80,58,.3); }
/* No sequence of remaining cards can finish it. Dimmed rather than marked:
   there is nothing to decide about a dead ladder. */
.ladder.dead { opacity: .45; }
/* A wild onto a 20 — the joker, the one card that rescues a dead ladder. */
.ladder.joker { box-shadow: inset 0 3px 7px rgba(6,17,29,.85), inset 0 0 0 2px var(--gold), 0 0 26px rgba(247,201,72,.5); opacity: 1; }
.ladder:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.rung { flex: 1; border-radius: 8px; background: rgba(6,17,29,.45); display: grid; }
.rung.filled { background: none; }
.rung > .plate { font-size: clamp(20px, 5.2vw, 30px); }

.deal {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 16px;
  background: linear-gradient(180deg, var(--panel-high), var(--panel));
}
.deal .current {
  flex: none; width: clamp(64px, 17vw, 80px); aspect-ratio: 1.3;
  font-size: clamp(28px, 7vw, 38px);
}
.upnext { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.deal .mini { width: 38px; aspect-ratio: 1.3; font-size: 19px; }

.burn {
  margin-left: auto; cursor: pointer; border: 0;
  padding: 10px 15px; border-radius: 13px;
  background: rgba(6,17,29,.5); box-shadow: inset 0 0 0 1.5px rgba(226,80,58,.6);
  color: var(--paper); font-family: var(--display); letter-spacing: .1em; font-size: 19px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: box-shadow .2s, background .2s, opacity .2s;
}
.burn:hover:not(:disabled) { background: rgba(226,80,58,.18); }
.burn:disabled { opacity: .4; cursor: default; }
.burn:focus-visible { outline: 2px solid var(--chochin); outline-offset: 3px; }
/* The only way out of a stuck board, so it says so rather than waiting to be
   noticed. */
.burn.urgent { box-shadow: inset 0 0 0 2px var(--chochin), 0 0 20px rgba(226,80,58,.5); background: rgba(226,80,58,.2); }
.pips { display: flex; gap: 4px; }
.pip { width: 7px; height: 7px; border-radius: 50%; background: var(--chochin); }
.pip.spent { background: rgba(255,255,255,.18); }
/* The milestone's sixth burn sits past the ceiling, so it is a different
   colour — it is a different thing. */
.pip.bonus { background: var(--gold); }

.hint { margin: 0; text-align: center; font-size: 15px; color: var(--dusk); min-height: 2.6em; }
.hint.alarm { color: var(--chochin); font-weight: 500; }
.hint.wildtip { color: var(--gold); }

.tools { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.ghost {
  cursor: pointer; border: 0; padding: 8px 15px; border-radius: 11px;
  background: transparent; box-shadow: inset 0 0 0 1.5px rgba(51,92,134,.9);
  color: var(--dusk); font-family: var(--display); letter-spacing: .1em; font-size: 16px;
  transition: color .2s, box-shadow .2s;
}
.ghost:hover { color: var(--paper); box-shadow: inset 0 0 0 1.5px var(--edge); }
.ghost:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.ghost.confirm { color: var(--chochin); box-shadow: inset 0 0 0 1.5px var(--chochin); }
.ghost.install { color: var(--gold); box-shadow: inset 0 0 0 1.5px rgba(247,201,72,.7); }

/* Points, where they were won. */
.pop {
  position: absolute; left: 50%; top: 16%; transform: translateX(-50%); pointer-events: none;
  font-family: var(--display); font-size: clamp(17px, 4vw, 23px); letter-spacing: .04em;
  white-space: nowrap; text-align: center; color: var(--gold);
  text-shadow: 0 2px 10px rgba(6,17,29,.9); z-index: 2;
}
.pop small { display: block; font-size: .64em; color: var(--paper); letter-spacing: .1em; }
.pop.perfect { color: #FFF0C0; }

/* ---------- the pitch under the game ---------- */
.pitch { padding-block: 56px 10px; margin-top: 46px; border-top: 1px solid rgba(247,201,72,.14); }
.kicker { font-family: var(--display); letter-spacing: .18em; color: var(--gold); font-size: 15px; margin: 0 0 8px; }
h2 { font-family: var(--display); font-weight: 400; letter-spacing: .04em; font-size: clamp(32px, 5vw, 48px); line-height: .98; margin: 0 0 16px; }
.pitch p { max-width: 62ch; }
.facts { list-style: none; margin: 22px 0 30px; padding: 0; display: grid; gap: 14px; max-width: 62ch; }
.facts li { padding-left: 22px; position: relative; color: var(--dusk); }
.facts li::before {
  content: ""; position: absolute; left: 0; top: .62em; width: 9px; height: 9px;
  border-radius: 2px; background: var(--gold);
}
.facts b { color: var(--paper); font-weight: 500; }
.soon {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 15px 22px; border-radius: 12px;
  background: linear-gradient(180deg, #FFDA6A, var(--gold) 55%, #EDB935);
  box-shadow: 0 5px 0 #A9791B, 0 12px 26px rgba(6,17,29,.5);
  color: var(--indigo-deep); font-family: var(--display); letter-spacing: .12em; font-size: 20px;
  text-decoration: none; position: relative; top: 0;
  transition: top .08s, box-shadow .08s, filter .15s;
}
.soon:hover { filter: brightness(1.05); }
.soon:active { top: 4px; box-shadow: 0 1px 0 #A9791B, 0 5px 12px rgba(6,17,29,.5); }
.soon small { font-family: var(--text); letter-spacing: 0; font-size: 14px; color: #6B4C0E; }
.beta-note { margin: 14px 0 0; font-size: 15px; color: var(--dusk); }
.beta-note a, .pitch a:not(.soon) { color: var(--gold); }

footer {
  padding-block: 34px calc(34px + env(safe-area-inset-bottom));
  margin-top: 40px; border-top: 1px solid rgba(247,201,72,.14);
  display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between;
  color: var(--dusk-deep); font-size: 15px;
}
footer a { color: var(--dusk); }
a:focus-visible { outline: 2px solid var(--paper); outline-offset: 4px; border-radius: 6px; }

/* ---------- end of run, and help ---------- */
/* An author `display` beats the hidden attribute's, so it has to be put back
   explicitly or the overlay never goes away. */
.overlay[hidden] { display: none; }
.overlay {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  padding: 20px; background: rgba(6,17,29,.78);
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.panel {
  width: min(420px, 100%); max-height: 86vh; overflow-y: auto;
  padding: 26px 24px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px; text-align: center;
  background: linear-gradient(180deg, var(--panel-high), var(--panel));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 24px 60px rgba(6,17,29,.7);
}
.panel .eyebrow { font-family: var(--display); letter-spacing: .18em; font-size: 14px; color: var(--gold); }
.panel h2 { font-size: clamp(32px, 7vw, 42px); margin: 6px 0 12px; }
.panel .final { font-family: var(--display); font-size: clamp(54px, 15vw, 76px); line-height: 1; margin: 0; }
.panel .newbest {
  display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 99px;
  background: var(--gold); color: var(--indigo-deep);
  font-family: var(--display); letter-spacing: .12em; font-size: 15px;
}
.panel .breakdown { margin: 14px 0 0; font-size: 16px; color: var(--dusk); }
.panel .rules { text-align: left; font-size: 16px; color: var(--dusk); line-height: 1.6; }
.panel .rules b { color: var(--paper); font-weight: 500; }
.panel .rules .star { color: var(--gold); }
.panel .btnrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 22px; }
.panel .primary {
  cursor: pointer; border: 0; padding: 13px 22px; border-radius: 12px;
  background: linear-gradient(180deg, #FFDA6A, var(--gold) 55%, #EDB935);
  box-shadow: 0 4px 0 #A9791B, 0 10px 20px rgba(6,17,29,.45);
  color: var(--indigo-deep); font-family: var(--display); letter-spacing: .12em; font-size: 19px;
  position: relative; top: 0; transition: top .08s, box-shadow .08s, filter .15s;
}
.panel .primary:hover { filter: brightness(1.05); }
.panel .primary:active { top: 3px; box-shadow: 0 1px 0 #A9791B, 0 4px 10px rgba(6,17,29,.45); }
.panel .primary:focus-visible, .panel .ghost:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.panel .getapp { display: block; margin-top: 18px; color: var(--gold); font-size: 15px; }

/* ---------- installed to a home screen ---------- */
/* Then it is the game and nothing else: no site header, no sales pitch, no
   footer, and the board takes the room they were using. */
@media (display-mode: standalone), (display-mode: minimal-ui) {
  .chrome { display: none; }
  body { padding-top: env(safe-area-inset-top); }
  .game { padding-top: 14px; }
  main { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
}

@media (max-width: 480px) {
  /* The heading and the line under it earn their place on a wide screen and
     cost a board's worth of height on a narrow one, so on a phone they are
     set at the size they need rather than the size they look best at. */
  h1 { font-size: 38px; margin-top: 22px; }
  .lede { font-size: 16px; margin: 10px 0 18px; }
}
@media (max-width: 420px) {
  .top-cta { font-size: 15px; padding: 8px 12px; }
  .wordmark { font-size: 20px; }
  .stat { min-width: 76px; padding: 8px 11px; }
  .val { font-size: 24px; }
}

/* Short screens: the board and the card in hand are the two things that have
   to be on screen together, so everything around them gives way first — and
   it has to give way early, because a phone's address bar and toolbar take
   something like 110px that none of these heights can see. */
@media (max-height: 740px) {
  h1 { font-size: clamp(34px, 6vw, 48px); margin-top: 22px; }
  .lede { margin-bottom: 18px; }
  .game { gap: 9px; }
}
@media (max-height: 700px) {
  /* The sales line goes: the heading above and the section below both still
     say it, and the dealt card is worth more than either. */
  .lede { display: none; }
  h1 { margin: 16px 0 14px; font-size: clamp(30px, 5.4vw, 40px); }
  header { padding-block: 14px 0; }
  .board { padding: 9px; gap: 8px; }
  .hud .stat { padding: 7px 11px; }
  .val { font-size: 23px; }
}

@media (prefers-reduced-motion: no-preference) {
  .ladder .plate.landed { animation: drop .42s cubic-bezier(.2,1.4,.5,1) both; }
  @keyframes drop { from { transform: translateY(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
  .ladder.clearing .plate { animation: clear .34s ease-in forwards; }
  @keyframes clear { 40% { transform: scale(1.06); } to { transform: scale(.88); opacity: 0; } }
  .ladder.refused { animation: shake .4s; }
  @keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
  .deal .current.dealt { animation: deal-in .3s cubic-bezier(.2,.9,.3,1) both; }
  @keyframes deal-in { from { opacity: 0; transform: translateY(-10px) scale(.95); } to { opacity: 1; transform: none; } }
  .deal .current.burned { animation: burn-out .3s ease-in both; }
  @keyframes burn-out { to { opacity: 0; transform: translateY(12px) rotate(7deg) scale(.9); } }
  .pop { animation: pop 1.05s ease-out both; }
  @keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } 22% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -26px); } }
  .overlay { animation: fade .2s ease-out; }
  @keyframes fade { from { opacity: 0; } }
}
