/* =====================================================================
   Crease - fixed "paper craft desk" theme.
   Everything here pretends to be a physical object on a green cutting mat:
   card stock, stamped numbers, washi tape, dashed cutting guides and long
   soft shadows. No glass, no neon, no glow. The shared base.css is loaded
   (back chip + resets) but glass.css deliberately is not: this game keeps
   its own paper chrome (.c-bar, .c-btn, .c-modal and friends).
   ===================================================================== */

:root {
  --paper-hi: #fdf7e8;
  --paper: #f4e9d5;
  --paper-lo: #e6d7ba;
  --paper-line: #cbb99a;
  --ink: #35302a;
  --ink-soft: #6d6456;
  --stamp: #ac3d24;
  --mat-a: #35594a;
  --mat-b: #24402f;
  --mat-c: #1a3125;
  --mat-line: rgba(198, 232, 208, .085);
  --tape: rgba(228, 210, 160, .5);

  --font-body: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --font-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;

  /* Base scale: the width of one player sheet. Every size on the mat derives
     from it. It grows with viewport width (7.4vw) so the game gets properly
     big on large screens, but the vh term caps it so the whole stack —
     rival hand, board, table, your hand — still fits one screen height with
     no scrollbar on shorter windows. 140px is the "silly-big" ceiling. */
  --u: clamp(46px, min(7.4vw, calc((100vh - 230px) / 5.6)), 140px);
}

/* ---------- The cutting mat ---------- */
body.p-page {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-color: var(--mat-b);
  background-image:
    radial-gradient(120% 70% at 50% -18%, rgba(255, 255, 255, .10), transparent 62%),
    repeating-linear-gradient(0deg, var(--mat-line) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, var(--mat-line) 0 1px, transparent 1px 26px),
    radial-gradient(90% 60% at 50% 118%, rgba(0, 0, 0, .42), transparent 72%),
    linear-gradient(180deg, var(--mat-a), var(--mat-b) 62%, var(--mat-c));
  background-attachment: fixed;
}
body.p-page *,
body.p-page *::before,
body.p-page *::after { box-sizing: border-box; }

.p-app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: none;
}

/* ---------- Top bar: a strip of card stock taped down ---------- */
.c-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px clamp(12px, 3vw, 26px) 11px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--paper-hi), var(--paper) 58%, var(--paper-lo));
  border-bottom: 1px solid rgba(122, 100, 68, .38);
  box-shadow: 0 8px 22px rgba(8, 18, 12, .40), inset 0 1px 0 rgba(255, 255, 255, .8);
}
/* Two scraps of washi tape holding the strip to the mat. */
.c-bar::before,
.c-bar::after {
  content: "";
  position: absolute;
  top: -6px;
  width: 68px;
  height: 19px;
  background: var(--tape);
  border-left: 1px solid rgba(255, 255, 255, .35);
  border-right: 1px solid rgba(255, 255, 255, .35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
  pointer-events: none;
}
.c-bar::before { left: 7%; transform: rotate(-2.6deg); }
.c-bar::after { right: 8%; transform: rotate(1.9deg); }

.c-bar__brand { display: flex; align-items: center; gap: 9px; }
.c-bar__brand svg { display: block; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .8)); }
.c-bar__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(19px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -.01em;
  color: #2f2a23;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .7);
}
.c-bar__stats { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.stat {
  font-size: 11.5px;
  letter-spacing: .02em;
  color: var(--ink-soft);
}
.stat b {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.c-bar__controls { display: flex; align-items: center; gap: 6px; margin-left: auto; }

/* Buttons read as small paper tabs with a hard bottom edge. */
.c-btn {
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  padding: 6px 12px;
  border-radius: 3px;
  color: #3c352b;
  background: linear-gradient(180deg, #fffdf4, #f0e4cc);
  border: 1px solid rgba(122, 100, 68, .45);
  box-shadow: 0 2px 0 rgba(122, 100, 68, .22), 0 4px 10px rgba(10, 20, 14, .18);
  cursor: pointer;
  transition: transform .06s ease, box-shadow .12s ease, filter .12s ease;
}
.c-btn:hover { filter: brightness(1.03); }
.c-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(122, 100, 68, .22); }
.c-btn:focus-visible { outline: 2px solid #7f5c33; outline-offset: 2px; }
.c-btn--primary {
  color: #fdf4e4;
  background: linear-gradient(180deg, #b2482c, #8f3320);
  border-color: #6d2715;
  box-shadow: 0 2px 0 #5c1f10, 0 4px 12px rgba(60, 12, 4, .3);
  text-shadow: 0 1px 0 rgba(0, 0, 0, .3);
}

/* ---------- Mat ---------- */
.p-mat {
  width: min(96vw, calc(var(--u) * 11.4 + 32px));
  margin: 0 auto;
  padding: clamp(8px, calc(var(--u) * .09), 14px) 0 calc(18px + var(--u) * .2);
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, calc(var(--u) * .06), 10px);
}
/* Equal spacers centre the table in whatever height is left over, and shrink to
   nothing (rather than clipping the top) when the board is taller than the
   window. */
.p-mat::before,
.p-mat::after { content: ""; flex: 1 1 0; min-height: 0; }

/* ---------- One side of the table ---------- */
.p-side { display: flex; flex-direction: column; gap: max(3px, calc(var(--u) * .025)); }
.p-side__head {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-height: max(17px, calc(var(--u) * .15));
  padding: 0 2px;
}
.p-side__tag {
  font-size: max(9px, calc(var(--u) * .072));
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(210, 234, 216, .5);
}
.p-side__score {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: max(13px, calc(var(--u) * .115));
  font-weight: 700;
  color: #fdf4e0;
  font-variant-numeric: tabular-nums;
}
.p-side__score small { font-size: .78em; font-weight: 600; opacity: .55; }
.p-side__score.is-lead { color: #ffd98a; }
.p-foot {
  font-size: max(10.5px, calc(var(--u) * .085));
  color: rgba(210, 234, 216, .45);
  white-space: nowrap;
}

/* ---------- Hands ---------- */
.p-hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(2px, calc(var(--u) * .06), 8px);
  padding: 4px 0 2px;
}
.p-hand--foe { padding: 1px 0 0; gap: clamp(2px, calc(var(--u) * .045), 7px); }

/* ---------- A sheet ---------- */
.p-sheet {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  max-width: var(--u);
  aspect-ratio: 5 / 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: max(3px, calc(var(--u) * .03)) max(2px, calc(var(--u) * .02)) max(2px, calc(var(--u) * .02));
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  color: var(--ink);
  background: linear-gradient(180deg, #fdf8ec, #f1e5ce);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tint) 52%, #fdf8ec),
    color-mix(in srgb, var(--tint) 24%, #eee1c7));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .75),
    inset 0 0 0 1px rgba(255, 255, 255, .35),
    0 0 0 1px rgba(108, 92, 64, .30),
    0 3px 0 rgba(18, 34, 24, .16),
    0 9px 16px rgba(8, 18, 12, .34);
  transform: rotate(var(--rot, 0deg));
  transition: transform .16s cubic-bezier(.2, .8, .3, 1), box-shadow .16s ease, filter .16s ease;
}
/* A whisper of paper grain over every sheet. */
.p-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: .5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='48' height='48' filter='url(%23n)' opacity='.16'/%3E%3C/svg%3E");
}
.p-sheet__n {
  font-family: var(--font-mono);
  font-size: max(13px, calc(var(--u) * .2));
  font-weight: 700;
  line-height: 1;
  color: var(--stamp);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
.p-sheet__art {
  width: 78%;
  display: grid;
  place-items: center;
  margin: 1px 0;
}
.p-sheet__art svg { width: 100%; height: auto; display: block; }
.p-sheet__label {
  font-size: max(6px, calc(var(--u) * .055));
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: rgba(60, 52, 40, .55);
}
.p-sheet:hover,
.p-sheet:focus-visible {
  transform: translateY(calc(var(--u) * -.08)) rotate(0deg);
  filter: brightness(1.04);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 0 0 1px rgba(90, 74, 48, .45),
    0 5px 0 rgba(18, 34, 24, .14),
    0 16px 24px rgba(6, 16, 10, .44);
  z-index: 4;
}
.p-sheet:focus-visible { outline: 2px solid #ffd98a; outline-offset: 2px; }
.p-sheet:active { transform: translateY(calc(var(--u) * -.035)) rotate(0deg); }
/* The sheet being folded in. */
.p-sheet.is-out {
  transform: translateY(calc(var(--u) * -.23)) rotate(8deg) scale(.86);
  opacity: 0;
  pointer-events: none;
}
.p-sheet.is-dead { cursor: default; }
.p-sheet.is-dead:hover { transform: rotate(var(--rot, 0deg)); filter: none; }

/* Rival sheets: same paper, smaller, not interactive. */
.p-hand--foe .p-sheet {
  max-width: max(52px, calc(var(--u) * .6));
  cursor: default;
  filter: saturate(.8) brightness(.97);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .55),
    0 0 0 1px rgba(96, 82, 58, .26),
    0 2px 0 rgba(18, 34, 24, .14),
    0 6px 10px rgba(8, 18, 12, .26);
}
.p-hand--foe .p-sheet__label { display: none; }
.p-hand--foe .p-sheet__n { font-size: max(10px, calc(var(--u) * .135)); }
.p-hand--foe .p-sheet:hover { transform: rotate(var(--rot, 0deg)); filter: saturate(.8) brightness(.97); }

/* Shape palettes. Every piece of paper carries data-shape, so a sheet, a
   crease card and a folded card all draw from the same four colours. */
[data-shape="crane"] { --tint: #b9cfba; --f0: #eef6ec; --f1: #cfe0cd; --f2: #b0c7b0; --shape-ink: #5f8068; }
[data-shape="boat"]  { --tint: #b6c9dd; --f0: #e7f0f9; --f1: #c3d6e7; --f2: #a2bbd2; --shape-ink: #5b7791; }
[data-shape="frog"]  { --tint: #c6d9a9; --f0: #eef6d8; --f1: #d2e3b2; --f2: #b3c98d; --shape-ink: #6b8347; }
[data-shape="star"]  { --tint: #ecd9a6; --f0: #fcf2d2; --f1: #efdca9; --f2: #dcc184; --shape-ink: #a08441; }

/* ---------- The table ---------- */
.p-table {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(6px, calc(var(--u) * .16), 24px);
  padding: 2px 0 0;
}

/* An empty slot: a dashed cutting guide on the mat. */
.p-slot {
  position: relative;
  justify-self: center;
  width: max(60px, var(--u));
  aspect-ratio: 5 / 6;
  margin-bottom: max(15px, calc(var(--u) * .12));
  display: grid;
  place-items: center;
  border: 1.5px dashed rgba(206, 234, 212, .26);
  border-radius: 4px;
  background: rgba(8, 24, 16, .16);
  transition: border-color .2s ease, background .2s ease;
}
.p-slot.is-live { border-color: rgba(255, 224, 150, .55); background: rgba(255, 216, 138, .07); }
.p-slot__cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: min(-15px, calc(var(--u) * -.12));
  text-align: center;
  font-size: max(8px, calc(var(--u) * .062));
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(206, 234, 212, .34);
}

/* The committed sheet, face down then flipped. */
.p-fold {
  position: absolute;
  inset: 0;
  perspective: 700px;
  animation: pDrop .26s cubic-bezier(.2, .9, .3, 1.1) both;
}
.p-fold__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform .46s cubic-bezier(.25, .8, .3, 1);
}
.p-fold.is-open .p-fold__inner { transform: rotateY(180deg); }
.p-fold__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 3px;
  border-radius: 3px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .7),
    0 0 0 1px rgba(108, 92, 64, .32),
    0 5px 12px rgba(6, 16, 10, .38);
}
/* The back of a sheet: paper with the two crease lines printed on it. */
.p-fold__back {
  background: linear-gradient(180deg, #fdf8ec, #eee1c7);
  background-image:
    linear-gradient(45deg, transparent calc(50% - .7px), rgba(150, 130, 100, .4) 50%, transparent calc(50% + .7px)),
    linear-gradient(-45deg, transparent calc(50% - .7px), rgba(150, 130, 100, .4) 50%, transparent calc(50% + .7px)),
    linear-gradient(180deg, #fdf8ec, #eee1c7);
}
.p-fold__front {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #fdf8ec, #f1e5ce);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tint) 52%, #fdf8ec),
    color-mix(in srgb, var(--tint) 24%, #eee1c7));
}
.p-fold__n {
  font-family: var(--font-mono);
  font-size: max(13px, calc(var(--u) * .195));
  font-weight: 700;
  line-height: 1;
  color: var(--stamp);
}
.p-fold__art { width: 74%; }
.p-fold__art svg { width: 100%; height: auto; display: block; }
.p-fold__tag {
  font-size: max(5.5px, calc(var(--u) * .05));
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(60, 52, 40, .55);
}

/* ---------- The crease card in the middle ---------- */
.p-centre { display: flex; flex-direction: column; align-items: center; gap: clamp(5px, calc(var(--u) * .055), 9px); min-width: 0; }
.p-crease {
  position: relative;
  width: max(124px, calc(var(--u) * 1.35));
  aspect-ratio: 5 / 6.1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(8px, calc(var(--u) * .06)) max(8px, calc(var(--u) * .062)) max(9px, calc(var(--u) * .07));
  border-radius: 4px;
  color: var(--ink);
  background: linear-gradient(180deg, #fdf8ec, #efe2ca);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 0 0 1px rgba(108, 92, 64, .32),
    0 3px 0 rgba(18, 34, 24, .14),
    0 12px 22px rgba(6, 16, 10, .4);
  transform: rotate(-.7deg);
}
/* A dashed cutting guide just inside the edge. */
.p-crease::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(140, 120, 88, .38);
  border-radius: 2px;
  pointer-events: none;
}
.p-crease__top {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  position: relative;
  z-index: 1;
}
.p-crease__kicker {
  font-size: max(7.5px, calc(var(--u) * .062));
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: rgba(70, 60, 46, .6);
  padding-top: max(3px, calc(var(--u) * .024));
}
/* Rubber-stamped prize. */
.p-stamp {
  flex: none;
  width: max(30px, calc(var(--u) * .24));
  height: max(30px, calc(var(--u) * .24));
  display: grid;
  place-items: center;
  border: 2px solid rgba(172, 61, 36, .62);
  border-radius: 50%;
  color: var(--stamp);
  font-family: var(--font-mono);
  font-size: max(15px, calc(var(--u) * .135));
  font-weight: 700;
  line-height: 1;
  transform: rotate(9deg);
  opacity: .92;
}
.p-crease__art {
  width: 74%;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .7));
}
.p-crease__art svg { width: 100%; height: auto; display: block; }
.p-crease__name {
  position: relative;
  z-index: 1;
  font-family: var(--font-serif);
  font-size: max(16px, calc(var(--u) * .16));
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #40382c;
  line-height: 1;
}
.p-crease__worth {
  position: relative;
  z-index: 1;
  font-size: max(8.5px, calc(var(--u) * .072));
  font-weight: 600;
  letter-spacing: .06em;
  color: rgba(70, 60, 46, .66);
  padding-bottom: 1px;
}

/* ---------- The open board of orders ---------- */
/* A laid-out strip of order slips between the rival hand and the table. Small
   enough never to shove the mat, but every fold and value stays readable. */
.p-board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: clamp(4px, calc(var(--u) * .07), 10px);
  padding: 2px 4px 4px;
}
.p-order {
  position: relative;
  flex: 0 0 auto;
  width: max(34px, calc(var(--u) * .55));
  aspect-ratio: 5 / 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 3px 2px;
  border: 0;
  border-radius: 3px;
  cursor: default;
  color: var(--ink);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tint) 46%, #fdf8ec),
    color-mix(in srgb, var(--tint) 20%, #eee1c7));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .7),
    0 0 0 1px rgba(108, 92, 64, .3),
    0 2px 0 rgba(18, 34, 24, .14),
    0 6px 12px rgba(8, 18, 12, .28);
  transition: transform .14s cubic-bezier(.2, .8, .3, 1), box-shadow .14s ease, filter .14s ease, opacity .2s ease;
}
.p-order::after { /* dashed cut line, like the crease card */
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(140, 120, 88, .34);
  border-radius: 2px;
  pointer-events: none;
}
.p-order__art {
  width: 66%;
  position: relative;
  z-index: 1;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .6));
}
.p-order__art svg { width: 100%; height: auto; display: block; }
.p-order__val {
  position: relative;
  z-index: 1;
  font-family: var(--font-mono);
  font-size: max(11px, calc(var(--u) * .13));
  font-weight: 700;
  line-height: 1;
  color: var(--stamp);
  text-shadow: 0 1px 0 rgba(255, 255, 255, .6);
}
/* The order being contested this round. */
.p-order.is-active {
  transform: translateY(calc(var(--u) * -.07)) scale(1.06);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .85),
    0 0 0 2px rgba(255, 214, 138, .8),
    0 6px 0 rgba(18, 34, 24, .12),
    0 14px 22px rgba(6, 16, 10, .44);
  z-index: 5;
}
/* A claimed order: folded away to a stub. */
.p-order.is-done {
  cursor: default;
  opacity: .32;
  filter: saturate(.4);
  transform: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 0 0 1px rgba(108, 92, 64, .22);
}
.p-order.is-done::before { /* a crease struck through it */
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 50%;
  height: 2px;
  z-index: 2;
  background: rgba(120, 60, 40, .55);
  transform: rotate(-18deg);
}

/* ---------- Verdict line ---------- */
.p-verdict {
  margin: 0;
  min-height: max(30px, calc(var(--u) * .24));
  max-width: 26ch;
  text-align: center;
  font-size: max(12px, calc(var(--u) * .105));
  line-height: 1.35;
  color: rgba(222, 238, 226, .8);
}
.p-verdict b { color: #ffe1a0; }
.p-verdict.is-you b { color: #a5e6b6; }
.p-verdict.is-them b { color: #ffb6a0; }
.p-verdict.is-flash { animation: pFlash .5s ease; }

/* ---------- Won folds, laid out as paper chips ---------- */
/* A strip height that scales with the sheets, so chips landing after a round
   never shove the table. */
.p-pile {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  min-height: max(21px, calc(var(--u) * .16));
}
.p-chip {
  min-width: max(17px, calc(var(--u) * .13));
  height: max(21px, calc(var(--u) * .16));
  padding: 0 max(3px, calc(var(--u) * .028));
  display: grid;
  place-items: center;
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: max(9.5px, calc(var(--u) * .078));
  font-weight: 700;
  line-height: 1;
  color: rgba(48, 40, 30, .88);
  background: linear-gradient(180deg, #fdf8ec, #f1e5ce);
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--tint) 58%, #fdf8ec),
    color-mix(in srgb, var(--tint) 26%, #eee1c7));
  box-shadow: 0 0 0 1px rgba(102, 88, 62, .34), 0 2px 4px rgba(0, 0, 0, .28);
  animation: pPop .32s cubic-bezier(.2, .9, .3, 1.3) both;
}
.p-chip.is-you { color: #3a2c1c; }

/* ---------- Paper modals ---------- */
.c-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.c-modal[hidden] { display: none; }
.c-modal__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 20, 14, .62);
  cursor: pointer;
}
.c-modal__panel {
  position: relative;
  z-index: 1;
  margin: auto;
  width: min(94vw, 520px);
  color: var(--ink);
  background: linear-gradient(180deg, #fdf8ec, #f2e6d0);
  border-radius: 3px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .8),
    0 0 0 1px rgba(118, 98, 68, .38),
    0 30px 70px rgba(0, 0, 0, .52);
  animation: pSheet .26s ease-out both;
}
/* A strip of tape holding the sheet to the mat. */
.c-modal__panel::before {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  width: 82px;
  height: 20px;
  transform: translateX(-50%) rotate(-1.6deg);
  background: var(--tape);
  border-left: 1px solid rgba(255, 255, 255, .35);
  border-right: 1px solid rgba(255, 255, 255, .35);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
  pointer-events: none;
}
.p-rules { width: min(94vw, 600px); }
.c-modal__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(140, 118, 84, .28);
}
.c-modal__head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  letter-spacing: -.01em;
  color: #322c24;
}
.c-modal__x {
  margin-left: auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 2px;
  border: 1px solid rgba(122, 100, 68, .4);
  background: linear-gradient(180deg, #fffdf4, #f0e4cc);
  color: #4a4236;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.c-modal__x:hover { filter: brightness(1.03); }
/* The author display:grid above would beat the [hidden] attribute on its own. */
.c-modal__x[hidden] { display: none; }
.c-modal__body { padding: 12px 20px 4px; font-size: 13px; line-height: 1.55; color: #443c31; }
.c-modal__body h3 {
  margin: 14px 0 5px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: rgba(70, 60, 46, .62);
}
.c-modal__body ul { margin: 0 0 8px; padding-left: 16px; }
.c-modal__body li { margin-bottom: 4px; }
.c-modal__body li::marker { color: rgba(172, 61, 36, .6); }
.c-modal__body b { color: #2d2820; }
.c-modal__body kbd {
  padding: 0 4px;
  border-radius: 2px;
  border: 1px solid rgba(122, 100, 68, .4);
  background: rgba(255, 255, 255, .55);
  font-family: var(--font-mono);
  font-size: 11px;
}
.c-modal__lead { margin: 0 0 10px; font-size: 13px; }
.c-modal__note {
  margin: 12px 0 2px;
  font-size: 11px;
  color: rgba(80, 68, 52, .72);
}
.c-modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 18px 14px;
}

/* ---------- Flow contents ---------- */
.p-flow-lead { margin: 0 0 12px; font-size: 13px; }
.p-end { text-align: center; padding: 4px 0 2px; }
.p-end__big {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  color: #332d25;
  margin: 0 0 4px;
}
.p-end__sub { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-soft); }
.p-end__stats { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.p-end__stat {
  min-width: 88px;
  padding: 7px 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .5);
  border: 1px dashed rgba(122, 100, 68, .38);
}
.p-end__stat b { display: block; font-family: var(--font-mono); font-size: 17px; line-height: 1.2; }
.p-end__stat span { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); }

/* ---------- Toast ---------- */
.c-toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  z-index: 80;
  padding: 8px 16px;
  transform: translateX(-50%) rotate(-1deg);
  border-radius: 3px;
  background: linear-gradient(180deg, #fdf7e8, #efe2c9);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: 0 0 0 1px rgba(122, 100, 68, .38), 0 12px 26px rgba(0, 0, 0, .42);
  animation: pToast .22s ease-out both;
}
.c-toast[hidden] { display: none; }

/* ---------- Motion ---------- */
@keyframes pSheet {
  from { opacity: 0; transform: translateY(10px) rotate(-1.4deg); }
}
@keyframes pDeal {
  from { opacity: 0; transform: translateY(-18px) rotate(-6deg); }
  to { opacity: 1; transform: rotate(-.7deg); }
}
@keyframes pDrop {
  from { opacity: 0; transform: translateY(-14px) scale(.9); }
}
@keyframes pPop {
  from { transform: scale(.4); opacity: 0; }
}
@keyframes pToast {
  from { opacity: 0; transform: translate(-50%, 10px) rotate(-1deg); }
}
@keyframes pFlash {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}
.p-crease.is-dealt { animation: pDeal .34s cubic-bezier(.2, .8, .3, 1.05) both; }

/* ---------- Responsive ---------- */
/* Large screens are handled fluidly by --u; these only shave things down for
   narrow phones where sheets get squeezed below the base scale anyway. */
@media (max-width: 640px) {
  /* The score number already carries this; on a phone the mat needs the room. */
  .p-foot { display: none; }
  .p-sheet { padding: 2px 1px; }
  .p-sheet__label { font-size: 5.5px; letter-spacing: .06em; }
  .p-sheet__art { width: 82%; }
}

@media (max-width: 470px) {
  .c-bar { gap: 8px; padding: 8px 10px 9px; }
  .c-bar__title { font-size: 18px; }
  .c-bar__stats { gap: 9px; }
  .stat { font-size: 10.5px; }
  .c-bar__controls { gap: 4px; }
  .c-btn { padding: 5px 8px; font-size: 11px; }
  /* Ten chips plus a score no longer fit beside a squeezed fold. */
  .p-pile { display: none; }
  .c-modal__body { padding: 10px 14px 4px; }
  .c-modal__head { padding: 12px 14px 9px; }
  .c-modal__foot { padding: 8px 14px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .p-sheet,
  .p-order,
  .p-crease,
  .p-chip,
  .c-modal__panel,
  .c-toast,
  .p-fold {
    animation: none;
    transition: none;
  }
  .p-crease.is-dealt { animation: none; }
  .p-fold__inner { transition: none; }
  .p-verdict.is-flash { animation: none; }
}
