/* Find Filip styles. Sizes come from tokens.css. Rules: DESIGN.md. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* No pull-to-refresh or page bounce: this is a game, not a page to scroll. */
html { overscroll-behavior: none; }

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  touch-action: manipulation;
}

h1, h2, h3, p { margin: 0; }

/* "hidden" always wins over a display set in this file. */
[hidden] { display: none !important; }

/* Start every button at zero. Browsers add their own odd padding (1px 6px). */
button {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  color: inherit;
  line-height: var(--leading-control);
  cursor: pointer;
  transition: scale var(--duration-press) var(--ease-out), background-color var(--duration-fast),
    box-shadow var(--duration-fast), color var(--duration-fast), opacity var(--duration-fast);
}

/* A pressed button shrinks a little, so a tap feels physical. */
button:active:not(:disabled) { scale: var(--press, 0.96); }

:focus-visible {
  outline: var(--border-width) solid var(--color-brand);
  outline-offset: var(--space-1);
}

a { color: inherit; }

.icon {
  width: var(--size-icon-md);
  height: var(--size-icon-md);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- shared animations ---------- */

@keyframes rise { from { opacity: 0; translate: 0 var(--space-4); } }
@keyframes drop { from { opacity: 0; translate: 0 calc(var(--space-4) * -1); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes pop { from { opacity: 0; scale: 0.6; } }
@keyframes pop-in { from { opacity: 0; scale: 0.6; rotate: -12deg; } }
@keyframes pop-text { from { scale: 1.16; } }
@keyframes slide-in { from { opacity: 0; translate: calc(var(--space-4) * -1) 0; } }

@keyframes nope {
  20%, 60% { translate: calc(var(--space-1) * -1) 0; }
  40%, 80% { translate: var(--space-1) 0; }
}

button.nope { animation: nope var(--duration-base) var(--ease-out); }
button.flash { animation: pop-text var(--duration-base) var(--ease-spring); }

/* ---------- start screen ---------- */

.start {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: none;
  overflow-y: auto;
  padding: var(--page-y) var(--page-x);
  background: var(--color-bg);
  transition: opacity var(--duration-fast) var(--ease-in);
}

body.starting .start { display: flex; }
body.starting > .top,
body.starting > main { display: none; }
.start.leaving { opacity: 0; }

.start-inner {
  width: 100%;
  max-width: 400px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transition: scale var(--duration-fast) var(--ease-in);
}

.start.leaving .start-inner { scale: 0.96; }

/* Everything on the start screen rises in, one after another. */
.start-inner > * { animation: rise var(--duration-slow) var(--ease-out) both; }
.start-inner > :nth-child(2) { animation-delay: 80ms; }
.start-inner > :nth-child(3) { animation-delay: 160ms; }
.start-inner > :nth-child(4) { animation: none; }
.start-inner > :nth-child(5) { animation-delay: 560ms; }
.start-inner > :nth-child(6) { animation-delay: 640ms; }

.start-face {
  width: 96px;
  height: 96px;
  margin-bottom: var(--space-4);
  border-radius: var(--radius-full);
  transform: rotate(-6deg);
  cursor: pointer;
  /* He pops in, then peeks around now and then. */
  animation: pop-in var(--duration-slow) var(--ease-spring) both, peek 4000ms ease-in-out 1600ms infinite;
}

.start-face.wiggle { animation: wiggle var(--duration-slow) var(--ease-out); }

@keyframes peek {
  0%, 16%, 100% { rotate: 0deg; }
  6% { rotate: -8deg; }
  11% { rotate: 4deg; }
}

@keyframes wiggle {
  25% { rotate: -12deg; scale: 1.04; }
  50% { rotate: 8deg; }
  75% { rotate: -4deg; }
}

.start h1 {
  font-size: var(--text-display);
  line-height: var(--leading-display);
  font-weight: var(--weight-black);
  color: var(--color-brand);
}

.start-line {
  margin-top: var(--space-2);
  color: var(--color-text-muted);
}

.start-rules {
  width: 100%;
  margin: var(--space-8) 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: left;
}

.start-rules li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: rise var(--duration-slow) var(--ease-out) both;
}

.start-rules li:nth-child(1) { animation-delay: 240ms; }
.start-rules li:nth-child(2) { animation-delay: 300ms; }
.start-rules li:nth-child(3) { animation-delay: 360ms; }
.start-rules li:nth-child(4) { animation-delay: 420ms; }
.start-rules li:nth-child(5) { animation-delay: 480ms; }

.rule-icon {
  width: var(--size-control-md);
  height: var(--size-control-md);
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-brand);
}

.start-actions {
  width: 100%;
  margin-top: var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.start-actions .primary,
.start-actions .ghost { height: var(--size-control-lg); }

.start-date {
  margin-top: var(--space-6);
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* The game rises in after the start screen. */
body.entering .top { animation: drop var(--duration-slow) var(--ease-out) both; }
body.entering .board { animation: rise var(--duration-slow) var(--ease-out) 80ms both; }
body.entering .below { animation: rise var(--duration-slow) var(--ease-out) 160ms both; }

/* ---------- header ---------- */

.top {
  width: 100%;
  max-width: 1104px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: var(--size-control-md) 1fr var(--size-control-md);
  align-items: center;
  gap: var(--space-2);
  padding: var(--page-y) var(--page-x) 0;
}

.icon-btn {
  --press: 0.88;
  width: var(--size-control-md);
  height: var(--size-control-md);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  display: grid;
  place-items: center;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
}

.brand img {
  width: var(--size-avatar);
  height: var(--size-avatar);
  border-radius: var(--radius-full);
  transform: rotate(-6deg);
}

.brand h1 {
  font-size: var(--text-title);
  line-height: var(--leading-title);
  font-weight: var(--weight-black);
  color: var(--color-brand);
}

.brand p {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- level tabs ---------- */

/* Tabs and photo are one unit: the board. Its radius minus its padding
   equals the photo's radius, so the corners line up. --c is the color of
   the level you are on. */
.board {
  --c: var(--color-easy);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
}

.board[data-level="normal"] { --c: var(--color-normal); }
.board[data-level="hard"] { --c: var(--color-hard); }
.board[data-level="impossible"] { --c: var(--color-impossible); }

.levels {
  --gap: var(--space-2);
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
}

/* The highlight behind the picked tab. It slides to the tab you pick. */
.level-pill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: calc((100% - 3 * var(--gap)) / 4);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--c) 16%, var(--color-surface));
  box-shadow: inset 0 0 0 var(--border-width) var(--c);
  translate: calc(var(--i, 0) * (100% + var(--gap))) 0;
  transition: translate var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast), box-shadow var(--duration-fast);
  pointer-events: none;
}

.level {
  --tab: var(--color-easy);
  position: relative;
  min-width: 0;
  border-radius: var(--radius-md);
  background: transparent;
  padding: var(--space-2) var(--space-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.level .name {
  max-width: 100%;
  font-size: var(--text-caption);
  font-weight: var(--weight-heavy);
  color: var(--tab);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level .sub {
  font-size: var(--text-caption);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.level .sub.pop-text { animation: pop-text var(--duration-base) var(--ease-spring); }

.level.done .sub { color: var(--tab); font-weight: var(--weight-bold); }

/* Impossible before you earn it. */
.level.locked { opacity: 0.48; }

/* Impossible just opened. */
.level.unlock { animation: pop-text var(--duration-base) var(--ease-spring); }

.level.easy { --tab: var(--color-easy); }
.level.normal { --tab: var(--color-normal); }
.level.hard { --tab: var(--color-hard); }
.level.impossible { --tab: var(--color-impossible); }

/* ---------- photo viewer ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1104px;
  margin: 0 auto;
  padding: var(--section-gap) var(--page-x) var(--page-y);
  display: flex;
  flex-direction: column;
  gap: var(--section-gap);
}

.viewer {
  position: relative;
  flex: 1;
  min-height: 320px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}

.viewer.dragging { cursor: grabbing; }

/* While a photo loads (only if it is slow), a soft light runs across the box. */
.viewer.is-loading::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--color-surface) 50%, transparent 70%);
  animation: shimmer 1200ms linear infinite;
}

@keyframes shimmer {
  from { translate: -100% 0; }
  to { translate: 100% 0; }
}

/* A wrong tap: the photo shakes its head. */
.viewer.shake { animation: shake var(--duration-base) var(--ease-out); }

@keyframes shake {
  16% { translate: calc(var(--space-2) * -1) 0; }
  32% { translate: var(--space-2) 0; }
  48% { translate: calc(var(--space-1) * -1) 0; }
  64% { translate: var(--space-1) 0; }
  80% { translate: 0 0; }
}

/* The stage is its own layer on the graphics card (will-change), so moving and
   fading it is cheap. Only the stage fades, never the big photo inside it. */
.stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  transition: opacity 120ms var(--ease-out);
}

.stage.out { opacity: 0; }
.stage.in { animation: fade-in var(--duration-fast) var(--ease-out); }

.stage img {
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Marks live inside the zoomed photo. --inv undoes the zoom, so they keep their size. */
.miss {
  position: absolute;
  width: var(--space-6);
  height: var(--space-6);
  margin: calc(var(--space-6) / -2) 0 0 calc(var(--space-6) / -2);
  transform: scale(var(--inv, 1));
  opacity: 0.64;
  transition: opacity var(--duration-base);
}

.miss.new {
  opacity: 1;
  animation: miss-in var(--duration-base) var(--ease-spring);
}

@keyframes miss-in { from { opacity: 0; scale: 0.5; rotate: -45deg; } }

.miss::before,
.miss::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: var(--space-1);
  height: var(--space-6);
  border-radius: var(--radius-full);
  background: var(--color-danger);
  box-shadow: 0 0 0 var(--border-width) var(--color-white);
}

.miss::before { transform: rotate(45deg); }
.miss::after { transform: rotate(-45deg); }

/* Every tap sends out a small ring. */
.ripple {
  position: absolute;
  width: var(--space-12);
  height: var(--space-12);
  margin: calc(var(--space-12) / -2) 0 0 calc(var(--space-12) / -2);
  border: var(--border-width) solid var(--color-white);
  border-radius: var(--radius-full);
  transform: scale(var(--inv, 1));
  animation: ripple var(--duration-slow) var(--ease-out) forwards;
}

@keyframes ripple {
  from { opacity: 0.8; scale: 0.2; }
  to { opacity: 0; scale: 1.4; }
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: calc(var(--space-1) * var(--inv, 1)) solid var(--c);
  box-shadow: 0 0 0 calc(var(--space-1) * var(--inv, 1)) rgba(0, 0, 0, 0.56),
              inset 0 0 0 calc(var(--space-1) * var(--inv, 1)) rgba(0, 0, 0, 0.32);
}

.ring.lost { border-color: var(--color-brand); }

/* Found him: the ring snaps around Filip, and a wave spreads out. */
.ring.new { animation: ring-in var(--duration-slow) var(--ease-spring); }

.ring.wave {
  box-shadow: none;
  animation: wave var(--duration-slow) var(--ease-out) forwards;
}

@keyframes ring-in { from { opacity: 0; scale: 1.4; } }

@keyframes wave {
  from { opacity: 0.8; }
  to { opacity: 0; scale: 2.4; }
}

/* ---------- on-photo controls ---------- */

.hud {
  position: absolute;
  display: flex;
  gap: var(--space-2);
  pointer-events: none;
}

.hud > * { pointer-events: auto; }

.hud-top {
  top: var(--space-3);
  left: var(--space-3);
  right: var(--space-3);
  align-items: flex-start;
}

.hud-bottom {
  right: var(--space-3);
  bottom: var(--space-3);
}

.chip {
  height: var(--size-control-sm);
  padding: 0 var(--space-3);
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-full);
  background: var(--color-scrim);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  line-height: var(--leading-control);
  font-weight: var(--weight-heavy);
  font-variant-numeric: tabular-nums;
  transition: background-color var(--duration-base), color var(--duration-base);
}

/* The tap count jumps and flashes red on a wrong tap. */
.chip.bump { animation: bump var(--duration-base) var(--ease-spring); }

@keyframes bump { from { scale: 1.12; background-color: var(--color-danger); } }

/* The clock turns the level's color when you find him. */
.chip.win {
  background: var(--c);
  color: var(--color-on-brand);
}

.chip.bump-win { animation: pop-text var(--duration-base) var(--ease-spring); }

/* The last 30 seconds of a time limit: the clock turns red and beats each second. */
.chip.hurry {
  background: var(--color-danger);
  color: var(--color-white);
}

.chip.beat { animation: pop-text var(--duration-base) var(--ease-out); }

.round {
  --press: 0.88;
  width: var(--size-control-md);
  height: var(--size-control-md);
  border-radius: var(--radius-full);
  background: var(--color-scrim);
  backdrop-filter: blur(var(--blur-md));
  -webkit-backdrop-filter: blur(var(--blur-md));
  display: grid;
  place-items: center;
}

/* The yellow "Wanted" card. Tap it to see it bigger: it grows as one picture
   from its top-right corner (scale), so the text always stays inside it. */
.wanted {
  --grow: 1;
  margin-left: auto;
  width: 72px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--color-brand);
  color: var(--color-on-brand);
  box-shadow: var(--shadow-md);
  transform: rotate(4deg);
  transform-origin: top right;
  scale: var(--grow);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  transition: scale var(--duration-base) var(--ease-out), translate var(--duration-base) var(--ease-out);
}

/* Big and tilted, its top-left corner would touch the edge, so it moves down a little. */
.wanted.big {
  --grow: 2.5;
  translate: 0 var(--space-2);
}

.wanted:active:not(:disabled) { scale: calc(var(--grow) * 0.96); }

.wanted > span {
  font-size: var(--text-caption);
  font-weight: var(--weight-black);
  text-transform: uppercase;
  text-align: center;
  white-space: nowrap;
}

.wanted img,
.wanted .q {
  width: 100%;
  height: 80px;
  border-radius: var(--radius-xs);
  background: var(--color-white);
}

.wanted img { display: block; object-fit: contain; }

.wanted .q { display: none; }

.wanted.locked img { display: none; }

.wanted.locked .q {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-title);
  font-weight: var(--weight-black);
}

.wanted.locked .q small {
  font-size: var(--text-caption);
  font-weight: var(--weight-heavy);
  font-variant-numeric: tabular-nums;
}

/* The hint is ready: the card turns over and shows his outfit. */
.wanted.flip { animation: flip var(--duration-base) ease-in-out; }

@keyframes flip {
  0%, 100% { transform: perspective(400px) rotate(4deg) rotateY(0deg); }
  50% { transform: perspective(400px) rotate(4deg) rotateY(90deg); }
}

/* Still secret: the card shakes its head. */
.wanted.nope { animation: nope var(--duration-base) var(--ease-out); }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  text-align: center;
  color: var(--color-text-muted);
  font-weight: var(--weight-bold);
  pointer-events: none;
}

/* ---------- result card ---------- */

.result {
  position: absolute;
  left: var(--space-3);
  right: var(--space-3);
  bottom: var(--space-16);
  margin: 0 auto;
  max-width: 400px;
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  animation: card-in var(--duration-base) var(--ease-spring);
  cursor: default;
}

@keyframes card-in { from { opacity: 0; translate: 0 var(--space-4); scale: 0.98; } }

/* Its parts come in one after another. */
.result > * { animation: rise var(--duration-base) var(--ease-out) both; }
.result > :nth-child(2) { animation-delay: 60ms; }
.result > :nth-child(3) { animation-delay: 120ms; }
.result > :nth-child(4) { animation-delay: 180ms; }

.result h2 {
  font-size: var(--text-title);
  line-height: var(--leading-title);
  font-weight: var(--weight-black);
}

.result .line {
  margin: var(--space-1) 0 var(--space-4);
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.result .row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.result .row > * { flex: 1 1 auto; }

.countdown {
  margin-top: var(--space-3);
  text-align: center;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- below the photo ---------- */

.below {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.credit {
  flex: 1;
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--color-text-muted);
  text-align: right;
}

/* ---------- buttons ---------- */

.primary,
.ghost {
  height: var(--size-control-md);
  padding: 0 var(--space-4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-full);
  font-weight: var(--weight-heavy);
  white-space: nowrap;
}

.primary {
  background: var(--color-brand);
  color: var(--color-on-brand);
}

/* The outline is drawn inside, so a ghost button is the same size as a primary one. */
.ghost {
  background: transparent;
  box-shadow: inset 0 0 0 var(--border-width) var(--color-line);
}

.ghost:disabled { opacity: 0.4; cursor: default; }

.ghost.warn {
  color: var(--color-danger);
  box-shadow: inset 0 0 0 var(--border-width) var(--color-danger);
}

.wide { width: 100%; }

/* Only devices with a mouse get hover looks. On phones they would get stuck. */
@media (hover: hover) {
  .primary:hover { background: color-mix(in srgb, var(--color-brand) 88%, var(--color-white)); }
  .ghost:hover:not(:disabled) { background: var(--color-surface-raised); }
  .icon-btn:hover { background: var(--color-surface-raised); }
  .close:hover { background: var(--color-line); }
  .round:hover { background: rgba(0, 0, 0, 0.8); }
  .level[aria-selected="false"]:hover { background: var(--color-surface-raised); }
}

/* ---------- dialogs ---------- */

dialog {
  width: calc(100% - var(--space-6));
  max-width: 448px;
  max-height: calc(100dvh - var(--space-6));
  border: 0;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  background: var(--color-surface);
  color: var(--color-text);
}

dialog::backdrop {
  background: var(--color-scrim);
  backdrop-filter: blur(var(--space-1));
}

/* Popups spring open and slip away when closed. */
dialog[open] { animation: dialog-in var(--duration-base) var(--ease-spring); }
dialog[open]::backdrop { animation: fade-in var(--duration-fast) ease-out; }
dialog.closing { animation: dialog-out var(--duration-fast) var(--ease-in) forwards; }
dialog.closing::backdrop { animation: fade-out var(--duration-fast) var(--ease-in) forwards; }

@keyframes dialog-in { from { opacity: 0; scale: 0.96; translate: 0 var(--space-4); } }
@keyframes dialog-out { to { opacity: 0; scale: 0.96; translate: 0 var(--space-2); } }

dialog h2 {
  margin-bottom: var(--space-4);
  font-size: var(--text-title);
  line-height: var(--leading-title);
  font-weight: var(--weight-black);
}

dialog h3 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--text-heading);
  line-height: var(--leading-heading);
  font-weight: var(--weight-heavy);
}

dialog p { margin-bottom: var(--space-3); }

.close {
  --press: 0.88;
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: var(--size-control-sm);
  height: var(--size-control-sm);
  border-radius: var(--radius-full);
  background: var(--color-surface-raised);
  display: grid;
  place-items: center;
}

.rules {
  margin: 0;
  padding-left: var(--space-5);
}

.rules li { margin-bottom: var(--space-1); }

.lv { font-weight: var(--weight-heavy); }
.lv.easy { color: var(--color-easy); }
.lv.normal { color: var(--color-normal); }
.lv.hard { color: var(--color-hard); }
.lv.impossible { color: var(--color-impossible); }

.muted { color: var(--color-text-muted); }

.small {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, 64px);
  gap: var(--space-2);
  margin: var(--space-3) 0 var(--space-4);
}

.gallery img {
  width: 64px;
  height: 80px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--color-surface-raised);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
  text-align: center;
}

.stat-grid b {
  display: block;
  font-size: var(--text-display);
  line-height: var(--leading-display);
  font-weight: var(--weight-black);
  font-variant-numeric: tabular-nums;
}

.stat-grid span {
  display: block;
  white-space: nowrap;
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--color-text-muted);
}

.level-table {
  width: 100%;
  margin-top: var(--space-4);
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.level-table th,
.level-table td {
  padding: var(--space-2) var(--space-1);
  text-align: right;
  border-bottom: var(--border-width) solid var(--color-surface-raised);
}

.level-table th {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
}

.level-table th:first-child,
.level-table td:first-child { text-align: left; }

/* ---------- results popup ---------- */

.day-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin-bottom: var(--space-2);
}

.day-face {
  width: var(--space-16);
  height: var(--space-16);
  margin-bottom: var(--space-3);
  border-radius: var(--radius-full);
  transform: rotate(-6deg);
  animation: pop-in var(--duration-slow) var(--ease-spring) 80ms both;
}

.day-top h2 { animation: rise var(--duration-base) var(--ease-out) 160ms both; }

.eyebrow {
  font-size: var(--text-caption);
  line-height: var(--leading-caption);
  color: var(--color-text-muted);
}

dialog .eyebrow { margin-bottom: var(--space-1); }

.day-levels {
  margin: var(--space-6) 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Rows slide in one by one, then their check marks pop. */
.day-levels li {
  --c: var(--color-text-muted);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-surface-raised);
  animation: slide-in var(--duration-base) var(--ease-out) both;
  animation-delay: calc(240ms + var(--i, 0) * 80ms);
}

.day-levels .lv { flex: 1; }

.day-levels .res {
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

.day-levels .icon {
  color: var(--color-text-muted);
  animation: pop var(--duration-base) var(--ease-spring) both;
  animation-delay: calc(440ms + var(--i, 0) * 80ms);
}

.day-levels li.won.easy { --c: var(--color-easy); }
.day-levels li.won.normal { --c: var(--color-normal); }
.day-levels li.won.hard { --c: var(--color-hard); }
.day-levels li.won.impossible { --c: var(--color-impossible); }
.day-levels li.won .icon { color: var(--c); }

#dlg-day .wide { animation: rise var(--duration-base) var(--ease-out) 640ms both; }

/* ---------- confetti ---------- */

/* One canvas over the whole page. As a popover it sits above open popups too. */
.confetti {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  overflow: visible;
  pointer-events: none;
  z-index: 30;
}

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
  translate: -50% var(--space-4);
  z-index: 10;
  width: max-content;
  max-width: calc(100% - var(--space-8));
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--color-brand);
  color: var(--color-on-brand);
  font-weight: var(--weight-heavy);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast), translate var(--duration-base) var(--ease-spring);
}

.toast.show { opacity: 1; translate: -50% 0; }

/* ---------- screen sizes ---------- */

@media (width >= 480px) {
  .level .name { font-size: var(--text-body); }
}

@media (width < 480px) {
  .stat-grid b {
    font-size: var(--text-title);
    line-height: var(--leading-title);
  }

  .below {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: var(--space-2);
  }

  .credit { text-align: center; }
}

/* Very small phones: "Impossible" needs a few more pixels. */
@media (width < 400px) {
  .levels { --gap: var(--space-1); }
  .level { padding-inline: 0; }
}

/* People who ask their device for less motion get no movement at all. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
