/* Diabetes Swipe: a glucose meter crossed with bedside flashcards. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-opsz-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 300 900;
  font-display: swap;
  src: url("../fonts/figtree-latin-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Kufi Arabic";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/noto-kufi-arabic-arabic-wght-normal.woff2") format("woff2");
}
@font-face {
  font-family: "Share Tech Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/share-tech-mono-latin-400-normal.woff2") format("woff2");
}

:root {
  --bg: #F0F4F2;
  --surface: #FFFFFF;
  --ink: #14232B;
  --muted: #55666F;
  --line: #D6E0E2;
  --accent: #0B6E73;
  --hero: #0B6E73;
  --hero-deep: #084F54;
  --left: #C4371F;
  --right: #0B7C5B;
  --left-soft: #FBE7E3;
  --right-soft: #DFF3EC;
  --lcd-bg: #C7D6C1;
  --lcd-ink: #1C2A1C;
  --on-photo: #FFFFFF;
  --scrim: rgba(8, 16, 20, .82);
  --shadow: 0 2px 4px rgba(20,35,43,.08), 0 16px 40px rgba(20,35,43,.16);
  --shadow-sm: 0 1px 2px rgba(20,35,43,.08), 0 6px 16px rgba(20,35,43,.10);
  --tint-l: 92%;
  --tint-s: 60%;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --spring: cubic-bezier(.2, 1.3, .4, 1);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "Share Tech Mono", "SF Mono", ui-monospace, Menlo, monospace;
  --arabic: "Noto Kufi Arabic", "Geeza Pro", "Tahoma", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0C1519; --surface: #15232A; --ink: #E4EDF1; --muted: #9DAEB7; --line: #2A3D47;
    --accent: #45BDB4; --hero: #0E4F54; --hero-deep: #0A383C;
    --left: #F0705F; --right: #3FC79C; --left-soft: #3A1F1B; --right-soft: #15352B;
    --lcd-bg: #1B2A1F; --lcd-ink: #B6E3A3; --tint-l: 18%; --tint-s: 32%;
    --shadow: 0 2px 4px rgba(0,0,0,.3), 0 16px 40px rgba(0,0,0,.45);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 6px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0C1519; --surface: #15232A; --ink: #E4EDF1; --muted: #9DAEB7; --line: #2A3D47;
  --accent: #45BDB4; --hero: #0E4F54; --hero-deep: #0A383C;
  --left: #F0705F; --right: #3FC79C; --left-soft: #3A1F1B; --right-soft: #15352B;
  --lcd-bg: #1B2A1F; --lcd-ink: #B6E3A3; --tint-l: 18%; --tint-s: 32%;
  --shadow: 0 2px 4px rgba(0,0,0,.3), 0 16px 40px rgba(0,0,0,.45);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3), 0 6px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
html { scrollbar-color: var(--line) transparent; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg); color: var(--ink);
  font-family: var(--body); font-size: 16px; line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent); color: var(--surface); }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
svg.i { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.app {
  min-height: 100%;
  max-width: 920px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-top: max(16px, env(safe-area-inset-top, 0px));
  padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column;
}
.screen { display: flex; flex-direction: column; gap: 20px; flex: 1; animation: screen-in .3s var(--ease-out); }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

h1, h2, h3 { font-family: var(--display); margin: 0; text-wrap: balance; }
h1 { font-size: clamp(40px, 7.4vw, 68px); font-weight: 800; line-height: .98; letter-spacing: -.025em; }
h2 { font-size: 22px; font-weight: 800; line-height: 1.15; }
h3 { font-size: 15px; font-weight: 600; }
.lede { margin: 0; color: var(--muted); max-width: 56ch; font-size: 17px; }

/* ---------- Home ---------- */
.hero {
  position: relative; overflow: hidden;
  display: grid; grid-template-columns: 1fr auto;
  grid-template-areas: "title demo" "lede demo" "rules demo";
  grid-template-rows: auto auto 1fr;
  gap: 14px clamp(20px, 5vw, 48px);
  padding: clamp(22px, 4.5vw, 40px);
  border-radius: 24px;
  background: linear-gradient(150deg, var(--hero), var(--hero-deep));
  color: #fff;
}
/* The demo card swipes behind the words, so the title stays readable */
.hero h1, .hero .lede, .rules { position: relative; z-index: 1; }
.hero h1 { grid-area: title; }
.hero .lede { grid-area: lede; color: rgba(255,255,255,.9); }
.rules { grid-area: rules; align-self: end; display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 0; padding: 0; list-style: none; }
.rules li { font-family: var(--mono); font-size: 14px; padding: 4px 10px; border-radius: 6px; background: #C7D6C1; color: #1C2A1C; box-shadow: inset 0 1px 3px rgba(0,0,0,.18); }

.demo { grid-area: demo; position: relative; align-self: center; width: clamp(150px, 23vw, 200px); aspect-ratio: .74; margin-bottom: 16px; pointer-events: none; }
.demo .fcard { border-radius: 16px; cursor: default; box-shadow: 0 10px 24px rgba(4,30,33,.35); touch-action: auto; }
.demo .fcard.d1 { transform: translateY(8px) scale(.94); }
.demo .fcard.d2 { transform: translateY(16px) scale(.88); }
.demo .fcard.incoming { transform: translateY(26px) scale(.82); }
.demo .fcard .info { padding: 34px 12px 12px; gap: 0; }
.demo .fcard .chip, .demo .fcard .sub { display: none; }
.demo .fcard .name { font-size: clamp(15px, 2.4vw, 21px); }
.demo .fcard .ar { font-size: clamp(11px, 1.7vw, 15px); }
.demo .fcard .ph span { font-size: clamp(30px, 6vw, 56px); margin-bottom: 40%; }
.demo .fcard.text .statement { font-size: 15px; }
.demo .stamp { top: 10px; font-size: clamp(10px, 1.6vw, 14px); padding: 2px 6px; border-width: 2px; border-radius: 6px; }
.demo .stamp.l { right: 8px; }
.demo .stamp.r { left: 8px; }

.field { display: flex; flex-direction: column; gap: 6px; max-width: 420px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  caret-color: var(--accent); transition: border-color .15s ease;
}
.field input::placeholder { color: var(--muted); opacity: .8; }
.field input:focus { border-color: var(--accent); }

.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mode {
  text-align: left; border: 0; background: var(--surface); box-shadow: var(--shadow-sm);
  border-radius: 18px; padding: 12px 12px 16px; display: flex; flex-direction: column; gap: 8px;
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
  animation: rise .5s var(--ease-out) calc(var(--i) * 50ms) backwards;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.mode:active { transform: scale(.975); }
.mode h2, .mode p, .mode .dir { margin-left: 6px; margin-right: 6px; }
.mode h2 { margin-top: 4px; }
.mode p { margin-top: 0; margin-bottom: 4px; color: var(--muted); font-size: 15px; }
.mode .dir { margin-top: auto; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; }
.dir span { display: inline-flex; align-items: center; gap: 4px; }
.dir .l { color: var(--left); } .dir .r { color: var(--right); }

.art {
  position: relative; display: grid; place-items: center; overflow: hidden;
  height: 112px; border-radius: 12px;
  background: hsl(var(--mh) var(--tint-s) var(--tint-l));
}
.mini {
  position: absolute; width: 56px; height: 76px; border-radius: 9px; overflow: hidden;
  box-shadow: 0 4px 10px rgba(20,35,43,.22);
  transition: transform .35s var(--spring);
}
.mini .ph, .mini img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.mini:nth-child(1) { transform: translateX(-34px) rotate(-12deg); }
.mini:nth-child(2) { transform: translateX(34px) rotate(12deg); }
.mini:nth-child(3) { transform: translateY(-2px); }
.meter {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 10px 16px 8px; border-radius: 12px;
  font-family: var(--mono); background: #C7D6C1; color: #1C2A1C; box-shadow: inset 0 2px 5px rgba(0,0,0,.18), 0 4px 10px rgba(20,35,43,.16);
  transition: transform .35s var(--spring);
}
.meter b { font-size: 44px; font-weight: 400; line-height: 1; }
.meter small { font-size: 13px; }
.bigquote { position: absolute; left: 50%; bottom: -44px; transform: translateX(-50%); font-family: var(--display); font-weight: 800; font-size: 130px; line-height: 1; color: var(--accent); opacity: .3; }
.art .tag {
  position: absolute; top: 34px; padding: 3px 10px; border: 2.5px solid; border-radius: 8px; background: var(--surface);
  font-family: var(--display); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .03em;
  transition: transform .35s var(--spring);
}
.art .tag.l { left: 14%; color: var(--left); transform: rotate(-9deg); }
.art .tag.r { right: 14%; color: var(--right); transform: rotate(8deg); }
@media (hover: hover) {
  .mode:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
  .mode:hover .mini:nth-child(1) { transform: translateX(-44px) rotate(-18deg); }
  .mode:hover .mini:nth-child(2) { transform: translateX(44px) rotate(18deg); }
  .mode:hover .mini:nth-child(3) { transform: translateY(-6px) scale(1.04); }
  .mode:hover .meter { transform: scale(1.06); }
  .mode:hover .tag.l { transform: rotate(-14deg) translateX(-4px); }
  .mode:hover .tag.r { transform: rotate(13deg) translateX(4px); }
  .btn:hover { filter: brightness(1.08); }
  .btn.ghost:hover { border-color: var(--accent); filter: none; }
  .quit:hover { color: var(--ink); border-color: var(--muted); }
  .linkbtn:hover { color: var(--ink); }
}

.board { display: flex; flex-direction: column; gap: 12px; }
.board-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.board-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px 24px; }
.board-col h3 { color: var(--muted); margin-bottom: 6px; }
.lb { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lb li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: baseline; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.lb .rank { font-family: var(--mono); color: var(--muted); }
.lb .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.lb .pts { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lb .mine .who, .lb .mine .pts { color: var(--accent); }
.lb .empty { display: block; color: var(--muted); font-size: 14px; border: 0; }
.linkbtn {
  background: none; border: 0; padding: 4px 8px; color: var(--muted);
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.credit { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Game ---------- */
.in-game { overflow: hidden; overscroll-behavior: none; }
.in-game .app { height: 100vh; height: 100dvh; overflow: hidden; padding-bottom: max(16px, env(safe-area-inset-bottom, 0px)); }

#game { min-height: 0; gap: clamp(8px, 1.6vh, 16px); --pl: 0; --pr: 0; }
.gamebar { display: flex; align-items: center; gap: 14px; }
.gamebar .modename { font-family: var(--display); font-weight: 800; font-size: 20px; white-space: nowrap; }
.gamebar .count { font-family: var(--mono); color: var(--muted); font-size: 18px; font-variant-numeric: tabular-nums; }
.gamebar .spacer { flex: 1; }
.quit {
  background: none; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 6px 12px; font-size: 14px; color: var(--muted);
  min-height: 44px; min-width: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, border-color .15s ease;
}
.pips { display: flex; gap: 5px; flex: none; }
.pips i {
  width: 9px; height: 9px; border-radius: 50%; background: var(--line);
  transition: background-color .2s ease, transform .35s var(--spring);
}
.pips i.now { background: var(--accent); transform: scale(1.3); }
.pips i.ok { background: var(--right); }
.pips i.no { background: var(--left); }

.lcd {
  display: flex; align-items: baseline; gap: 6px; padding: 6px 12px 4px; border-radius: 10px;
  background: var(--lcd-bg); color: var(--lcd-ink); font-family: var(--mono);
  box-shadow: inset 0 2px 4px rgba(0,0,0,.12);
}
.lcd .num { font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; min-width: 2.6ch; text-align: right; }
.lcd .unit { font-size: 12px; letter-spacing: .08em; }
.lcd.low .num { animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
.timebar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; flex: none; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left; transition: background-color .2s ease; }
.timebar.low i { background: var(--left); }

.stage { position: relative; flex: 1; min-height: 0; display: flex; justify-content: center; align-items: center; padding-bottom: 30px; }
.deck { position: relative; height: 100%; aspect-ratio: .74; max-width: 100%; max-height: 780px; --p: 0; }
.fcard {
  position: absolute; inset: 0; border-radius: 26px; overflow: hidden;
  background: var(--surface); box-shadow: var(--shadow);
  transform-origin: 50% 100%;
  transition: transform .42s var(--ease-out), opacity .3s ease;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.fcard.d0 { z-index: 3; touch-action: none; cursor: grab; transition: transform .5s var(--spring), opacity .3s ease; }
.fcard.d1 { z-index: 2; transform: translateY(calc(13px * (1 - var(--p)))) scale(calc(.95 + .05 * var(--p))); }
.fcard.d2 { z-index: 1; opacity: .8; transform: translateY(calc(26px - 13px * var(--p))) scale(calc(.9 + .05 * var(--p))); }
.fcard.incoming { opacity: 0; transform: translateY(44px) scale(.84); transition: none; }
.fcard.gone { z-index: 5; pointer-events: none; }
.deck.dragging .fcard { transition: none; }
/* The next card stays blank during the verdict, so "Answer: Carb" is never read against the wrong food */
.fcard > * { transition: opacity .22s ease; }
.deck.answering .fcard.d0 > * { opacity: 0; transition: none; }
.fcard.dragging { cursor: grabbing; will-change: transform; }
/* Photos sit a little high, so food centred in the shot stays clear of the name and the gradient */
.fcard:not(.text) { background: #0A1014; }
.fcard img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: translateY(-9%); pointer-events: none; -webkit-user-drag: none; }
.fcard .ph, .thumb .ph {
  position: absolute; inset: 0; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(120% 80% at 30% 20%, hsl(var(--h) 55% 62%), transparent 60%),
    linear-gradient(160deg, hsl(var(--h) 45% 46%), hsl(calc(var(--h) + 25) 50% 28%));
}
.mini .ph { background: linear-gradient(160deg, hsl(var(--h) 55% 56%), hsl(calc(var(--h) + 25) 50% 34%)); }
.fcard .ph span {
  font-family: var(--arabic); font-weight: 700; font-size: clamp(56px, 11vh, 104px);
  color: rgba(255,255,255,.22); line-height: 1.2; text-align: center; padding: 0 12px; margin-bottom: 30%;
}
.fcard .info {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 80px 22px 22px; color: var(--on-photo);
  background: linear-gradient(to bottom, transparent, var(--scrim) 50%, #0A1014 76%);
  display: flex; flex-direction: column; gap: 4px;
}
.fcard .chip {
  align-self: flex-start; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; background: rgba(255,255,255,.2);
  margin-bottom: 4px;
}
.fcard .name { font-family: var(--display); font-weight: 800; font-size: clamp(30px, 5vh, 42px); line-height: 1.05; margin: 0; text-wrap: balance; }
.fcard .ar { font-family: var(--arabic); font-weight: 700; font-size: 22px; margin: 0; opacity: .92; }
.fcard .sub { margin: 0; font-size: 16px; opacity: .88; }

/* text-only card (Myth or Fact) */
.fcard.text { display: flex; flex-direction: column; justify-content: center; gap: 16px; padding: 34px 28px; }
.fcard.text .kick { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); margin: 0; }
.fcard.text .statement { font-family: var(--display); font-weight: 600; font-size: clamp(24px, 3.6vh, 32px); line-height: 1.2; margin: 0; text-wrap: balance; }
.fcard.text .quote { font-family: var(--display); font-weight: 800; font-size: 90px; line-height: .6; color: var(--accent); opacity: .3; margin: 0; }

/* colour wash and stamp, both driven by how far the card has been dragged */
.fcard::before, .fcard::after {
  content: ""; position: absolute; inset: 0; z-index: 3; pointer-events: none;
  transition: opacity .2s ease;
}
.fcard::before { background: linear-gradient(to left, var(--left), transparent 75%); opacity: calc(var(--sl, 0) * .4); }
.fcard::after { background: linear-gradient(to right, var(--right), transparent 75%); opacity: calc(var(--sr, 0) * .4); }
.stamp {
  position: absolute; top: 26px; z-index: 4; padding: 4px 12px; border: 4px solid; border-radius: 10px;
  font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: .04em; text-transform: uppercase;
  pointer-events: none; background: rgba(255,255,255,.9);
  transition: opacity .15s ease, transform .25s var(--spring);
}
.stamp.l { right: 20px; color: #C4371F; border-color: #C4371F; opacity: var(--sl, 0); transform: rotate(14deg) scale(calc(1.3 - .3 * var(--sl, 0))); }
.stamp.r { left: 20px; color: #0B7C5B; border-color: #0B7C5B; opacity: var(--sr, 0); transform: rotate(-14deg) scale(calc(1.3 - .3 * var(--sr, 0))); }
.fcard.dragging::before, .fcard.dragging::after, .fcard.dragging .stamp { transition: none; }

.flash { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 10; }
.flash .msg {
  display: grid; justify-items: center; gap: 4px;
  padding: 16px 26px; border-radius: 20px; text-align: center; box-shadow: var(--shadow);
  font-family: var(--display); font-weight: 800; font-size: 30px; line-height: 1.1;
  animation: verdict .95s linear both;
}
@keyframes verdict {
  0% { opacity: 0; transform: scale(.78); animation-timing-function: var(--spring); }
  22% { opacity: 1; transform: scale(1); }
  84% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(.97); }
}
.flash .head { display: flex; align-items: center; gap: 8px; }
.flash .head svg { width: .95em; height: .95em; stroke-width: 3.5; }
.flash .head path { stroke-dasharray: 30; animation: draw .28s ease-out .06s backwards; }
@keyframes draw { from { stroke-dashoffset: 30; } to { stroke-dashoffset: 0; } }
.flash small { font-family: var(--body); font-weight: 600; font-size: 16px; }
.flash .gain { font-family: var(--mono); font-weight: 400; font-size: 20px; }
.flash .ok { background: var(--right-soft); color: #0A6B4F; }
.flash .no { background: var(--left-soft); color: #B4321F; }

.answers { display: flex; justify-content: center; gap: clamp(28px, 10vw, 80px); flex: none; }
.rb { background: none; border: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0; }
.rb .circle {
  width: 78px; height: 78px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); font-size: 34px;
  transition: transform .2s var(--spring), background-color .15s ease, color .15s ease;
}
.rb.l .circle { color: var(--left); box-shadow: inset 0 0 0 2.5px var(--left), var(--shadow-sm); transform: scale(calc(1 + .14 * var(--pl))); }
.rb.r .circle { color: var(--right); box-shadow: inset 0 0 0 2.5px var(--right), var(--shadow-sm); transform: scale(calc(1 + .14 * var(--pr))); }
.rb:active .circle { transform: scale(.88); }
@media (hover: hover) {
  .rb.l:hover .circle { background: var(--left); color: var(--surface); }
  .rb.r:hover .circle { background: var(--right); color: var(--surface); }
}
.rb .lbl { font-weight: 700; font-size: 16px; }
.rb.l .lbl { color: var(--left); } .rb.r .lbl { color: var(--right); }
.hint { margin: 0; text-align: center; color: var(--muted); font-size: 13px; flex: none; }

/* ---------- Results ---------- */
.readout {
  display: grid; grid-template-columns: auto 1fr; align-items: end; gap: 12px 20px;
  padding: 20px 24px; border-radius: 20px;
  background: var(--lcd-bg); color: var(--lcd-ink); font-family: var(--mono);
  box-shadow: inset 0 2px 6px rgba(0,0,0,.14);
}
.big { font-size: clamp(76px, 16vw, 128px); line-height: .85; margin: 0; font-variant-numeric: tabular-nums; animation: reading .55s var(--spring) backwards; }
@keyframes reading { from { opacity: 0; transform: scale(.9); transform-origin: left bottom; } }
.big span { font-size: clamp(32px, 6.7vw, 54px); opacity: .7; }
.readout .pts { margin: 0 0 4px; text-align: right; font-size: clamp(18px, 3.8vw, 28px); font-variant-numeric: tabular-nums; }
.readout .pips { grid-column: 1 / -1; gap: 8px; }
.readout .pips i { width: 14px; height: 14px; animation: rise .35s var(--ease-out) calc(var(--i) * 45ms) backwards; }
.readout .pips i.ok { background: #0E7A5B; }
.readout .pips i.no { background: #C4371F; }
.readout.perfect .pips i { animation: wave .6s var(--spring) calc(var(--i) * 70ms + 200ms) backwards; }
@keyframes wave { 0% { transform: translateY(0) scale(.6); opacity: 0; } 45% { transform: translateY(-10px) scale(1.2); opacity: 1; } 100% { transform: none; } }
.scoremeta { display: flex; flex-direction: column; gap: 2px; }
.rmode { margin: 0; font-weight: 700; }
.verdict { margin: 0; color: var(--muted); font-size: 17px; }

.review { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.review li {
  display: grid; grid-template-columns: 52px 1fr; gap: 4px 14px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start;
  animation: rise .4s var(--ease-out) calc(var(--i) * 35ms + 120ms) backwards;
}
.review .thumb { grid-row: span 2; width: 52px; height: 52px; border-radius: 12px; position: relative; }
.review .thumb img, .review .thumb .ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 12px; }
.review .thumb .mark {
  position: absolute; right: -4px; bottom: -4px; width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center; font-size: 13px; box-shadow: 0 0 0 2px var(--bg);
}
.review .thumb.textonly { background: var(--line); }
.mark.ok { background: var(--right); color: var(--surface); }
.mark.no { background: var(--left); color: var(--surface); }
.mark svg { stroke-width: 4; }
.review .item { font-weight: 700; min-width: 0; }
.review .item .tag { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-size: 13px; color: var(--muted); margin-left: 8px; white-space: nowrap; }
.review .why { color: var(--muted); font-size: 15px; min-width: 0; }
.review .why b { color: var(--ink); font-weight: 600; }
.review .miss .why b { color: var(--left); }
.takeaway { background: var(--lcd-bg); color: var(--lcd-ink); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; box-shadow: inset 0 2px 5px rgba(0,0,0,.1); }
.takeaway h3 { font-size: 17px; font-weight: 800; }
.takeaway p { margin: 0; max-width: 70ch; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  border: 0; border-radius: 14px; padding: 14px 22px; min-height: 48px; font-weight: 700; font-size: 17px;
  background: var(--accent); color: var(--surface);
  transition: transform .2s var(--spring), filter .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(.96); }
.btn.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); }

/* ---------- Smaller screens ---------- */
@media (max-width: 719px) {
  .modes { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .mode {
    display: grid; grid-template-columns: minmax(0, 1fr) 100px; grid-template-rows: auto auto auto;
    column-gap: 6px; row-gap: 2px; padding: 10px 10px 12px 12px;
  }
  .mode h2 { grid-column: 1; grid-row: 1; margin: 2px 0 0; font-size: 20px; }
  .mode p { grid-column: 1; grid-row: 2; margin: 0 0 6px; font-size: 14px; line-height: 1.35; }
  .mode .dir { grid-column: 1; grid-row: 3; margin: auto 0 0; }
  .art { grid-column: 2; grid-row: 1 / span 3; height: 100%; min-height: 92px; }
  .mini { width: 40px; height: 54px; border-radius: 7px; }
  .mini:nth-child(1) { transform: translateX(-22px) rotate(-12deg); }
  .mini:nth-child(2) { transform: translateX(22px) rotate(12deg); }
  .meter { padding: 7px 8px 5px; gap: 3px; }
  .meter b { font-size: 28px; }
  .meter small { font-size: 10px; }
  .bigquote { font-size: 90px; bottom: -32px; }
  .art .tag { font-size: 11px; padding: 2px 5px; border-width: 2px; border-radius: 6px; top: 12px; }
  .art .tag.l { left: 6px; }
  .art .tag.r { right: 6px; top: 44px; }
}
@media (max-width: 560px) {
  .screen { gap: 14px; }
  .hero { grid-template-areas: "title demo" "lede lede" "rules rules"; grid-template-rows: auto auto auto; gap: 10px 14px; padding: 20px; }
  .hero h1 { align-self: center; }
  .hero .lede { font-size: 15px; line-height: 1.4; }
  .rules { margin-top: 2px; }
  .demo { width: 92px; margin-bottom: 10px; }
  .demo .fcard { border-radius: 10px; }
  .demo .fcard.d1 { transform: translateY(5px) scale(.94); }
  .demo .fcard.d2 { transform: translateY(10px) scale(.88); }
  .demo .fcard .info { padding: 18px 6px 6px; }
  .demo .fcard .name { font-size: 12px; }
  .demo .fcard .ar { font-size: 9px; }
  .demo .fcard .ph span { font-size: 26px; }
  .demo .stamp { top: 5px; font-size: 8px; padding: 1px 3px; border-width: 1.5px; border-radius: 4px; }
  .demo .stamp.l { right: 4px; }
  .demo .stamp.r { left: 4px; }
}
@media (max-width: 480px) {
  .gamebar { gap: 8px; }
  .gamebar .modename { font-size: 16px; }
  .gamebar .count { display: none; }
  .pips { gap: 3px; }
  .pips i { width: 7px; height: 7px; }
  .readout .pips { gap: 6px; }
  .readout .pips i { width: 12px; height: 12px; }
  .lcd { padding: 4px 8px 3px; gap: 4px; }
  .lcd .num { font-size: 22px; min-width: 2.3ch; }
  .lcd .unit { font-size: 11px; }
  .quit { padding: 4px 8px; font-size: 13px; }
  .readout { padding: 16px 18px; }
}
@media (max-width: 340px) {
  h1 { font-size: 34px; }
  .gamebar .modename { display: none; }
  .demo { width: 80px; }
}
@media (max-height: 700px) {
  .hint { display: none; }
  .stage { padding-bottom: 26px; }
  .rb .circle { width: 68px; height: 68px; font-size: 30px; }
  .rb .lbl { font-size: 14px; }
  .fcard .info { padding: 50px 16px 14px; gap: 2px; }
  .fcard .chip { font-size: 11px; padding: 3px 8px; margin-bottom: 2px; }
  .fcard .name { font-size: 24px; line-height: 1.1; }
  .fcard .ar { font-size: 18px; }
  .fcard .sub { font-size: 13px; }
  .fcard.text { padding: 20px 18px; gap: 10px; }
  .fcard.text .quote { font-size: 50px; line-height: .5; }
  .fcard.text .kick { font-size: 11px; }
  .fcard.text .statement { font-size: 18px; line-height: 1.25; }
  .fcard .ph span { font-size: 56px; margin-bottom: 35%; }
  .fcard { border-radius: 20px; }
  .stamp { font-size: 20px; top: 16px; border-width: 3px; padding: 2px 8px; }
  .stamp.l { right: 12px; }
  .stamp.r { left: 12px; }
  .flash .msg { font-size: 24px; padding: 12px 20px; }
  .flash small { font-size: 14px; }
  .flash .gain { font-size: 16px; }
}
@media (max-height: 520px) and (orientation: portrait) {
  .fcard.text .quote { display: none; }
  .fcard.text .statement { font-size: 15px; }
  .rb .circle { width: 58px; height: 58px; font-size: 26px; }
}

/* Phone held sideways: buttons either side of a wider card, because Safari's toolbars can leave under 300px */
@media (max-height: 560px) and (orientation: landscape) {
  .in-game .app {
    padding-top: max(6px, env(safe-area-inset-top, 0px));
    padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  }
  #game {
    display: grid; align-items: center; gap: 6px 16px; height: 100%; min-height: 0;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto auto minmax(0, 1fr);
    grid-template-areas: "bar bar bar" "time time time" "left stage right";
  }
  .gamebar { grid-area: bar; }
  .timebar { grid-area: time; }
  .answers { display: contents; }
  #btnL { grid-area: left; align-self: center; }
  #btnR { grid-area: right; align-self: center; }
  .stage { grid-area: stage; height: 100%; padding-bottom: 22px; }
  .hint, .fcard.text .quote { display: none; }
  .rb .circle { width: 58px; height: 58px; font-size: 26px; }
  .rb .lbl { font-size: 13px; }
  .deck { aspect-ratio: 1.15; }
  .fcard img { transform: none; object-position: 50% 36%; }
  .fcard { border-radius: 18px; }
  .fcard .info { padding: 30px 12px 10px; gap: 2px; }
  .fcard .chip { font-size: 10px; padding: 2px 6px; margin-bottom: 2px; }
  .fcard .name { font-size: 20px; line-height: 1.1; }
  .fcard .ar { font-size: 14px; }
  .fcard .sub { font-size: 12px; }
  .fcard.text { padding: 12px 14px; gap: 6px; }
  .fcard.text .kick { font-size: 10px; }
  .fcard.text .statement { font-size: 15px; line-height: 1.2; }
  .fcard .ph span { font-size: 36px; margin-bottom: 30%; }
  .fcard.d1 { transform: translateY(calc(9px * (1 - var(--p)))) scale(calc(.96 + .04 * var(--p))); }
  .fcard.d2 { transform: translateY(calc(18px - 9px * var(--p))) scale(calc(.92 + .04 * var(--p))); }
  .stamp { font-size: 16px; top: 10px; border-width: 2.5px; padding: 2px 6px; }
  .flash .msg { font-size: 20px; padding: 10px 16px; gap: 2px; }
  .flash small { font-size: 13px; }
  .flash .gain { font-size: 14px; }
  .hero { grid-template-rows: auto auto auto; }
}

/* Cards that move with intent become simple fades; meaning stays, travel goes */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .flash .msg { animation: fade .95s linear both !important; }
  @keyframes fade { 0% { opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { opacity: 0; } }
}
