:root {
  color-scheme: light dark;
  --bg: #f2f2f0;
  --panel: #ffffff;
  --panel-2: rgba(0, 0, 0, 0.045);
  --ink: #1c1c1f;
  --muted: #6c6c73;
  --line: rgba(20, 20, 30, 0.12);
  --line-strong: rgba(20, 20, 30, 0.28);
  --accent: #ffc53d;
  --accent-deep: #d99c0f;
  --accent-ink: #2b1d00;
  --link: #1f5fbf;
  /* the swatches always sit on this neutral grey, in light and dark mode alike */
  --surround: #7a7a7a;
  --t0: #1f9d55;
  --t1: #b88a00;
  --t2: #e0701b;
  --t3: #d63d3d;
  --t4: #7c7c84;
  --radius: 18px;
  --display: Fraunces, Georgia, 'Times New Roman', serif;
  --display-weight: 600; /* the weight hub/game.css gives display text */
  --heading: var(--ink); /* the gold accent is too light for headings on a light dialog */
  --panel-solid: var(--panel); /* hub/game.css's solid panel: Shade's own is already solid */
  --text: Figtree, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --panel: #232327;
    --panel-2: rgba(255, 255, 255, 0.06);
    --ink: #f1f1f3;
    --muted: #a0a0a8;
    --line: rgba(255, 255, 255, 0.11);
    --line-strong: rgba(255, 255, 255, 0.3);
    --accent: #ffc53d;
    --accent-deep: #c98d07;
    --link: #8ab8ff;
    --t0: #4fd08a;
    --t1: #f2c94c;
    --t2: #ff9a4d;
    --t3: #ff6b6b;
    --t4: #9a9aa2;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--text);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }

.app {
  max-width: 460px;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ------------------------------------------------------------ header */
.logo {
  font-family: var(--display);
  font-style: italic;
  font-weight: 700;
  font-size: 1.75rem;
  line-height: 1;
  letter-spacing: -0.01em;
  position: relative;
  padding-bottom: 5px;
}
.logo::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 0;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, #e8524a 0 20%, #f4a52d 20% 40%, #f2d33a 40% 60%, #4cae6a 60% 80%, #5a7fe0 80%);
}
.day { margin-top: 4px; font-size: 0.78rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
.icon-btn:hover { background: var(--panel); }

.banner .bs { display: none; }

/* ------------------------------------------------------------ progress chips */
.chips { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.chips[hidden] { display: none; }
.chip {
  position: relative;
  height: 32px;
  border-radius: 9px;
  border: 1.5px dashed var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  overflow: hidden;
}
.chip.on { border-style: solid; border-color: var(--ink); color: var(--ink); }
.chip.done { border: 0; display: flex; background: var(--surround); padding: 3px; gap: 0; }
.chip.done i { flex: 1; height: 100%; }
.chip.done i:first-child { border-radius: 6px 0 0 6px; }
.chip.done i:nth-child(2) { border-radius: 0 6px 6px 0; }
.chip.done span {
  position: absolute;
  inset: auto 50% 50% auto;
  transform: translate(50%, 50%);
  background: var(--panel);
  color: var(--ink);
  border-radius: 6px;
  padding: 1px 5px;
  font-size: 0.7rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  animation: chipin 0.35s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes chipin { from { transform: translate(50%, 50%) scale(0.4); opacity: 0; } }

/* ------------------------------------------------------------ the round */
.play { display: flex; flex-direction: column; gap: 10px; }
.play[hidden] { display: none; }
/* A round fills the screen and the pad takes the height that's left, so Lock it in is never
   below the fold. svh is the viewport with the browser's toolbars showing. */
.app:has(> .play:not([hidden])) { min-height: 100vh; min-height: 100svh; }
.play { flex: 1 1 auto; }
.prompt { text-align: center; padding-top: 2px; }
.prompt-k { font-size: 0.74rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.prompt-name {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.1rem, 10vw, 2.9rem);
  line-height: 1.12;
  letter-spacing: -0.015em;
  min-height: 1.12em;
}
.prompt-name.long { font-size: clamp(1.7rem, 7.6vw, 2.3rem); line-height: 1.38; }
.prompt-name.in { animation: namein 0.45s cubic-bezier(0.2, 0.9, 0.3, 1); }
@keyframes namein { from { opacity: 0; transform: translateY(8px); filter: blur(3px); } }

.surround { position: relative; background: var(--surround); border-radius: 22px; padding: 14px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.swatch {
  position: relative;
  height: clamp(100px, 19vh, 190px);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15), 0 2px 10px rgba(0, 0, 0, 0.18);
}
.sw { position: absolute; inset: 0; transition: background-color 0.06s linear; }
.sw-crowd { clip-path: inset(0 0 0 100%); transition: clip-path 0.55s cubic-bezier(0.25, 0.9, 0.25, 1); }
.swatch.revealed .sw-crowd { clip-path: inset(0 0 0 50%); }
.sw-label {
  position: absolute;
  bottom: 9px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.92);
  opacity: 0;
  transition: opacity 0.3s 0.35s;
}
.sw-you .sw-label { left: 11px; }
.sw-crowd .sw-label { right: 11px; }
.ink-dark .sw-label { color: rgba(0, 0, 0, 0.72); }
.swatch.revealed .sw-label { opacity: 1; }
/* The score hangs from the surround's bottom edge, under the seam: never on the two colours. */
.badge {
  position: absolute;
  left: 50%;
  top: calc(100% - 11px); /* 3px below the swatch */
  display: flex;
  align-items: baseline;
  gap: 1px;
  padding: 4px 11px 5px;
  border-radius: 999px;
  background: #fff;
  color: #1c1c1f;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%) scale(0.5);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.2, 1.6, 0.4, 1), opacity 0.2s;
  pointer-events: none;
}
.badge b { font-family: var(--display); font-weight: 600; font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums; min-width: 1.6em; text-align: right; }
.badge small { font-size: 0.74rem; font-weight: 700; color: #6c6c73; }
.swatch.scored + .badge { opacity: 1; transform: translateX(-50%) scale(1); }

.verdict {
  min-height: 2.65rem; /* two lines, also while it holds the smaller hint */
  margin-top: 15px; /* room for the score badge */
  text-align: center;
  font-weight: 600;
  line-height: 1.35;
  font-size: 0.98rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.3s, transform 0.3s;
  margin-bottom: -6px;
}
.verdict.show { opacity: 1; transform: none; }
.verdict.hint { color: var(--muted); font-size: 0.9rem; font-weight: 600; }

/* ------------------------------------------------------------ picker */
.picker { display: contents; } /* the hue strip and pad sit in .play's column, so the pad can grow */
.hue, .pad { position: relative; touch-action: none; cursor: crosshair; outline: none; user-select: none; -webkit-user-select: none; }
.hue { height: 44px; border-radius: 12px; } /* a 44px touch target, also on short screens */
.pad { flex: 1 1 0; min-height: 120px; max-height: 300px; border-radius: 16px; }
.hue canvas, .pad canvas { display: block; width: 100%; height: 100%; border-radius: inherit; }
.pad canvas { position: absolute; inset: 0; }
.hue:focus-visible, .pad:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--ink); }
.hue .thumb {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 16px;
  margin-left: -8px;
  border-radius: 8px;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.12s;
}
.pad .thumb {
  position: absolute;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45), 0 3px 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: transform 0.12s;
}
.dragging .thumb { transform: scale(1.18); }
.mark {
  position: absolute;
  top: -11px;
  width: 0;
  height: 0;
  margin-left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--ink);
  animation: markin 0.4s 0.4s both;
}
.mark[hidden] { display: none; }
@keyframes markin { from { opacity: 0; transform: translateY(-6px); } }
.pad-hint {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transition: opacity 0.4s;
}
.pad-hint-y { left: 10px; top: 8px; color: rgba(0, 0, 0, 0.55); text-shadow: none; }
.pad-hint-x { right: 10px; bottom: 8px; }
.picker.touched .pad-hint { opacity: 0; }
.hue.off, .pad.off { opacity: 0.6; cursor: default; }

/* ------------------------------------------------------------ buttons */
.btn.primary:active { transform: translateY(3px); box-shadow: 0 0 0 var(--accent-deep); }
.btn.primary.pending { opacity: 0.7; }
@media (prefers-reduced-motion: no-preference) { html:not(.reduce-motion) .btn.nudge { animation: nudge 0.32s ease; } }
@keyframes nudge { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.btn.ghost:hover { background: var(--panel); }

/* ------------------------------------------------------------ the finished day */
.summary { display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.summary[hidden] { display: none; }
.sum-total, .res-total { font-family: var(--display); font-weight: 600; line-height: 1; }
.sum-total { font-size: 3.4rem; text-align: center; }
.sum-total span, .res-total span { font-size: 0.42em; color: var(--muted); font-family: var(--text); font-weight: 700; margin-left: 4px; }
.summary .kicker { text-align: center; }
.legend { font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.summary .legend { text-align: center; margin-top: -6px; }
.palette { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.palette li { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.palette li:last-child { border-bottom: 0; }
.pair { display: flex; padding: 4px; background: var(--surround); border-radius: 11px; }
.pair i { width: 30px; height: 36px; }
.pair i:first-child { border-radius: 7px 0 0 7px; }
.pair i:last-child { border-radius: 0 7px 7px 0; }
.pl-name { font-family: var(--display); font-style: italic; font-size: 1.12rem; line-height: 1.2; }
.pl-name small { display: block; font-family: var(--text); font-style: normal; font-size: 0.76rem; font-weight: 600; color: var(--muted); margin-top: 2px; }
.pl-pts { font-family: var(--display); font-weight: 600; font-size: 1.35rem; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.t0 { color: var(--t0); }
.t1 { color: var(--t1); }
.t2 { color: var(--t2); }
.t3 { color: var(--t3); }
.t4 { color: var(--t4); }
.chip.done span.t0, .chip.done span.t1, .chip.done span.t2, .chip.done span.t3, .chip.done span.t4 { color: var(--ink); }
.journal { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.journal summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.journal-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 6px; }
.journal-bar .btn { flex: 1; }
.journal .palette { max-height: 50vh; overflow: auto; }
#verdict .last { display: block; margin-top: 4px; font-size: 0.86em; color: var(--muted); }
.res-actions .btn { flex: 1 1 120px; }
.share-note { margin: 8px 0 0; text-align: center; }
.countdown[hidden] { display: none; }
.countdown b { font-family: var(--display); font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ dialogs */
.dialog h2 em { font-weight: 500; }
.rules { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.rules li { display: flex; gap: 12px; align-items: flex-start; line-height: 1.4; font-size: 0.95rem; }
.step {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
  font-size: 0.85rem;
}
.rule-note { margin: 0 0 10px; line-height: 1.45; font-size: 0.93rem; }
.opt { display: flex; gap: 12px; align-items: flex-start; margin: 0 0 12px; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); font-size: 0.9rem; line-height: 1.4; cursor: pointer; }
.opt input { flex: none; width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--link); cursor: pointer; }
.opt b { display: block; }
.keys { margin: 4px 0 16px; font-size: 0.82rem; color: var(--muted); line-height: 2; }
.kicker { color: var(--muted); }
.res-total { font-size: 2.8rem; margin: -2px 0 10px; }
.dialog .palette { margin-bottom: 14px; }
.section-h { margin: 20px 0 10px; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.avg { margin-top: 10px; font-size: 0.88rem; color: var(--muted); font-weight: 600; text-align: center; }
.avg b { color: var(--ink); }
.wd.done i { border: 0; background: var(--panel-2); }
.wd.great i { border: 0; background: var(--accent); color: var(--accent-ink); }
.wd.today i { border-style: solid; border-color: var(--ink); }
.progress-note { margin: 0 0 6px; font-weight: 700; }
.dialog .countdown { margin-top: 16px; }

.toast { z-index: 10; }

@media (max-width: 380px) {
  .app { padding-left: 12px; padding-right: 12px; gap: 8px; }
  .surround { padding: 10px; }
  .stat b { font-size: 1.2rem; }
}
/* a banner (archive, practice) takes a line: give it back from the swatch */
@media (max-height: 760px) {
  .app:has(> .banner:not([hidden])) .swatch { height: clamp(90px, 16vh, 120px); }
}
/* short phones: keep the whole round on one screen */
@media (max-height: 700px) {
  .app { gap: 8px; padding-top: max(8px, env(safe-area-inset-top)); }
  .icon-btn { width: 36px; height: 36px; }
  .logo { font-size: 1.5rem; }
  .chip { height: 26px; }
  .prompt-name { font-size: 1.95rem; }
  .prompt-name.long { font-size: 1.6rem; line-height: 1.2; }
  .surround { padding: 10px; border-radius: 18px; }
  .swatch { height: 86px; }
  .badge { top: calc(100% - 7px); padding: 3px 10px 4px; }
  .badge b { font-size: 1.3rem; }
  .verdict { font-size: 0.9rem; min-height: 2.7em; }
  .btn { min-height: 46px; padding: 11px 16px; }
  /* The archive and practice banner shrinks to one line, so Lock it in stays on screen. */
  .banner { padding: 5px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .banner .bl { display: none; }
  .banner .bs { display: inline; }
  .app:has(> .banner:not([hidden])) .swatch { height: 72px; }
}
/* the shortest (iPhone SE with Safari's toolbars): a little tighter still, so the pad keeps 120px */
@media (max-height: 600px) {
  .play { gap: 8px; }
  .swatch { height: 76px; }
  .banner { padding: 4px 10px; font-size: 0.8rem; }
  .app:has(> .banner:not([hidden])) .swatch { height: 54px; }
}
@media (min-width: 900px) and (min-height: 760px) {
  .app { padding-top: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* the same for the site-wide Reduce motion setting (hub/prefs.js) */
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; transition: none !important; }

/* Each name, everyone (#268): the share of players in each tier, per name. */
.crowd-hard { margin: 0 0 8px; font-size: 0.92rem; }
.crowd-names { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 6px; }
.crowd-names li { display: grid; grid-template-columns: minmax(0, 9em) 1fr auto; align-items: center; gap: 10px; font-size: 0.86rem; }
.cn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cn-tag { font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; color: var(--t3); }
.cn-bar { display: flex; height: 12px; border-radius: 4px; overflow: hidden; gap: 1px; }
.cn-bar i, .cn-key i { display: block; flex-basis: 0; min-width: 2px; }
.cn-n { font-size: 0.76rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.cn-key { display: inline-flex; align-items: center; gap: 4px; margin-right: 8px; white-space: nowrap; }
.cn-key i { flex: none; width: 10px; height: 10px; border-radius: 3px; }
.cb0 { background: var(--t0); }
.cb1 { background: var(--t1); }
.cb2 { background: var(--t2); }
.cb3 { background: var(--t3); }
.cb4 { background: var(--t4); }
