/* Layout: a station wall. Black wayfinding sign on top, a mosaic band, then a tiled wall
   holding the 3×3 grid. Route bullets carry all the color. */
:root {
  --wall: #f2f3ef;
  --tile: #fbfbf8;
  --tile-edge: #d3d7cf;
  --ink: #151615;
  --muted: #61665f;
  --sign: #141414;
  --sign-fg: #ffffff;
  --ok: #17763a;
  --bad: #c0261c;
  --shadow: rgba(20, 22, 20, .12);
  --btn: #141414;
  --plate-edge: #141414;
  --btn-fg: #ffffff;
  --veil: rgba(20, 22, 20, .45);
  --grout-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%23fdfdfb'/%3E%3Cstop offset='1' stop-color='%23eceee8'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='60' height='30' fill='%23d9dcd5'/%3E%3Crect x='1' y='1' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='-29' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='31' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='3' y='2' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.9%29'/%3E%3Crect x='-27' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.9%29'/%3E%3Crect x='33' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.9%29'/%3E%3C/svg%3E");
  --mosaic-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='21'%3E%3Crect width='28' height='21' fill='%23ece6d4'/%3E%3Cg fill='%237b2d2a'%3E%3Crect x='.5' y='.5' width='6' height='6'/%3E%3Crect x='14.5' y='.5' width='6' height='6'/%3E%3Crect x='7.5' y='14.5' width='6' height='6'/%3E%3Crect x='21.5' y='14.5' width='6' height='6'/%3E%3C/g%3E%3Cg fill='%23c49a3c'%3E%3Crect x='7.5' y='.5' width='6' height='6'/%3E%3Crect x='21.5' y='.5' width='6' height='6'/%3E%3Crect x='.5' y='14.5' width='6' height='6'/%3E%3Crect x='14.5' y='14.5' width='6' height='6'/%3E%3C/g%3E%3Cg fill='%231e5a55'%3E%3Crect x='.5' y='7.5' width='6' height='6'/%3E%3Crect x='7.5' y='7.5' width='6' height='6'/%3E%3Crect x='21.5' y='7.5' width='6' height='6'/%3E%3C/g%3E%3C/svg%3E");

  /* station wall: trim color changes daily (set by game.js), plaques are cream mosaic */
  --trim: #1e5a55;
  --cream: #efe8d4;
  --plaque-grout: rgba(0, 0, 0, .14);

  /* MTA route colors */
  --l-123: #ee352e;
  --l-456: #00933c;
  --l-7: #b933ad;
  --l-ace: #0039a6;
  --l-bdfm: #ff6319;
  --l-g: #6cbe45;
  --l-jz: #996633;
  --l-l: #a7a9ac;
  --l-nqrw: #fccc0a;
  --l-s: #808183;

  /* rarity levels (same in both themes: each pop-up paints its own card) */
  --t-com: #6d7073;
  --t-unc: #007f34;
  --t-rare: #0039a6;
  --t-epic: #8a2be2;
  --t-epic-night: #160d2e;
  --t-leg: #e8b923;
  --t-leg-deep: #8a6408;
  --t-leg-night: #1c1505;

  --f-sign: "Helvetica Neue", Helvetica, Arimo, Arial, sans-serif;
  --f-body: "Helvetica Neue", Helvetica, Arimo, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --wall: #181a19; --tile: #222524; --tile-edge: #353937; --ink: #ecede8; --muted: #9da29b;
    --sign: #0a0a0a; --ok: #4cc072; --bad: #ff6a5e; --shadow: rgba(0, 0, 0, .4); --btn: #ecede8; --btn-fg: #111211; --plate-edge: #4a4f4c; --veil: rgba(0, 0, 0, .6); --cream: #cfc7b3; --plaque-grout: rgba(0, 0, 0, .3);
    --grout-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%232a2e2c'/%3E%3Cstop offset='1' stop-color='%23202322'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='60' height='30' fill='%23121413'/%3E%3Crect x='1' y='1' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='-29' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='31' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='3' y='2' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3Crect x='-27' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3Crect x='33' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --wall: #181a19; --tile: #222524; --tile-edge: #353937; --ink: #ecede8; --muted: #9da29b;
  --sign: #0a0a0a; --ok: #4cc072; --bad: #ff6a5e; --shadow: rgba(0, 0, 0, .4); --btn: #ecede8; --btn-fg: #111211; --plate-edge: #4a4f4c; --veil: rgba(0, 0, 0, .6); --cream: #cfc7b3; --plaque-grout: rgba(0, 0, 0, .3);
  --grout-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='30'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='0' y2='1'%3E%3Cstop offset='0' stop-color='%232a2e2c'/%3E%3Cstop offset='1' stop-color='%23202322'/%3E%3C/linearGradient%3E%3C/defs%3E%3Crect width='60' height='30' fill='%23121413'/%3E%3Crect x='1' y='1' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='-29' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='31' y='16' width='58' height='13' rx='2' fill='url%28%23g%29'/%3E%3Crect x='3' y='2' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3Crect x='-27' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3Crect x='33' y='17' width='54' height='1.5' rx='.75' fill='rgba%28255%2C255%2C255%2C.06%29'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--wall) var(--grout-img);
  color: var(--ink);
  font: 15px/1.45 var(--f-body);
  display: flex;
  flex-direction: column;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--sign); }
button { font: inherit; color: inherit; }
button, a, .cell { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
:focus-visible { outline: 3px solid var(--l-ace); outline-offset: 2px; }

/* ---------- sign header ---------- */
.sign {
  background: var(--sign);
  color: var(--sign-fg);
  position: relative;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.sign::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 2px; background: var(--sign-fg); opacity: .9; }
.sign-inner {
  max-width: 560px; margin: 0 auto; padding-block: 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; min-width: 0; }
.brand-name { font: 700 28px/1 var(--f-sign); letter-spacing: -.01em; }
.brand-bullets { display: flex; gap: 4px; }
.brand-bullets i {
  font-style: normal; width: 22px; height: 22px; border-radius: 50%;
  background: var(--c); color: #fff; font: 700 13px/22px var(--f-sign); text-align: center;
}
.sign-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--sign-fg);
  background: transparent; color: var(--sign-fg); font: 700 17px/1 var(--f-sign); cursor: pointer; flex: none;
}
.sign-btn:hover { background: var(--sign-fg); color: var(--sign); }
.sign-btn svg { width: 18px; height: 18px; display: block; margin: auto; }
.mosaic { height: 21px; background: var(--mosaic-img); border-bottom: 3px solid var(--sign); }
/* the station's trim stripe: two rows of small colored tiles */
.trim {
  height: 14px;
  background:
    linear-gradient(var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    linear-gradient(90deg, var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    var(--trim);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15);
}

/* ---------- mosaic name plaque at the bottom of the page ---------- */
.plaque {
  padding: 10px;
  background:
    linear-gradient(var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    linear-gradient(90deg, var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    repeating-conic-gradient(var(--trim) 0 25%, var(--cream) 0 50%) 0 0 / 14px 14px;
  border-radius: 3px;
  box-shadow: 0 2px 8px var(--shadow);
}
.plaque-field {
  background:
    linear-gradient(var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    linear-gradient(90deg, var(--plaque-grout) 1px, transparent 1px) 0 0 / 7px 7px,
    var(--cream);
  border: 4px solid var(--trim);
  padding: 14px 16px 12px; text-align: center;
  display: flex; flex-direction: column; gap: 4px;
}
.plaque-name { font: 700 24px/1 var(--f-sign); letter-spacing: .06em; text-transform: uppercase; color: var(--trim); }
.plaque-sub { font: 700 11px/1 var(--f-sign); letter-spacing: .18em; text-transform: uppercase; color: #3b3a35; }
.plaque-bottom { width: 100%; max-width: 360px; margin: 4px auto 0; }

/* ---------- main ---------- */
.wrap {
  width: 100%; max-width: 560px; margin: 0 auto; flex: 1;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 28px;
  display: flex; flex-direction: column; gap: 16px;
}
.meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.day { font: 700 13px/1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.score-chip {
  background: var(--sign); color: var(--sign-fg); border-radius: 4px; padding: 6px 10px;
  font: 400 13px/1 var(--f-sign); letter-spacing: .02em;
}
.score-chip b { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: 4px; }
.score-chip .of { opacity: .6; }

/* ---------- route bullets ---------- */
.bullet {
  --size: 22px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--size); height: var(--size); border-radius: 50%;
  background: var(--c); color: #fff;
  font: 700 calc(var(--size) * .62)/1 var(--f-sign);
}
.bullet.dark { color: #111; }
.bullet.sm { --size: 18px; vertical-align: -3px; }
.bullet.xs { --size: 15px; }
.bullet.lg { --size: 48px; box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.bullet.md { --size: 26px; }
.hd-bullets { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; }
.hd-cap.faint { font-weight: 400; letter-spacing: .04em; text-transform: none; }
.hd-bullets.many { max-width: 92px; gap: 2px; }
.sol-bullets { display: flex; flex-wrap: wrap; justify-content: center; gap: 1px; }

/* ---------- board ---------- */
.board {
  display: grid;
  grid-template-columns: minmax(64px, .82fr) repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.hd {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  text-align: center; padding: 6px 2px; min-width: 0;
}
.hd-cap { font: 700 10px/1.1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hd-plate {
  background: var(--sign); color: var(--sign-fg); border-radius: 4px;
  padding: 7px 6px 6px; width: 100%; max-width: 120px;
  display: flex; flex-direction: column; gap: 2px;
}
.hd-main { font: 700 13px/1.1 var(--f-sign); text-wrap: balance; overflow-wrap: break-word; hyphens: auto; }
.hd-sub { font: 400 10px/1.2 var(--f-sign); opacity: .75; text-wrap: balance; }
.hd.row { justify-content: center; }
.corner { display: grid; place-items: center; }
.corner span { font: 700 10px/1.2 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); text-align: center; }

.cell {
  aspect-ratio: 1; min-width: 0; width: 100%;
  border: 1px solid var(--tile-edge); border-radius: 6px;
  background: linear-gradient(160deg, var(--tile) 0%, var(--tile) 55%, var(--wall) 100%);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 1px 2px var(--shadow);
  cursor: pointer; position: relative; padding: 0; overflow: hidden;
  display: grid; place-items: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
@media (hover: hover) {
  .cell:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 10px var(--shadow); }
}
.cell:disabled { cursor: default; }
.cell .plus { font: 300 28px/1 var(--f-sign); color: var(--tile-edge); }
.cell.filled { background: var(--sign); border-color: var(--plate-edge); color: var(--sign-fg); }
.plate { display: flex; flex-direction: column; justify-content: space-between; height: 100%; width: 100%; padding: 8px 7px 7px; text-align: left; gap: 4px; }
.plate::before { content: ""; display: block; height: 1px; background: var(--sign-fg); opacity: .6; flex: none; }
.plate-name {
  font: 700 13px/1.15 var(--f-sign); overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.plate-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; }
.plate-routes { display: flex; flex-wrap: nowrap; align-items: center; gap: 2px; min-width: 0; overflow: hidden; }
.more { font: 700 10px/1 var(--f-sign); margin-left: 2px; opacity: .85; }
/* rarity badges */
.pts {
  display: inline-block; flex: none; min-width: 26px; text-align: center;
  font: 700 11px/1 var(--f-sign); font-variant-numeric: tabular-nums;
  padding: 3px 4px; border-radius: 3px; color: #fff; background: var(--l-l);
}
.pts.com { background: var(--t-com); }
.pts.unc { background: var(--t-unc); }
.pts.rare { background: var(--t-rare); }
.pts.epic { background: var(--t-epic); }
.pts.leg { background: linear-gradient(135deg, #f7dc6f, var(--t-leg) 50%, #c9971a); color: #2b1d00; }

.tier-list { display: grid; gap: 6px; }
.tier-list div { display: grid; grid-template-columns: 40px 90px 1fr; align-items: center; gap: 8px; font-size: 14px; }
.tier-list span:last-child { color: var(--muted); }

/* ---------- reward pop-up ---------- */
.reward {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center;
  padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px));
  background: rgba(0, 0, 0, .25); cursor: pointer;
}
.reward-card {
  position: relative; overflow: hidden; width: min(320px, 100%);
  border-radius: 14px; padding: 22px 20px 20px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.reward-card > *:not(.reward-fx) { position: relative; z-index: 1; }
.reward-fx { position: absolute; inset: 0; pointer-events: none; }
.reward-badge { width: 74px; height: 74px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 4px; }
.reward-badge span { font: 700 26px/1 var(--f-sign); }
.reward-tier { font: 700 12px/1 var(--f-sign); letter-spacing: .12em; text-transform: uppercase; }
.reward-pts { font: 700 40px/1 var(--f-sign); font-variant-numeric: tabular-nums; }
.reward-station { font: 700 17px/1.2 var(--f-sign); }
.reward-line { font: 400 13px/1.35 var(--f-sign); opacity: .85; max-width: 26ch; }

/* Common · Rush Hour: flat and grey, no fuss */
.r-com { background: #ecedeb; color: #55585b; animation: r-fade .25s ease-out both; }
.r-com .reward-badge { background: var(--t-com); color: #fff; width: 60px; height: 60px; }
.r-com .reward-pts { font-size: 30px; }

/* Uncommon · Local: a green bullet that hops in */
.r-unc { background: #fff; color: #10351f; border-top: 6px solid var(--t-unc); animation: r-hop .45s cubic-bezier(.3, 1.5, .6, 1) both; }
.r-unc .reward-badge { background: var(--t-unc); color: #fff; animation: r-bob 1s ease-in-out .4s 2; }

/* Rare · Express: the express diamond, arriving fast with speed lines */
.r-rare { background: #0b2a6f; color: #fff; animation: r-express .5s cubic-bezier(.2, .9, .2, 1) both; }
.r-rare .reward-fx { right: -40px; background: repeating-linear-gradient(180deg, transparent 0 14px, rgba(255, 255, 255, .14) 14px 16px, transparent 16px 31px); animation: r-speed .6s linear infinite; }
.r-rare .reward-badge { background: var(--t-rare); border-radius: 8px; transform: rotate(45deg); width: 64px; height: 64px; margin: 6px 0 10px; box-shadow: 0 0 0 3px #fff; }
.r-rare .reward-badge span { transform: rotate(-45deg); }

/* Epic · Night Owl: a late-night car under the stars */
.r-epic { background: radial-gradient(circle at 50% 0%, #3b1f73, var(--t-epic-night) 70%); color: #f1e9ff; animation: r-rise .5s ease-out both; }
.r-epic .reward-badge { background: var(--t-epic); color: #fff; box-shadow: 0 0 0 0 rgba(186, 120, 255, .7); animation: r-glow 1.2s ease-out .2s 2; }
.r-epic .reward-fx i { position: absolute; left: var(--x); top: var(--y); width: 3px; height: 3px; border-radius: 50%; background: #fff; opacity: 0; animation: r-twinkle 1.4s ease-in-out var(--d) infinite; }
.r-epic .reward-tier { color: #d9b8ff; }

/* Legendary · Golden Token: a spinning subway token, sparks and a shine */
.r-leg { background: radial-gradient(circle at 50% 30%, #4a3608, var(--t-leg-night) 75%); color: #fff6d8; animation: r-slam .55s cubic-bezier(.2, 1.4, .4, 1) both; border: 2px solid var(--t-leg); }
.r-leg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 236, 160, .35) 45%, transparent 60%); transform: translateX(-100%); animation: r-shine 1.2s ease-in-out .35s 2; pointer-events: none; }
.r-leg .reward-badge {
  width: 84px; height: 84px; color: #2b1d00;
  background: radial-gradient(circle at 35% 30%, #fff1b0, var(--t-leg) 45%, var(--t-leg-deep));
  box-shadow: inset 0 0 0 5px rgba(138, 100, 8, .55), inset 0 0 0 9px rgba(255, 241, 176, .5), 0 0 28px rgba(232, 185, 35, .6);
  animation: r-spin 1.3s cubic-bezier(.2, .8, .3, 1) both;
}
.r-leg .reward-tier { color: var(--t-leg); }
.r-leg .reward-pts { color: var(--t-leg); text-shadow: 0 0 18px rgba(232, 185, 35, .6); }
.r-leg .reward-fx i { position: absolute; left: 50%; top: 68px; width: 6px; height: 6px; margin: -3px; border-radius: 1px; background: var(--t-leg); transform: rotate(var(--a)) translateY(0); opacity: 0; animation: r-burst .9s ease-out calc(.25s + var(--d)) both; }

@keyframes r-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes r-hop { from { opacity: 0; transform: translateY(30px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes r-bob { 50% { transform: translateY(-6px); } }
@keyframes r-express { from { opacity: 0; transform: translateX(-120%) skewX(-18deg); } 70% { transform: translateX(4%) skewX(4deg); } to { opacity: 1; transform: none; } }
@keyframes r-speed { to { background-position: -0 0; transform: translateX(-30px); } }
@keyframes r-rise { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes r-glow { to { box-shadow: 0 0 0 18px rgba(186, 120, 255, 0); } }
@keyframes r-twinkle { 0%, 100% { opacity: 0; transform: scale(.6); } 50% { opacity: 1; transform: scale(1.3); } }
@keyframes r-slam { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: none; } }
@keyframes r-shine { to { transform: translateX(100%); } }
@keyframes r-spin { from { transform: rotateY(0) scale(.4); } to { transform: rotateY(1080deg) scale(1); } }
@keyframes r-burst { 0% { opacity: 1; transform: rotate(var(--a)) translateY(0); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-120px); } }

/* ---------- ranking & solution ---------- */
.rank-card, .sol-card { background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 6px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.rank-card h3, .sol-card h3 { margin: 0; font: 700 12px/1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.rank-big { font: 700 22px/1.15 var(--f-sign); display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.rank-big span { font-size: 13px; font-weight: 700; background: var(--sign); color: var(--sign-fg); padding: 3px 7px; border-radius: 3px; }
.rank-note { margin: 0; font-size: 13px; color: var(--muted); }
.rank-bars { display: flex; align-items: flex-end; gap: 3px; height: 56px; border-bottom: 1px solid var(--tile-edge); }
.rank-bars i { flex: 1; background: var(--tile-edge); border-radius: 2px 2px 0 0; }
.rank-bars i.me { background: var(--l-bdfm); }
.rank-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.sol-grid { display: grid; grid-template-columns: minmax(64px, .8fr) repeat(3, minmax(0, 1fr)); gap: 4px; align-items: stretch; }
.sol-hd { font: 700 10.5px/1.2 var(--f-sign); text-align: center; display: grid; place-items: center; padding: 2px; color: var(--ink); min-width: 0; overflow-wrap: break-word; }
.sol-cell {
  min-width: 0; border: 1px solid var(--tile-edge); background: var(--wall); border-radius: 4px; padding: 7px 6px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px; text-align: left;
}
.sol-cell.got { border-color: var(--t-leg); box-shadow: inset 0 0 0 1px var(--t-leg); }
.sol-best { font: 700 12px/1.2 var(--f-sign); overflow-wrap: break-word; hyphens: auto; }
.sol-more { font: 400 11px/1.2 var(--f-sign); color: var(--muted); }
.sol-cell.got .sol-more { color: var(--ink); font-weight: 700; }
.cell.missed { background: var(--tile); border-style: dashed; }
.missed-txt { font: 400 11px/1.3 var(--f-sign); color: var(--muted); text-align: center; padding: 6px; }
.missed-txt b { display: block; font-size: 20px; color: var(--ink); font-weight: 700; }
.cell.shake { animation: shake .4s; border-color: var(--bad); }
.cell.pop { animation: pop .35s ease-out; }
@keyframes shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }
@keyframes pop { from { transform: scale(.88); } to { transform: scale(1); } }

/* ---------- under the board ---------- */
.under { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.fare {
  display: flex; align-items: center; gap: 10px;
  background: var(--l-nqrw); color: #111; border-radius: 6px; padding: 8px 12px 8px 14px;
  box-shadow: 0 1px 2px var(--shadow);
  position: relative;
}
.fare::after { content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 6px; background: repeating-linear-gradient(#111 0 3px, transparent 3px 6px); border-radius: 0 6px 6px 0; opacity: .7; }
.fare-lbl { font: 700 11px/1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; }
.fare-lbl small { display: block; font-weight: 400; letter-spacing: .02em; text-transform: none; margin-top: 3px; opacity: .75; }
.fare-num { font: 700 24px/1 var(--f-sign); font-variant-numeric: tabular-nums; margin-right: 8px; }
/* wrong guesses in a square, and a square closed after three */
.cell .tries { position: absolute; bottom: 7px; left: 0; right: 0; display: flex; justify-content: center; gap: 4px; }
.cell .tries i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--tile-edge); }
.cell .tries i.on { background: var(--bad); border-color: var(--bad); }
.cell.closed { background: repeating-linear-gradient(-45deg, var(--tile) 0 10px, var(--wall) 10px 20px); border-color: var(--bad); }
.closed-txt { font: 400 10.5px/1.3 var(--f-sign); color: var(--muted); text-align: center; padding: 6px; }
.closed-txt b { display: block; font-size: 13px; color: var(--bad); text-transform: uppercase; letter-spacing: .04em; }

.btn {
  border: 2px solid var(--btn); background: var(--btn); color: var(--btn-fg);
  border-radius: 999px; padding: 10px 18px; font: 700 14px/1 var(--f-sign); cursor: pointer;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--wall); }
.btn.primary:hover { filter: brightness(1.25); }
.btn.wide { width: 100%; padding-block: 14px; }

/* ---------- end of trip ---------- */
.end { display: flex; flex-direction: column; gap: 14px; }
.arrive { background: var(--sign); color: var(--sign-fg); border-radius: 6px; padding: 16px; position: relative; display: flex; flex-direction: column; gap: 10px; }
.arrive::before { content: ""; position: absolute; left: 0; right: 0; top: 6px; height: 1px; background: var(--sign-fg); opacity: .7; }
.arrive h2 { margin: 6px 0 0; font: 700 22px/1.1 var(--f-sign); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { border-left: 2px solid rgba(255,255,255,.35); padding-left: 10px; }
.stat b { display: block; font: 700 24px/1.1 var(--f-sign); font-variant-numeric: tabular-nums; }
.stat span { font: 400 11px/1.2 var(--f-sign); opacity: .75; }
.arrive p { margin: 0; font-size: 13px; opacity: .85; }
.end-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.end-actions .btn { flex: 1; }
.arrive .btn { background: var(--sign-fg); color: var(--sign); border-color: var(--sign-fg); }
.map-card { background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.map-card h3 { margin: 0; font: 700 12px/1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.map-card svg { width: 100%; height: auto; max-height: 460px; display: block; }
.map-dot { fill: var(--muted); opacity: .35; }
.map-pick { stroke: var(--tile); stroke-width: 2; }
.map-num { font: 700 11px var(--f-sign); fill: #fff; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.map-boro { font: 700 10px var(--f-sign); fill: var(--muted); letter-spacing: .1em; text-transform: uppercase; opacity: .7; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 20; background: var(--veil); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--wall); color: var(--ink); width: 100%; max-width: 480px;
  border-radius: 14px 14px 0 0; padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  max-height: 88vh; overflow-y: auto; position: relative;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .2s ease-out;
}
@media (min-width: 600px) {
  .modal { align-items: center; }
  .sheet { border-radius: 10px; padding: 22px; }
}
@keyframes rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet.pick { min-height: min(520px, 80vh); }
.close { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: transparent; font-size: 24px; line-height: 1; cursor: pointer; color: var(--muted); }
.sheet h2 { margin: 0; font: 700 22px/1.15 var(--f-sign); }
.sheet p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.help-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }

.pick-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-right: 36px; font: 700 14px/1.2 var(--f-sign); }
.pick-head .x { color: var(--muted); font-weight: 400; }
.tag { display: inline-flex; align-items: center; gap: 6px; background: var(--sign); color: var(--sign-fg); border-radius: 4px; padding: 5px 8px; font: 700 13px/1 var(--f-sign); }
.tag .bullet { --size: 18px; }
.search input {
  width: 100%; font: 400 17px/1.2 var(--f-body); color: var(--ink);
  background: var(--tile); border: 2px solid var(--sign); border-radius: 6px; padding: 12px 12px;
}
.results, .answers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.results li button {
  width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--tile-edge); background: transparent;
  padding: 10px 4px; cursor: pointer; display: flex; flex-direction: column; gap: 3px;
}
.results li button:hover, .results li button[aria-selected="true"] { background: var(--tile); }
.results li button:disabled { opacity: .4; cursor: not-allowed; }
.r-name { font: 700 15px/1.2 var(--f-sign); }
.r-sub { font: 400 12px/1.3 var(--f-sign); color: var(--muted); }
.results .empty { color: var(--muted); font-size: 13px; padding: 10px 4px; }
.answers li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--tile-edge); }
.answers li.mine { background: var(--tile); }
.answers .a-name { font: 700 14px/1.2 var(--f-sign); }
.answers .a-routes { display: flex; gap: 2px; flex-wrap: wrap; grid-column: 1; }
.answers .a-pts { grid-row: 1 / span 2; grid-column: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.answers .a-pts .pts { font-size: 13px; min-width: 32px; }
.answers .a-tier { font: 400 11px/1 var(--f-sign); color: var(--muted); }
.answers .you { font: 700 10px/1 var(--f-sign); letter-spacing: .08em; text-transform: uppercase; color: var(--ok); margin-left: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--sign); color: var(--sign-fg); padding: 10px 16px; border-radius: 6px;
  font: 700 14px/1.2 var(--f-sign); transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }

.foot {
  text-align: center; color: var(--muted); font-size: 11px;
  padding-block: 0 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.foot a { color: inherit; }

/* Phones: the typing screen fills the screen from the top, so the search box and first results
   stay above the on-screen keyboard. */
@media (max-width: 599px) {
  #modal-pick { align-items: stretch; }
  #modal-pick .sheet {
    max-width: none; max-height: none; min-height: 0; height: 100%; border-radius: 0;
    padding-top: calc(14px + env(safe-area-inset-top, 0px)); animation: r-fade .15s ease-out both;
  }
  #modal-pick .results { overflow-y: auto; }
  .sheet { max-height: 92vh; max-height: 92dvh; }
}

@media (max-width: 400px) {
  .brand-name { font-size: 24px; }
  .brand-bullets i { width: 18px; height: 18px; font-size: 11px; line-height: 18px; }
  .bullet.lg { --size: 40px; }
  .plate-name { font-size: 11.5px; }
  .hd-main { font-size: 12px; }
  .plate { padding: 6px 5px 5px; }
  .hd-plate { padding: 6px 4px 5px; }
  .end-actions .btn { padding-inline: 10px; }
}
@media (max-width: 360px) {
  .brand-bullets { display: none; }
  .hd-main { font-size: 10.5px; }
  .hd-plate { padding: 6px 3px 5px; }
  .hd-sub { font-size: 9.5px; }
  .plate-name { font-size: 11px; }
  .bullet.lg { --size: 36px; }
  .bullet.md { --size: 22px; }
  .board { gap: 4px; }
  .sol-best { font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- share sheet ---------- */
.share-text {
  width: 100%; resize: none; font: 400 14px/1.4 var(--f-body); color: var(--ink);
  background: var(--tile); border: 1px solid var(--tile-edge); border-radius: 6px; padding: 10px 12px;
}
.share-apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.app-btn {
  display: flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px;
  border: 2px solid var(--ink); border-radius: 999px; color: var(--ink); text-decoration: none;
  font: 700 14px/1 var(--f-sign);
}
.app-btn:hover { background: var(--ink); color: var(--wall); }
.share-img-wrap { display: grid; grid-template-columns: 120px 1fr; gap: 12px; align-items: center; }
.share-img-wrap img { width: 120px; aspect-ratio: 4 / 5; max-width: 100%; border-radius: 6px; border: 1px solid var(--tile-edge); background: var(--tile); }
.share-img-side { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-width: 0; font-size: 13px; }
.share-img-side p { margin: 0; color: var(--muted); }
.share-img-side b { color: var(--ink); }
