:root {
  /* Dona Filó's house: paw prints on a wine-red Persian rug, a walnut card table, a deep teal felt board, slate panels with a lighter edge, chips blue, mult red, money gold */
  --felt: #12282c;
  --cloth: #422234;
  --ink: #0c1517;
  --panel: #2a3a40;
  --panel-deep: #1d2a2f;
  --edge: #4b6168;
  --muted: #c3cecd;
  --soft: #eef1ec;
  --gold: #f3b958;
  --orange: #f08a24;
  --red: #fe5f55;
  --blue: #1aa3ff;
  --green: #35bd86;
  --grey: #4b6168;
  --card: #f4ecd8;
  --card-ink: #2a2730;
  --card-red: #e2463c;
  --card-well: #e3d8bd;
  --common: #1aa3ff;
  --uncommon: #35bd86;
  --rare: #fe5f55;
  --legendary: #b26cbb;
  --boss: #f3b958;
  /* Kinds of board, as in Balatro: small blue, big orange, boss purple */
  --small: #1aa3ff;
  --big: #f08a24;
  --display: 'Jersey 10', 'Courier New', monospace;
  --body: 'Jersey 10', 'Courier New', monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background-color: var(--cloth); }
/* Feel like an app on phones: no rubber-band bounce, no text selection or long-press callouts while playing, and no
   double-tap zoom on controls (so taps register straight away). Inputs stay selectable. */
html, body:not(.admin) { overscroll-behavior: none; }
body:not(.admin) { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea { -webkit-user-select: text; user-select: text; }
button, a, .slot { touch-action: manipulation; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: #f4efe2;
  font-family: var(--body);
  /* Jersey 10 is a single-weight, condensed pixel face: no faked bold, and sized to Rubik's proportions, which every
     layout here was tuned to */
  font-synthesis: none;
  font-size-adjust: .52;
  letter-spacing: .4px;
  /* Light text gets a soft dark shadow so its pixels hold up over the cloth; cream cards turn it off */
  text-shadow: 0 1px 0 rgba(0, 0, 0, .55);
  /* Transparent so the tablecloth canvas (#bg) shows; html keeps the cloth colour underneath */
  background: transparent;
  -webkit-tap-highlight-color: transparent;
}
/* The background (tablecloth.js: paw prints on a Persian rug on menus and in the shop, the card table on boards), then a
   vignette (softer over the rug, which is lighter than the table) and CRT scanlines over everything. */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; image-rendering: pixelated; }
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 160px rgba(0, 0, 0, .4);
}
body:has(#app.screen-play)::before { box-shadow: inset 0 0 160px rgba(0, 0, 0, .6); }
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, .05) 0 1px, transparent 1px 3px);
}
img[src$=".svg"] { image-rendering: pixelated; }
/* Dark text on light pills, tags and cards: no shadow (the body's shadow is for light text) */
.card,
.ante-badge,
.sticker,
.filter.on,
.panel.offer.t-relic,
.relic-stack,
.rung-tag,
.mini-seal,
.seal-tag,
.last-tag,
.joker-tag,
.lv-tag,
.mini-up,
.selected-tag,
.next-card,
.mini-card,
.pip.now,
.chip.done,
.chip.hot,
.cell-up,
.forged,
.post input,
.signin input,
.move-btn.sel,
.move-btn.sel .move-glyph,
.sheet-relic,
.name-row input,
.seg button.on { text-shadow: none; }
button { font: inherit; color: inherit; }
h1, h2, p { margin: 0; }
img { display: block; }

.px { font-family: var(--display); font-weight: 400; font-synthesis: none; letter-spacing: .3px; }
.gold { color: var(--gold); }
.muted { color: var(--muted); }
.sub { font-size: 14px; font-weight: 500; color: var(--soft); line-height: 1.4; }
.center { text-align: center; }
.label { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .5px; }
.h1 { font-size: 32px; line-height: 1; text-shadow: 0 3px 0 var(--ink); }
.h2 { font-size: 22px; }
.sr-only { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(22px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.screen { display: flex; flex-direction: column; gap: 12px; flex: 1; }

/* ---------- Building blocks ---------- */
.panel {
  background: var(--panel);
  border: 3px solid var(--edge);
  border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink);
}
.btn {
  font-family: var(--display);
  font-weight: 400;
  font-synthesis: none;
  letter-spacing: .5px;
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink);
  cursor: pointer;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  font-size: 18px;
  transition: transform .06s, box-shadow .06s;
  text-decoration: none;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--ink); }
.btn:disabled { filter: brightness(.5) saturate(.6); cursor: default; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.b-orange { background: var(--orange); }
.b-red { background: var(--red); }
.b-blue { background: var(--blue); }
.b-green { background: var(--green); }
.b-grey { background: var(--grey); }
.xl { min-height: 64px; font-size: 28px; }
.lg { min-height: 54px; font-size: 21px; }
.md { min-height: 50px; font-size: 19px; }
.small { min-height: 36px; font-size: 15px; padding: 0 8px; box-shadow: 0 3px 0 var(--ink); }
.icon { width: 46px; height: 46px; padding: 0; flex-shrink: 0; }

.card {
  width: 100%;
  height: 100%;
  background: var(--card);
  color: var(--card-ink);
  border: 3px solid #1a1a22;
  border-radius: 9px;
  box-shadow: 0 4px 0 #1a1a22;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-weight: 400;
  font-synthesis: none;
  line-height: .95;
}
.card.r { color: var(--card-red); }
.card.hit { border-color: var(--gold); box-shadow: 0 0 0 3px #1a1a22, 0 7px 0 #1a1a22; }
/* A face-down card (The Fog) and a card whose suit a boss has switched off (The Monochrome) */
.card.back {
  color: rgba(255, 255, 255, .7);
  background: repeating-linear-gradient(45deg, #3a3f6b 0 6px, #2c3058 6px 12px);
}
.card.debuffed { opacity: .55; filter: grayscale(.8); }

.avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 8px; border: 2px solid var(--ink);
  background: var(--red);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.avatar.sm { width: 30px; height: 30px; font-size: 15px; background: var(--grey); border-radius: 7px; }
.avatar.lg { width: 44px; height: 44px; font-size: 22px; border-width: 3px; border-radius: 10px; }
.ante-badge {
  font-size: 14px; color: #2a1d00; background: var(--gold);
  border: 2px solid var(--ink); border-radius: 6px; padding: 0 6px; white-space: nowrap;
}

.rar-common { --rar: var(--common); }
.rar-uncommon { --rar: var(--uncommon); }
.rar-rare { --rar: var(--rare); }
.rar-legendary { --rar: var(--legendary); }
.rar-boss { --rar: var(--boss); }
.k0 { --k: var(--small); }
.k1 { --k: var(--big); }
.k2 { --k: var(--boss); }
/* Relics look like little cards, as in the concept: a cream well on a white rim, the rarity as an inner ring */
.relic-tile {
  display: flex; width: 100%; aspect-ratio: 1;
  border-radius: 10px; border: 3px solid #fff;
  background: var(--card-well); overflow: hidden;
  box-shadow: inset 0 0 0 2px var(--rar), 0 4px 0 var(--ink);
}
.relic-tile img { width: 100%; height: 100%; object-fit: contain; }
.relic-tile.big { width: 96px; flex-shrink: 0; }

/* ---------- Main menu ---------- */
.topline { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.profile {
  display: flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px;
  color: #fff; cursor: pointer; text-align: left; min-height: 48px;
}
.profile-text { display: flex; flex-direction: column; }
.profile-text .px { font-size: 16px; }
.profile-text small { font-size: 13px; color: var(--muted); }
.hero { display: flex; justify-content: center; padding-top: 10px; position: relative; }
.hero-board {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px;
  width: 214px; padding: 12px; transform: rotate(-5deg);
  background: rgba(0, 0, 0, .25); border: 3px solid rgba(0, 0, 0, .35); border-radius: 18px;
}
.hero-cell { height: 74px; transform: rotate(var(--tilt)); font-size: 26px; }
.hero-cell .suit { font-size: 20px; }
.sticker {
  position: absolute; right: calc(50% - 150px); top: 2px;
  background: var(--gold); color: #2a1d00; border: 3px solid var(--ink); border-radius: 8px;
  padding: 2px 10px; font-size: 20px; transform: rotate(10deg); box-shadow: 0 4px 0 var(--ink);
}
.title-block { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.logo {
  font-size: 60px; line-height: .95; letter-spacing: 1px;
  text-shadow: 0 5px 0 var(--red), 0 9px 0 var(--ink); transform: rotate(-2deg);
}
.tagline { font-size: 15px; font-weight: 500; color: var(--soft); }
.hero-lady { position: absolute; left: calc(50% - 168px); bottom: -14px; width: 104px; height: 104px; transform: rotate(-4deg); filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .35)); }
.best-run { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.best-run .label { flex: 1; font-size: 14px; }
.best-score { font-size: 20px; }
.menu-actions { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding-top: 8px; }
/* NEW RUN and, once a second deck is unlocked, the deck dropdown beside it */
.new-run { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.menu-deck { display: flex; min-width: 0; }
.menu-deck select {
  flex: 1; min-width: 0; padding: 0 10px; border-radius: 10px; border: 3px solid var(--ink);
  background: rgba(0, 0, 0, .3); color: #fff; font-family: var(--display); font-size: 18px; cursor: pointer;
}
.menu-deck select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.menu-deck-desc { margin-top: -4px; }
.unlock { display: flex; flex-direction: column; gap: 4px; padding: 10px 14px; text-align: center; }

/* ---------- Leaderboard ---------- */
.head { display: flex; align-items: center; gap: 10px; }
.head-text { display: flex; flex-direction: column; gap: 4px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filter {
  flex-shrink: 0; min-height: 36px; padding: 0 12px; border-radius: 8px; border: 2px solid var(--ink);
  background: rgba(0, 0, 0, .3); color: var(--soft); font-size: 15px; cursor: pointer;
}
.filter.on { background: var(--card); color: #1a1a22; }
.period-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.period-tabs .filter { padding: 0 4px; }
.period-tabs .filter.on { background: var(--gold); }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; align-items: end; padding-top: 6px; }
.podium-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.podium-name { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-step {
  width: 100%; border-radius: 10px 10px 4px 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; text-align: center;
}
.podium-rank { font-size: 36px; line-height: 1; text-shadow: 0 3px 0 var(--ink); }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; background: rgba(0, 0, 0, .28); border-radius: 10px; }
.lb-rank { width: 24px; font-size: 17px; color: var(--muted); }
.lb-who { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.lb-who b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-who small { font-size: 13px; color: var(--muted); }
.lb-score { font-size: 17px; min-width: 60px; text-align: right; }
.you-row { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--orange); margin-top: auto; transform: rotate(-1deg); }
.you-row .lb-who small { color: #fff1e0; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 16px; text-align: center; }
.empty-state .px { font-size: 24px; }

/* ---------- Shop ---------- */
.shop-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.offers {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -14px; padding: 4px 14px 12px; scrollbar-width: none;
}
.offer-slot { flex: 0 0 168px; display: flex; min-width: 0; transform: rotate(var(--tilt)); scroll-snap-align: start; }
/* Offers come grouped by type: a thin rule with the group's name opens each group */
.offer-divider { flex: 0 0 16px; display: flex; align-items: center; gap: 8px; font-size: 13px; line-height: 1; color: var(--muted); letter-spacing: .5px; }
.offer-divider::after { content: ''; flex: 1; height: 2px; background: rgba(255, 255, 255, .14); border-radius: 1px; }
/* The shop's own relics: drag one along the strip to reorder them */
.shop-relics .relic-slot[data-id] { touch-action: none; -webkit-user-select: none; user-select: none; }
.shop-relics img { -webkit-user-drag: none; }
.shop-relics .relic-slot.dragging { visibility: hidden; }
.shop-relics .relic-slot.droptarget { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.shop-relics .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.relic-ghost { animation: none; }
/* Shop offers are cards that bob gently, one look per kind of item. Relics, which take a slot, are cream cards with a
   white rim, like the relic cards in the concept. Every other kind is a card in its own colour (see .t-cell and on),
   with its art in a well of its own shape (round for seals, square for cell upgrades) drawing what it changes. Tags
   under the name give the kind and the rarity. Tapping a card opens its sheet, where it's bought. */
.panel.offer {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; padding: 8px;
  font: inherit; text-align: left; cursor: pointer;
  background: var(--card); color: var(--card-ink); border: 3px solid #fff; box-shadow: 0 5px 0 var(--ink);
  animation: card-bob 4.5s ease-in-out infinite;
}
.panel.offer:not(.t-relic) {
  color: #fff; border-color: var(--type);
  background: linear-gradient(170deg, color-mix(in srgb, var(--type) 34%, var(--panel-deep)), color-mix(in srgb, var(--type) 14%, var(--panel-deep)));
}
.offer-slot:nth-child(2) .offer { animation-delay: -.9s; } .offer-slot:nth-child(3) .offer { animation-delay: -1.8s; }
.offer-slot:nth-child(4) .offer { animation-delay: -2.7s; } .offer-slot:nth-child(5) .offer { animation-delay: -3.6s; }
.relic-slot:not(.empty) { animation: card-bob 5s ease-in-out infinite; }
.relic-slot:nth-child(even) { animation-delay: -2.5s; }
@keyframes card-bob { 50% { translate: 0 -3px; } }
@media (prefers-reduced-motion: reduce) { .panel.offer, .relic-slot { animation: none; } }
.offer-art {
  position: relative; display: flex; width: 100%; aspect-ratio: 1; flex-shrink: 0;
  border-radius: 8px; border: 3px solid #d9cdb0; background: var(--card-well);
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, .08);
}
.offer:not(.t-relic) .offer-art { background: rgba(0, 0, 0, .3); border-color: rgba(255, 255, 255, .25); }
.t-seal .offer-art { border-radius: 50%; }
.t-cell .offer-art { border-radius: 2px; }
.offer-art img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; }
.offer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; }
.offer-name { min-width: 0; font-size: 18px; line-height: 1.05; overflow-wrap: break-word; hyphens: manual; }
.tile-price {
  flex-shrink: 0; padding: 1px 5px; border-radius: 4px; font-size: 15px; line-height: 18px;
  background: rgba(0, 0, 0, .75); color: var(--gold);
}
.offer.poor .tile-price { color: var(--muted); }
.offer-desc { font-size: 14px; line-height: 1.2; }
.t-relic .offer-desc { color: #4d4755; }
.offer.poor .offer-art, .offer.poor .offer-head, .offer.poor .offer-tags, .offer.poor .offer-desc { opacity: .55; }
/* Under the name: the kind of item as a tag in its colour, and the rarity as gems and a word, so neither relies on
   colour alone and the two never share one */
.offer-tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.type-tag {
  font-size: 15px; line-height: 1; letter-spacing: .5px; padding: 2px 6px 1px; border-radius: 4px; white-space: nowrap;
  background: var(--type); color: var(--ink); text-shadow: none;
}
.t-relic .type-tag { background: var(--card-ink); color: var(--card); }
.rar-gems { font-size: 13px; line-height: 1; letter-spacing: -1px; white-space: nowrap; color: var(--rar); text-shadow: 0 1px 0 var(--ink); }
.t-relic .rar-gems { text-shadow: none; filter: brightness(.85); }
.rar-gems b { font-weight: 400; letter-spacing: .5px; margin-left: 4px; }
.buy { font-size: 19px; }
.offer.poor .offer-art, .offer.poor .offer-name { opacity: .55; }
.empty-offers { padding: 14px; font-size: 14px; color: var(--soft); flex: 1; }
.section { display: flex; flex-direction: column; gap: 8px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.section-head > .px { font-size: 17px; white-space: nowrap; }
.relic-strip { display: grid; grid-template-columns: repeat(var(--cols, 6), minmax(0, 56px)); justify-content: center; gap: 8px; }
/* Two rows (see relicStrip): small enough to leave the board and the offers their room */
.relic-strip.rows2 { grid-template-columns: repeat(var(--cols), minmax(0, 44px)); gap: 6px 8px; }
.relic-stack {
  position: absolute; right: -4px; bottom: -4px; min-width: 20px; padding: 0 4px;
  background: var(--gold); color: #2a1d00; border: 2px solid var(--ink); border-radius: 6px; font-size: 14px;
}
.boss-panel {
  padding: 8px 12px; display: flex; flex-direction: column; gap: 2px;
  background: #3a2350; border-color: #1c0f29; box-shadow: 0 4px 0 #1c0f29; transform: rotate(.6deg);
}
.boss-panel .label { color: var(--boss); }
.boss-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.boss-reroll { min-height: 30px; padding: 2px 10px; font-size: 14px; gap: 4px; flex-shrink: 0; }
.boss-reroll svg { width: 14px; height: 14px; }
/* The shop's top row: the ante and the coins (buttons for the run and for interest) around the ante's boards, the next
   one raised; the boss is a button for its rule */
.ladder { display: grid; grid-template-columns: auto repeat(3, minmax(0, 1fr)) auto; gap: 6px; align-items: stretch; }
.ladder-box {
  padding: 3px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: 0 3px 0 var(--ink);
  font: inherit; color: inherit; cursor: pointer;
}
.ladder-box .px { font-size: 17px; line-height: 1.05; }
/* The run sheet: every ante's boards, the cleared ones with their score */
.run-table td small { display: block; font-size: 11px; color: var(--boss); white-space: nowrap; }
.run-table .done { color: var(--green); }
.run-table tr.past td { color: var(--muted); }
.run-table tr.on td { background: rgba(255, 255, 255, .06); }
.rung {
  position: relative; min-width: 0; padding: 4px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 3px solid var(--ink); border-radius: 10px; background: var(--panel); box-shadow: 0 3px 0 var(--ink); color: #fff; text-align: center;
}
button.rung { font: inherit; cursor: pointer; }
.rung.k2 { background: #3a2350; border-color: #1c0f29; box-shadow: 0 3px 0 #1c0f29; }
.rung.done { filter: brightness(.6) saturate(.7); }
.rung.next { padding-top: 7px; transform: translateY(-3px); outline: 2px solid var(--k); outline-offset: -1px; }
.rung-kind { font-size: 14px; line-height: 1.1; color: var(--k); }
.rung-val { font-size: 14px; line-height: 1.15; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rung.done .rung-val { color: var(--green); }
/* A boss's name can take two lines on narrow phones (the showdown has two bosses) */
.rung.k2 .rung-val { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-height: 1.05; }
.rung-tag {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%); padding: 0 5px; border: 2px solid var(--ink); border-radius: 5px;
  background: var(--k); color: var(--ink); font-size: 11px; font-weight: 700; letter-spacing: .5px; line-height: 13px;
}
.boss-panel.has-lady { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; }
.boss-panel.has-lady > :not(.ladies) { grid-column: 2; }
.ladies { grid-row: 1 / span 3; display: flex; }
.lady { width: 52px; height: 52px; }
.ladies .lady + .lady { margin-left: -14px; }
.lady-inline { width: 22px; height: 22px; vertical-align: -6px; margin-right: 4px; display: inline-block; }
.boss-name { font-size: 20px; color: #fff; }
.boss-desc { font-size: 14px; font-weight: 500; color: #ecdcf7; line-height: 1.35; }
.next { flex-direction: column; gap: 0; line-height: 1.05; }
.next-sub { font-family: var(--body); font-size: 13px; font-weight: 700; letter-spacing: .3px; opacity: .9; }
.relic-slot {
  position: relative; padding: 0; border: 0; background: none; cursor: pointer;
  transform: rotate(var(--tilt)); aspect-ratio: 1;
}
/* Items without a picture (cell upgrades, line upgrades, seals, patterns): their glyph on a tint of their type */
.glyph-art {
  display: flex; align-items: center; justify-content: center; width: 100%; height: 100%;
  font: 700 46px/1 var(--body); color: var(--type); text-shadow: 0 3px 0 var(--ink);
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--type) 28%, transparent), transparent 70%);
}
.relic-tile .glyph-art { font-size: 26px; }
.relic-tile.big .glyph-art { font-size: 52px; }
.type-cell, .t-cell { --type: #ff9a3d; }
.type-line, .t-line { --type: #4ea8ff; }
.type-hand, .t-hand { --type: #3de0d0; }
.type-seal, .t-seal { --type: #d58cff; }
.type-pattern, .t-pattern { --type: #47d18c; }
.type-trick, .t-trick { --type: #ff6f86; }
/* What an item changes, drawn in its art (see itemDrawing): a 3x3 board, or little cards. Sized from --art, the art's
   width where the layout sets it. */
.item-art { --a: var(--art, 120px); position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.relic-tile.drawn { --art: 96px; background: var(--panel-deep); }
.item-board { position: relative; display: flex; width: 100%; height: 100%; padding: 10%; }
.item-board svg { width: 100%; height: 100%; }
.item-board rect { fill: rgba(255, 255, 255, .16); }
.item-board .sq-lit { fill: var(--type); }
.item-board .sq-red { fill: var(--card-red); }
.item-board .sq-black { fill: var(--card-ink); stroke: var(--card); stroke-width: .7; }
.item-board .sq-card { fill: var(--card); }
.item-board text { font-size: 7px; text-anchor: middle; fill: var(--card-ink); }
.item-board text.r { fill: var(--card-red); }
.item-board line { stroke: var(--type); stroke-width: 2.6; stroke-linecap: round; }
.item-board line.pick { stroke-dasharray: 2 2.2; }
.mb-glyph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font: 700 calc(var(--a) * .2)/1 var(--body); color: var(--ink); text-shadow: none;
}
.mc {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 40%; aspect-ratio: .72; margin: 0 -5%; border-radius: 3px; border: 1px solid var(--ink);
  background: var(--card); color: var(--card-ink); box-shadow: 0 2px 0 var(--ink);
  font: calc(var(--a) * .22)/1 var(--display); letter-spacing: -1px; text-shadow: none;
}
.mc.r { color: var(--card-red); }
.mc:nth-child(1) { transform: rotate(-10deg); } .mc:nth-child(3) { transform: rotate(10deg); }
.type-seal .mc { width: 52%; margin: 0; transform: none; color: var(--muted); }
.deck .mc { margin: 0 -18%; }
.deck .mc:nth-child(1) { transform: rotate(-8deg) translateY(2px); } .deck .mc:nth-child(3) { transform: rotate(6deg); }
.mc-badge {
  position: absolute; right: -24%; bottom: -14%; width: 66%; aspect-ratio: 1; border-radius: 50%; border: 1px solid var(--ink);
  display: flex; align-items: center; justify-content: center; font: 700 calc(var(--a) * .22)/1 var(--body); font-style: normal;
  background: var(--type); color: var(--ink);
}
.mc-up { position: absolute; right: 6%; top: 4%; font: 700 calc(var(--a) * .2)/1 var(--body); font-style: normal; color: var(--type); text-shadow: 0 1px 0 var(--ink); }
/* The shop's deck button, beside the title */
/* The title gives way to the buttons beside it: "THE" goes first, then the word is cut, never overlapped; the (i)
   always stays whole next to it */
.shop-head { container-type: inline-size; }
.shop-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.shop-word { min-width: 0; overflow: hidden; text-overflow: clip; }
.shop-title .info-btn { flex-shrink: 0; margin-left: 0; }
@container (max-width: 330px) { .shop-the { display: none; } }
/* Narrow phones: the header's buttons tighten so the title stays whole */
@media (max-width: 360px) {
  .shop-head { gap: 6px; }
  .shop-head .btn { padding: 0 8px; gap: 4px; }
}
.deck-btn { padding: 0 10px; white-space: nowrap; }
.info-btn {
  width: 24px; height: 24px; margin-left: 2px; vertical-align: middle; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--muted); background: none; color: var(--muted); font: 700 15px/1 var(--body); text-shadow: none;
}
.info-btn:hover { color: #fff; border-color: #fff; }
/* The shop's board view: three rows of squares with each row's level, then the columns' levels and the diagonals' */
.board-map { display: grid; grid-template-columns: repeat(3, minmax(0, 72px)) minmax(0, 56px); gap: 6px; justify-content: center; }
.map-cell {
  aspect-ratio: 1; padding: 4px; border-radius: 8px; border: 2px dashed rgba(255, 255, 255, .25); background: rgba(0, 0, 0, .25);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #fff; font: inherit;
}
button.map-cell { cursor: pointer; border: 2px solid var(--up); background: color-mix(in srgb, var(--up) 18%, transparent); }
.map-cell .mini-up { width: 26px; height: 26px; font-size: 15px; }
.map-cell small { font-size: 12px; font-weight: 700; line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.map-line {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: 8px;
  background: rgba(0, 0, 0, .2); color: var(--muted); min-height: 44px; padding: 2px;
}
.map-line small { font-size: 11px; font-weight: 700; white-space: nowrap; }
.map-line b { font-size: 14px; }
.map-line.on { background: rgba(78, 168, 255, .2); color: #4ea8ff; box-shadow: inset 0 0 0 2px #4ea8ff; }
/* Under the board view: each hand's level */
.hand-levels { margin-top: 12px; }
.hand-levels tr.on td { color: #3de0d0; }
/* Narrow phones: the refresh button keeps its icon and price, so the title, deck and refresh fit on one line */
@media (max-width: 420px) { .refresh-word { display: none; } }
/* Sleight of Hand: cards on the board can be tapped to swap them */
.swap-card { position: relative; display: flex; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; }
.swap-card.sel .card { outline: 3px solid var(--gold); outline-offset: 2px; }
span.mini-card { position: relative; }
/* Picking where a bought item goes: a square, a line, or a card of the deck */
.mini-board { display: grid; grid-template-columns: repeat(3, 38px); gap: 3px; }
.mini-board.big { grid-template-columns: repeat(3, 64px); gap: 6px; justify-content: center; }
.mini-board.big .mini-cell { height: 52px; }
.mini-board.big .mini-price { font-size: 15px; }
.line-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.line-choice { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 10px; color: #fff; text-align: left; cursor: pointer; }
.line-choice:disabled { opacity: .45; cursor: default; }
.line-choice small { color: var(--muted); font-size: 13px; }
button.mini-card { position: relative; border: 0; font-family: inherit; cursor: pointer; }
button.mini-card:disabled { opacity: .45; cursor: default; }
.mini-seal {
  position: absolute; top: -5px; right: -5px; width: 15px; height: 15px; border-radius: 50%; font-size: 11px; line-height: 15px;
  background: #d58cff; color: var(--ink); border: 1px solid var(--ink);
}
/* A seal on a card, and a line's level on its chip */
.seal-tag {
  position: absolute; left: -4px; top: -4px; z-index: 1; width: 18px; height: 18px; font: 700 12px/15px var(--body); text-align: center;
  background: #d58cff; color: var(--ink); border: 2px solid var(--ink); border-radius: 50%; pointer-events: none;
}
button.chip, button.diag { position: relative; }
/* Last Word: the most recent card counts twice */
.last-tag {
  position: absolute; right: -4px; bottom: -4px; z-index: 1; padding: 0 3px; font-size: 12px; line-height: 15px;
  background: var(--gold); color: var(--ink); border: 2px solid var(--ink); border-radius: 5px; pointer-events: none;
}
.lv-tag {
  position: absolute; top: 1px; right: 1px; min-width: 14px; padding: 0 2px; font-size: 11px; line-height: 12px;
  background: #4ea8ff; color: var(--ink); border: 1px solid var(--ink); border-radius: 5px; text-decoration: none;
}
.mini-cell {
  position: relative; height: 27px; padding: 0; border-radius: 6px; border: 2px dashed rgba(255, 255, 255, .25);
  background: rgba(0, 0, 0, .25); color: var(--soft); display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.mini-cell.buyable { cursor: pointer; border: 2px solid rgba(255, 210, 63, .6); }
.mini-cell.buyable:hover:not(:disabled) { background: rgba(255, 210, 63, .18); }
.mini-cell:disabled { opacity: .45; cursor: default; }
.mini-up { width: 18px; height: 18px; border-radius: 50%; background: var(--up); color: var(--ink); font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.mini-price { font-family: var(--display); font-size: 13px; line-height: 1; }
.relic-slot.empty { border: 3px dashed rgba(255, 255, 255, .25); border-radius: 10px; background: rgba(0, 0, 0, .2); }
.deck-shop { display: flex; gap: 8px; overflow-x: auto; margin: 0 -14px; padding: 0 14px 6px; scrollbar-width: none; }
.deck-buy { flex: 0 0 96px; display: flex; flex-direction: column; gap: 8px; }
.deck-chip {
  height: 56px; border-radius: 8px; border: 3px solid var(--ink); box-shadow: 0 3px 0 var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 4px; cursor: pointer;
}
.deck-chip .glyph { font-size: 22px; text-shadow: 0 2px 0 var(--ink); }
.deck-chip .px:not(.glyph) { font-size: 13px; line-height: 1; text-align: left; }
.next { margin-top: auto; }

/* ---------- Stats ---------- */
.stats { display: flex; gap: 8px; }
.stat { flex: 1; min-width: 0; padding: 4px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.stat-val { font-size: 24px; line-height: 1.05; }
.suit-label { font-size: 14px; color: var(--soft); }
.suit-label.r { color: #ff6b61; }

/* ---------- Board (phone first) ---------- */
.o-stats { order: 1; }
.o-score { order: 2; }
.o-strip { order: 3; }
.o-board { order: 4; }
.o-hand { order: 6; }
.o-actions { order: 7; }
.score { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.score-row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; height: 30px; }
.score-row .label { white-space: nowrap; flex-shrink: 0; }
/* One line whatever the score: fitText shrinks it instead of letting it wrap */
.score-num { font-size: 30px; line-height: 1; flex: 1 1 auto; text-align: right; }
.score-num .muted { font-size: .57em; }
.fit { display: block; min-width: 0; max-width: 100%; overflow: hidden; white-space: nowrap; }
.bar { height: 14px; border-radius: 6px; background: var(--ink); padding: 2px; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--gold); transition: width .15s linear; }
/* A fixed height, so swapping the deck line for the scoring tally never moves the board */
.score-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; height: 24px; overflow: hidden;
  font-size: 13px; font-weight: 500; color: var(--soft); white-space: nowrap;
}
.score-foot > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.score-foot .tally { gap: 4px; }
.score-foot .tally-name { font-size: 13px; line-height: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.score-foot .chips, .score-foot .mult { font-size: 14px; padding: 0 5px; border-width: 2px; border-radius: 6px; min-width: 0; }
.score-foot .times { font-size: 14px; }
.score-foot .tally-total { font-size: 15px; }
.next-card { background: var(--card); color: var(--card-ink); border-radius: 4px; padding: 0 4px; }
.next-card.r { color: var(--card-red); }
/* Cards left in the deck: tap to see them. The icon is a little stack of cards. */
.deck-left {
  display: inline-flex; align-items: center; gap: 7px; height: 100%; padding: 0 8px 0 7px; border: 0; border-radius: 6px;
  background: rgba(0, 0, 0, .3); color: var(--soft); font: inherit; font-weight: 700; cursor: pointer;
}
.deck-left::before { content: ''; width: 8px; height: 11px; border-radius: 2px; background: var(--card); box-shadow: 2px -2px 0 rgba(251, 246, 233, .45); }
.deck-left-grid { display: grid; grid-template-columns: 22px repeat(var(--ranks), minmax(0, 1fr)); gap: 3px; align-items: center; text-align: center; }
.deck-left-grid .suit-label { font-size: 15px; line-height: 1; }
.deck-left-grid .suit-label small { display: block; font-size: 12px; font-weight: 700; color: var(--muted); }
.mini-card { padding: 3px 0; border-radius: 4px; background: var(--card); color: var(--card-ink); font-size: 12px; font-weight: 800; line-height: 1.15; }
.mini-card.r { color: var(--card-red); }
.mini-card.gone { opacity: .18; }
/* A sealed card in the deck view: tap it to read its seal */
button.mini-card.sealed { outline: 2px solid #d58cff; outline-offset: -1px; }
button.mini-card.sealed.gone { opacity: .45; }
/* Under the deck view: each seal, the cards it's on and what it does */
.seal-head { margin: 4px 0 0; }
.seal-list { display: flex; flex-direction: column; gap: 6px; }
.seal-list .relic-row { font: inherit; color: inherit; text-align: left; cursor: pointer; border-color: #d58cff; }
.seal-on { font-family: var(--body); font-size: 14px; color: var(--muted); }
.boss-stat { background: #3a2350; }
.boss-stat .label { color: var(--boss); }
button.stat { font: inherit; color: inherit; cursor: pointer; }
.stat .label { white-space: nowrap; }
/* The ante stat's board pips: dots for the boards around this one (a diamond for the boss), this one by name */
.pips { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 19px; }
.pip { flex: none; width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--k); }
.pip.boss { border-radius: 2px; transform: rotate(45deg); width: 8px; height: 8px; }
.pip.done { background: var(--k); opacity: .55; }
.pip.now {
  width: auto; height: auto; transform: none; padding: 0 4px; border: 2px solid var(--ink); border-radius: 5px;
  background: var(--k); color: var(--ink); font-family: var(--display); font-size: 13px; line-height: 14px; letter-spacing: .3px;
}

/* The card that opens each board, over the board (see boardIntro in game.js) */
.board-intro {
  position: fixed; z-index: 14; pointer-events: none; opacity: 0; visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 12px; text-align: center;
  background: rgba(8, 14, 13, .82); border-radius: 14px;
}
.board-intro.show { visibility: visible; animation: intro var(--dur, 2.2s) ease-out both; }
.intro-ante { font-size: 18px; color: var(--soft); letter-spacing: 1px; }
.intro-ladies { display: flex; justify-content: center; }
.intro-lady { width: 96px; height: 96px; }
.intro-ladies .intro-lady + .intro-lady { margin-left: -24px; }
.intro-name { font-size: clamp(30px, 9vw, 44px); line-height: 1; color: var(--k); text-shadow: 0 3px 0 var(--ink); }
.intro-of { font-size: 13px; font-weight: 700; color: var(--muted); letter-spacing: .5px; }
.intro-note { max-width: 30ch; margin-top: 4px; font-size: 14px; font-weight: 500; color: #ecdcf7; line-height: 1.35; }
.intro-target { margin-top: 6px; font-size: 18px; }
@keyframes intro {
  0% { opacity: 0; transform: scale(.85); }
  10% { opacity: 1; transform: scale(1.04); }
  18%, 80% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1); }
}

.board-wrap { container-type: inline-size; }
.board-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, .72fr);
  gap: 8px; padding: 8px;
  border-radius: 16px; background: var(--felt); border: 3px solid var(--edge); box-shadow: 0 4px 0 var(--ink);
}
.cell { position: relative; aspect-ratio: 1; display: flex; transform: rotate(var(--tilt)); font-size: 9.5cqi; }
.cell .suit { font-size: .82em; }
.cell.lit .card { border-color: var(--gold); box-shadow: 0 0 0 3px var(--ink), 0 0 16px 4px rgba(255, 210, 63, .6), 0 5px 0 var(--ink); }
.slot {
  width: 100%; height: 100%; border-radius: 10px; cursor: pointer;
  border: 3px dashed rgba(255, 210, 63, .55); background: rgba(255, 210, 63, .08);
  color: rgba(255, 210, 63, .8); font-family: var(--display); font-size: 1em;
}
.slot:hover:not(:disabled) { background: rgba(255, 210, 63, .18); }
.slot:disabled { cursor: default; border-color: rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .18); color: rgba(255, 255, 255, .35); }
.chip {
  border-radius: 10px; border: 3px solid var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 44px; padding: 2px;
}
.chip-label { font-size: 12px; font-weight: 700; line-height: 1.1; }
.chip-pts { font-size: 17px; }
/* Text sized to the chip itself: row chips are narrow and tall, column chips wide and short */
button.chip:not(.corner) { container-type: inline-size; }
.chip-label .short { display: none; }
@container (max-width: 64px) {
  .chip-label .full { display: none; }
  .chip-label .short { display: inline; }
}
.chip.open { background: rgba(0, 0, 0, .28); color: rgba(255, 255, 255, .6); border-style: dashed; }
.chip.done { background: var(--card); color: #1a1a22; box-shadow: 0 4px 0 var(--ink); }
.chip.hot { background: var(--gold); color: #2a1d00; box-shadow: 0 4px 0 var(--ink); }
.chip.corner { background: rgba(0, 0, 0, .28); gap: 0; align-items: stretch; }
.chip.void { background: rgba(0, 0, 0, .4); color: #ff8f86; text-decoration: line-through; }
/* What a line would score with the card being dragged or hovered */
.cell.blocked { align-items: center; justify-content: center; }
.blocked-tile {
  width: 100%; height: 100%; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, rgba(0, 0, 0, .45) 0 8px, rgba(0, 0, 0, .25) 8px 16px);
  color: rgba(255, 255, 255, .45); font-family: var(--display); font-size: 1.2em; border: 3px solid rgba(0, 0, 0, .5);
}
.diag { display: flex; justify-content: space-between; padding: 0 4px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .6); }
.diag b { font-size: 14px; }
.diag.on { color: var(--gold); }
/* Wraparound's lines: a row under the board, each chip with a map of its squares */
.wrap-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; min-height: 0; }
.wrap-chip { flex-direction: row; gap: 6px; min-height: 36px; }
.line-map { width: 24px; height: 24px; flex-shrink: 0; }
.h1 .line-map { width: 1em; height: 1em; vertical-align: -.1em; margin-left: 6px; color: var(--gold); }
.line-map rect { fill: currentColor; opacity: .22; }
.line-map rect.on { opacity: 1; }
/* Cell upgrades: a tinted square, a badge on its corner, and the same colours in the shop */
.up-anchor { --up: #4ea8ff; }
.up-echo { --up: #d58cff; }
.up-prism { --up: #47d18c; }
.up-forge { --up: #ff8a3d; }
.up-gilded { --up: var(--gold); }
.up-joker { --up: #ff5fa2; }
.cell.up .slot { border-color: var(--up); background: color-mix(in srgb, var(--up) 18%, transparent); }
.cell.up .card { box-shadow: 0 0 0 3px var(--up), 0 4px 0 #1a1a22; }
.cell-up {
  position: absolute; top: -7px; right: -7px; z-index: 2; width: 22px; height: 22px; padding: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font: 13px/1 var(--body); font-weight: 700;
  background: var(--up); color: var(--ink); border: 2px solid var(--ink); border-radius: 50%;
}
.forged {
  position: absolute; left: -4px; bottom: -4px; z-index: 1; padding: 0 3px; font-size: 12px; line-height: 15px;
  background: #ff8a3d; color: var(--ink); border: 2px solid var(--ink); border-radius: 5px; pointer-events: none;
}
/* Joker square: on a line's chip, what its card counted as in that line */
.joker-tag {
  position: absolute; top: 2px; left: 2px; padding: 0 2px; font: 700 10px/12px var(--body); white-space: nowrap;
  text-decoration: none; background: #ff5fa2; color: var(--ink); border: 1px solid var(--ink); border-radius: 5px; pointer-events: none;
}
/* The diagonals share one small chip: there it sits between the arrow and the points */
.diag .joker-tag { position: static; margin-left: -3px; padding: 0 1px; }
.joker-as { color: #ff5fa2; font-weight: 700; }
.hand-card { position: relative; }
button.chip, button.diag { font-family: inherit; cursor: pointer; }
button.diag { flex: 1; align-items: center; min-width: 0; background: none; border: 0; }
.line-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.line-layer .stroke {
  stroke: var(--gold); stroke-width: 8; stroke-linecap: round; opacity: .9;
  stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: draw .35s ease-out forwards;
}
.line-layer .stroke.old { opacity: .3; }
.board-stamp {
  position: absolute; left: 50%; top: 42%; z-index: 3;
  background: var(--green); border: 4px solid var(--ink); border-radius: 12px; box-shadow: 0 6px 0 var(--ink);
  padding: 8px 14px; font-size: 28px; white-space: nowrap; text-shadow: 0 3px 0 var(--ink);
  animation: stamp .45s cubic-bezier(.2, .8, .3, 1.3) forwards;
}

.hand {
  container-type: inline-size;
  display: flex; justify-content: center; align-items: flex-end;
  min-height: 84px; padding-top: 12px; margin-top: auto;
}
.hand-card {
  --w: min(58px, calc((100cqi + 42px) / 8));
  width: var(--w); height: calc(var(--w) * 1.42);
  padding: 0; border: 0; background: transparent; cursor: pointer;
  margin-left: -6px; font-size: calc(var(--w) * .4);
  transform: translateY(var(--drop)) rotate(var(--tilt));
  transition: transform .12s;
}
.hand-card:first-child { margin-left: 0; }
.hand-card .suit { font-size: .85em; }
.hand-card.sel { transform: translateY(-16px) rotate(var(--tilt)); z-index: 1; }
.hand-card.sel .card { border-color: var(--gold); box-shadow: 0 0 0 3px #1a1a22, 0 7px 0 #1a1a22; }
.hand-card:disabled { cursor: default; }
.hand-card { touch-action: none; -webkit-user-select: none; user-select: none; }
.hand-card.dragging { visibility: hidden; }
.hand-card.deal .card { animation: deal .22s ease-out; }
.slot.droptarget { border-style: solid; border-color: var(--gold); background: rgba(255, 210, 63, .3); }
.drag-ghost {
  position: fixed; z-index: 50; margin: 0; pointer-events: none;
  transform: rotate(var(--rot, -4deg)) scale(1.08);
  box-shadow: 0 14px 28px rgba(0, 0, 0, .45), 0 4px 0 #1a1a22;
}
.drag-ghost .suit { font-size: .85em; }
.drag-ghost.discarding { opacity: 0; }
.drag-ghost.settling {
  transform: none; box-shadow: 0 4px 0 #1a1a22;
  transition: left .16s ease-out, top .16s ease-out, width .16s ease-out, height .16s ease-out, transform .16s ease-out, font-size .16s ease-out, opacity .16s ease-in;
}

/* Discard pile: a drop zone for hand cards, and tappable to discard the picked cards */
.discard-pile {
  --pile-h: 59px;
  width: 100%; height: var(--pile-h); border-radius: 12px; cursor: pointer;
  border: 3px dashed rgba(255, 107, 97, .7); background: #3a2230; color: #ffc2b8;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.discard-pile .pile-label { font-size: 19px; line-height: 1; }
.discard-pile .pile-hint { font-size: 13px; font-weight: 600; color: var(--soft); }
.discard-pile:hover:not(:disabled) { background: rgba(201, 58, 50, .22); }
.discard-pile.armed { border-style: solid; border-color: var(--ink); background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--ink); height: calc(var(--pile-h) - 5px); margin-bottom: 5px; }
.discard-pile.armed .pile-hint { color: #ffe0dc; }
.discard-pile.droptarget { border-style: solid; border-color: #ff6b61; background: rgba(201, 58, 50, .45); color: #fff; }
.discard-pile:disabled { cursor: default; border-color: rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .18); color: rgba(255, 255, 255, .45); }

/* Leaderboard account line, sign-in and run posting */
.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--gold); font-weight: 700; text-decoration: underline; font-size: inherit;
}
.account { padding: 0 2px; }
.signin, .post { display: flex; flex-direction: column; gap: 6px; }
.signin .linkbtn { align-self: flex-start; }
.post { background: rgba(0, 0, 0, .25); border-radius: 10px; padding: 10px; }
.post-title { font-size: 20px; color: var(--gold); }
/* Add-to-home-screen offer on the game-over sheet: iOS's Share icon, drawn inline in the steps */
.share-icon { display: inline-block; vertical-align: -3px; color: #fff; }
.post input, .signin input {
  min-height: 48px; padding: 0 12px; border-radius: 10px; border: 3px solid var(--ink);
  background: var(--card); color: var(--card-ink); font-family: var(--body); font-size: 16px; font-weight: 500;
}
.form-error { color: #ffb3a8; font-size: 14px; font-weight: 500; }
.account-box { display: flex; flex-direction: column; gap: 8px; }
.lb-row.me { outline: 3px solid var(--gold); }
.actions { display: flex; gap: 8px; }
/* Once-per-board relics, beside the discard pile: tap to use. One waiting for its target is lit, and so are the cards it can take. */
.move-btn {
  flex: 0 0 64px; height: var(--pile-h, 59px); border-radius: 12px; cursor: pointer; padding: 0;
  border: 3px solid var(--ink); background: #2b5a63; color: #fff; box-shadow: 0 4px 0 var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.move-btn .move-glyph { font-size: 22px; line-height: 1; color: #3fd6d0; }
.move-btn small { font-size: 12px; line-height: 1; }
.move-btn.sel { background: #3fd6d0; color: var(--ink); }
.move-btn.sel .move-glyph { color: var(--ink); }
.move-btn:disabled { cursor: default; opacity: .45; box-shadow: none; }
.swap-card.aim .card { outline: 3px dashed #3fd6d0; outline-offset: 2px; }

/* Scoring tally (shown in the score panel while lines score) */
.tally { display: flex; align-items: center; gap: 6px; width: 100%; }
.tally-name { flex: 1; font-size: 15px; line-height: 1.05; color: #fff; }
.chips, .mult {
  display: inline-block; border: 3px solid var(--ink); border-radius: 8px;
  padding: 1px 9px; font-size: 20px; color: #fff;
}
.chips { background: var(--blue); min-width: 40px; text-align: right; }
.mult { background: var(--red); }
.times { color: #ff8f86; font-size: 18px; }
.tally-total { color: var(--gold); font-size: 22px; text-shadow: 0 2px 0 var(--ink); }

.pop {
  position: absolute; left: 50%; top: -12px; z-index: 5; pointer-events: none; white-space: nowrap;
  font-size: 18px; padding: 0 6px; border-radius: 6px; border: 2px solid var(--ink);
  animation: pop .95s ease-out forwards;
}
.pop.chips { background: var(--blue); color: #fff; }
.pop.mult { background: var(--red); color: #fff; }
.pop.gold { background: none; border: 0; color: var(--gold); font-size: 24px; left: 70%; text-shadow: 0 3px 0 var(--ink); }

/* Line breakdown sheet */
.calc { border-collapse: collapse; width: 100%; font-size: 14px; }
.calc td { padding: 5px 6px; border-bottom: 2px solid var(--panel-deep); vertical-align: middle; }
.calc td:first-child { padding-left: 0; }
.calc .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
.calc .chips-t { color: #8fc7ff; }
.calc .mult-t { color: #ff8f86; }
.calc-total td { border-bottom: 0; font-weight: 700; }
.calc-points { font-size: 24px; text-align: center; }

/* Notices that float over the board for a moment */
.toast {
  position: fixed; z-index: 15; transform: translate(-50%, -50%) scale(.96); opacity: 0; pointer-events: none;
  width: max-content; padding: 8px 14px; border-radius: 12px; border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink);
  background: var(--panel); color: var(--soft); font-size: 14px; font-weight: 500; line-height: 1.35; text-align: center;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%); }
/* How-to-play tips: a bar just above the hand, pointing down at it */
.toast.tip {
  display: flex; align-items: center; gap: 10px; text-align: left; border-color: var(--gold);
  transform: translate(-50%, calc(-100% + 8px)); box-shadow: 0 4px 0 var(--ink);
}
.toast.tip.show { transform: translate(-50%, -100%); }
.toast.tip::after {
  content: ''; position: absolute; left: 50%; bottom: -9px; width: 12px; height: 12px; translate: -50% 0; rotate: 45deg;
  background: var(--panel); border-right: 3px solid var(--gold); border-bottom: 3px solid var(--gold);
}
.tip-tag { flex-shrink: 0; padding: 1px 7px; border-radius: 6px; background: var(--gold); color: #2a1d00; font-size: 15px; }
/* A line's chip as its score lands during the scoring animation */
.reveal { animation: thump .3s ease-out; }
/* What the board's boss switches off, under a line's breakdown */
.pattern-note { --type: #47d18c; display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--type) 14%, transparent); }
.pattern-note .label { color: var(--type); }
.pattern-note p { margin: 0; }
.boss-off { margin-top: 12px; padding: 8px 10px; border-radius: 10px; border: 2px solid var(--boss); background: rgba(58, 35, 80, .6); }
.boss-off .label { color: var(--boss); }
.boss-off p { margin: 4px 0 0; font-size: 14px; }
.line-row:last-child { border-bottom: 0; }
.line-row b { font-size: 16px; }
.line-row.on > span:last-child { color: #fff; }
.line-row.on b { color: var(--gold); }
.relic-row {
  position: relative; display: flex; gap: 10px; align-items: center; padding: 6px 8px;
  color: #fff; text-align: left; cursor: pointer; width: 100%;
}
.relic-row .relic-tile { width: 44px; flex-shrink: 0; }
.relic-row > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.relic-row .px { font-size: 15px; }
.relic-row small { font-size: 13px; line-height: 1.3; color: var(--soft); }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(5, 12, 10, .6); z-index: 20; }
.sheet {
  position: fixed; z-index: 21; left: 50%; bottom: 0; transform: translateX(-50%);
  /* dvh, not vh: on iPhone Safari 100vh is the height with the toolbars hidden, so a vh sheet runs under them. */
  width: min(480px, 100%); max-height: 90vh; max-height: calc(100dvh - max(12px, env(safe-area-inset-top))); overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 18px 18px 0 0; padding: 20px 16px max(22px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px; font-size: 15px; line-height: 1.45;
  animation: sheet-in .2s ease-out;
}
/* A redrawn sheet carries on its entrance from where it was (--since is minus the time since it opened) */
.sheet, .sheet .stamp { animation-delay: var(--since, 0s); }
.sheet p { color: var(--soft); }
/* When a sheet's content is taller than the screen (the rules), its closing buttons stay pinned at the bottom.
   The panel-coloured ring masks the text scrolling behind them. */
.sheet > :last-child:is(.btn, .two-btn) { position: sticky; bottom: 0; z-index: 1; }
.sheet > .btn:last-child { box-shadow: 0 5px 0 var(--ink), 0 0 0 10px var(--panel), 0 30px 0 10px var(--panel); }
.sheet > .two-btn:last-child { background: var(--panel); box-shadow: 0 0 0 10px var(--panel); }
/* A relic's sheet shows it as a big cream card */
.sheet-relic {
  display: flex; gap: 14px; align-items: center; padding: 12px;
  background: var(--card); color: var(--card-ink); border: 3px solid #fff; border-radius: 12px; box-shadow: 0 5px 0 var(--ink);
}
.sheet-relic .h1 { color: var(--card-ink); text-shadow: none; }
.sheet .sheet-relic p, .sheet-relic .sub { color: #5d5866; }
.rarity-text { font-size: 12px; font-weight: 700; letter-spacing: .5px; }
.rar-text-common { color: var(--common); }
.rar-text-uncommon { color: var(--uncommon); }
.rar-text-rare { color: var(--rare); }
.rar-text-legendary { color: var(--legendary); }
.rar-text-boss { color: var(--boss); }
.rules { font-size: 14px; display: flex; flex-direction: column; gap: 8px; }
/* The pixel font has no bold, so bold text in sheets is picked out in gold instead */
.rules b, .sheet p b:not([class]) { color: var(--gold); font-weight: inherit; }
/* The rules sheet: five tabs, each section a picture beside a line or two of text */
.rules-tabs { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.rules-tabs .filter { font-size: 14px; }
.rules { gap: 10px; }
.rule-row { display: flex; gap: 12px; align-items: center; }
.rule-art { flex: 0 0 64px; display: flex; justify-content: center; }
.rule-art .relic-tile { width: 44px; }
.hand-cards { display: inline-flex; gap: 3px; }
.hand-cards .mini-card { width: 20px; text-align: center; }
.rule-hands td { vertical-align: middle; padding-left: 4px; padding-right: 4px; }
.rule-hands td.num { white-space: nowrap; }
.rule-hands .chips, .rule-hands .mult, .rule-steps .chips, .rule-steps .mult { font-size: 15px; padding: 0 6px; border-width: 2px; border-radius: 6px; min-width: 0; }
.rule-hands .chips { min-width: 30px; }
.rule-hands .times { margin: 0 3px; font-size: 14px; }
.rule-formula, .rule-steps { display: flex; justify-content: center; align-items: center; gap: 8px; }
.rule-formula { font-size: 20px; }
.rule-formula .gold { font-size: 24px; text-shadow: 0 2px 0 var(--ink); }
.rule-lines { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; text-align: center; }
.rule-lines small { display: block; margin-top: 4px; font-size: 11px; font-weight: 700; color: var(--muted); }
.mini-board { display: inline-grid; grid-template-columns: repeat(3, 14px); gap: 3px; padding: 4px; border-radius: 6px; background: var(--panel-deep); }
.mini-board i { height: 14px; border-radius: 3px; background: rgba(255, 255, 255, .1); }
.mini-board i.on { background: var(--gold); }
.discard-icon {
  display: flex; align-items: center; justify-content: center; width: 34px; height: 44px; border-radius: 5px;
  border: 2px dashed var(--muted); color: var(--soft); font-size: 20px;
}
.rule-ante { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.rule-board {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px;
  border-radius: 10px; border: 3px solid var(--k); background: color-mix(in srgb, var(--k) 18%, transparent);
}
.rule-board > .px:first-child { color: var(--k); font-size: 17px; }
.rule-board b { font-size: 26px; color: var(--soft); font-weight: 400; }
.rule-board small { font-size: 12px; color: var(--muted); }
.rule-board .lady { width: 38px; height: 38px; }
.ante-pips { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); gap: 4px; }
.ante-pip {
  display: flex; align-items: center; justify-content: center; height: 30px; min-width: 28px; border-radius: 6px;
  background: rgba(0, 0, 0, .3); color: var(--soft); font-size: 16px;
}
.ante-pip.relic { background: var(--boss); color: var(--ink); }
.ante-pip.win { background: var(--green); color: var(--ink); }
/* A shop kind that opens its full list: the whole row is the button, with the count and a chevron on the right */
.rule-link {
  width: 100%; padding: 6px 4px 6px 0; border: 0; border-radius: 10px; background: rgba(0, 0, 0, .2);
  text-align: left; cursor: pointer;
}
.rule-link p { flex: 1; min-width: 0; }
.rule-more { display: flex; align-items: center; gap: 2px; color: var(--gold); font-size: 17px; }
.rule-more svg { width: 16px; height: 16px; }
.rule-back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; text-decoration: none; font-size: 16px; font-weight: 400; }
.rule-back svg { width: 16px; height: 16px; }
.coin-tag {
  display: flex; align-items: center; justify-content: center; min-width: 48px; height: 34px; padding: 0 8px; border-radius: 17px;
  border: 2px solid var(--ink); background: var(--gold); color: var(--ink); font-size: 18px;
}
.hand-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.hand-table th, .hand-table td { text-align: left; padding: 4px 8px; border-bottom: 2px solid var(--panel-deep); }
.hand-table th { font-size: 12px; color: var(--muted); }
.hand-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.boss-choices { display: flex; flex-direction: column; gap: 8px; }
.boss-choice small { color: var(--soft); }
.name-form { display: flex; flex-direction: column; gap: 6px; }
.name-row { display: flex; gap: 8px; }
.name-row input {
  flex: 1; min-width: 0; min-height: 50px; padding: 0 12px; border-radius: 10px; border: 3px solid var(--ink);
  background: var(--card); color: var(--card-ink); font-family: var(--body); font-size: 16px; font-weight: 500;
}
.speed { display: flex; flex-direction: column; gap: 6px; }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.seg button {
  min-height: 44px; border-radius: 10px; border: 3px solid var(--ink); background: rgba(0, 0, 0, .3);
  color: var(--soft); font-size: 16px; cursor: pointer;
}
.seg button.on { background: var(--card); color: #1a1a22; }
.seg.seg-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.replace-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.replace-choice { display: flex; align-items: center; gap: 8px; padding: 6px; color: #fff; text-align: left; cursor: pointer; }
.replace-choice .relic-tile { width: 44px; flex-shrink: 0; }
.replace-choice > span { display: flex; flex-direction: column; min-width: 0; }
.replace-choice small { color: var(--muted); font-size: 13px; }
.stamp {
  align-self: center; background: var(--green); border: 4px solid var(--ink); border-radius: 12px;
  box-shadow: 0 6px 0 var(--ink); padding: 8px 16px; font-size: 30px; text-shadow: 0 3px 0 var(--ink);
  animation: stamp-flat .45s cubic-bezier(.2, .8, .3, 1.3);
}
.stamp.lost { background: var(--red); }
.result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.result-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.result-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.result-grid span { display: flex; flex-direction: column; background: rgba(0, 0, 0, .25); border-radius: 8px; padding: 6px 8px; }
.result-grid small { font-size: 12px; font-weight: 700; color: var(--muted); }
.result-grid b { font-size: 20px; }
.two-btn { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.two-btn .btn { font-size: 16px; }
.three-btn { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.three-btn .btn { font-size: 15px; padding: 0 6px; }

/* Leaderboard filters: the period switch and the deck dropdown are separate controls */
.lb-filters { display: flex; gap: 10px; align-items: stretch; }
.lb-period { flex: 1; }
.lb-period button { min-height: 40px; font-size: 14px; }
.lb-deck { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.lb-deck select {
  min-height: 40px; padding: 0 10px; border-radius: 10px; border: 3px solid var(--ink);
  background: rgba(0, 0, 0, .3); color: #fff; font-family: var(--display); font-size: 15px; cursor: pointer;
}
.lb-deck select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

/* Run history */
.seed-form { display: flex; flex-direction: column; gap: 6px; }
.history-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.history-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.history-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.history-main .px { font-size: 16px; }
.history-main small { font-size: 13px; color: var(--muted); }
.history-relics { display: flex; gap: 3px; flex-wrap: wrap; }
.history-relics img { width: 20px; height: 20px; border-radius: 4px; }
.history-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.history-side .px { font-size: 18px; }
.history-side .small { min-height: 28px; font-size: 13px; }

/* Collection: the used / not used / locked counts filter the grid; each rarity is a section of relic tiles */
.coll-filter { cursor: pointer; font: inherit; color: inherit; padding: 6px 8px; }
.coll-filter.used .stat-val { color: var(--gold); }
.coll-filter.locked .stat-val { color: var(--muted); }
.coll-filter[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.coll-group { display: flex; flex-direction: column; gap: 8px; }
.coll-head { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 0; font-size: 20px; font-weight: 400; }
.coll-head small { font-family: var(--body); font-size: 13px; color: var(--muted); }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 10px; }
.coll-item { position: relative; padding: 0; border: 0; background: none; cursor: pointer; }
/* Unlocked but never used: faded, so the used ones stand out. Dimmed rather than see-through so the rug's paw prints
   don't show inside the tiles (disabled buttons and cleared boards dim the same way). */
.coll-item.unused .relic-tile { filter: grayscale(.8) brightness(.5); }
.relic-tile.locked { background: rgba(0, 0, 0, .35); border-color: var(--muted); }
.relic-tile.locked .glyph-art { --type: var(--muted); font-family: var(--display); }
/* How many finished runs a relic was used in */
.coll-count {
  position: absolute; right: -4px; bottom: -6px; min-width: 20px; padding: 0 4px; border-radius: 6px;
  background: var(--gold); color: #2a1d00; border: 2px solid var(--ink); font-size: 13px; line-height: 16px; text-align: center;
}
.unlock-bar { height: 12px; border-radius: 6px; border: 2px solid var(--ink); background: rgba(0, 0, 0, .35); overflow: hidden; }
.unlock-bar span { display: block; height: 100%; background: var(--gold); }
/* Relics a run unlocked, on the end-of-run sheets */
.unlock-relics { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; padding: 4px 0; }
.unlock-relic { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 72px; }
.unlock-relic .relic-tile { width: 48px; }
.unlock-relic small { font-size: 12px; line-height: 1.15; }

/* ---------- Motion ---------- */
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes drop {
  0% { transform: translate(-30px, 260px) scale(.7) rotate(-14deg); }
  60% { transform: translate(0, -12px) scale(1.15) rotate(5deg); }
  100% { transform: none; }
}
@keyframes bounce { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.16) rotate(-4deg); } }
@keyframes shake {
  0%, 100% { transform: rotate(0) scale(1); }
  20% { transform: rotate(-14deg) scale(1.25); }
  45% { transform: rotate(11deg) scale(1.2); }
  70% { transform: rotate(-5deg) scale(1.08); }
}
@keyframes pop {
  0% { transform: translate(-50%, 8px) scale(.4); opacity: 0; }
  20% { transform: translate(-50%, -6px) scale(1.25); opacity: 1; }
  70% { transform: translate(-50%, -14px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -34px); opacity: 0; }
}
@keyframes thump { 0% { transform: scale(1); } 35% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes stamp {
  0% { transform: translate(-50%, -50%) rotate(-16deg) scale(2.6); opacity: 0; }
  60% { transform: translate(-50%, -50%) rotate(-8deg) scale(.9); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-8deg) scale(1); opacity: 1; }
}
@keyframes stamp-flat {
  0% { transform: rotate(-12deg) scale(2.2); opacity: 0; }
  60% { transform: rotate(-4deg) scale(.92); opacity: 1; }
  100% { transform: rotate(-4deg) scale(1); }
}
@keyframes deal { from { opacity: 0; transform: translateY(-14px) scale(.9); } }
@keyframes glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 210, 63, 0); } 50% { box-shadow: 0 0 18px 4px rgba(255, 210, 63, .75); } }
@keyframes sheet-in { from { transform: translate(-50%, 30px); opacity: 0; } }
.card.drop { animation: drop .5s cubic-bezier(.2, .8, .3, 1.2); }
.card.bounce { animation: bounce .35s ease-out; }
.relic-tile.shake { animation: shake .45s ease-out; }
.thump { display: inline-block; animation: thump .25s ease-out; }
.bar.glow { animation: glow 1s ease-in-out infinite; }
.bar.glow .bar-fill { background: var(--gold); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- Every screen fits the viewport, no page scroll. Desktop plays the phone layout, a little wider ---------- */
@media all {
  #app { height: 100vh; height: 100dvh; min-height: 0; }
  .screen { min-height: 0; }

  /* Menu: the hero board takes whatever height is left, up to a cap, so on tall desktop windows the art stays close to
     the title and the menu sits in the middle of the screen. The stickers and Dona Filó are placed on the board itself
     (the stage), not on the hero's edges, so they stay with it at any height. */
  .screen.menu { justify-content: center; }
  .hero { flex: 1; min-height: 0; max-height: 380px; align-items: center; padding-top: 0; container-type: size; }
  .hero-stage { --hb: clamp(90px, calc((100cqh - 44px) / 1.3), 214px); position: relative; }
  .hero-board { width: var(--hb); gap: calc(var(--hb) * .037); padding: calc(var(--hb) * .056); }
  .hero-cell { height: calc(var(--hb) * .345); font-size: calc(var(--hb) * .12); }
  .hero-cell .suit { font-size: .77em; }
  .sticker { top: -22px; right: calc(var(--hb) * -.18); font-size: clamp(14px, calc(var(--hb) * .093), 20px); }
  .ea-badge { top: -22px; left: calc(var(--hb) * -.21); font-size: clamp(12px, calc(var(--hb) * .075), 16px); }
  .hero-lady { left: calc(var(--hb) * -.32); bottom: calc(var(--hb) * -.1); width: calc(var(--hb) * .49); height: calc(var(--hb) * .49); }
  .ea-tip { top: 22px; }
  .logo { font-size: clamp(44px, 8dvh, 60px); }
  .menu-actions { margin-top: 0; }

  /* Leaderboard: the list scrolls inside the screen instead of the page */
  .lb-list { flex: 1; min-height: 0; overflow-y: auto; }
  .history-list { flex: 1; min-height: 0; overflow-y: auto; padding-bottom: 6px; }
  .you-row { flex-shrink: 0; }

  /* Shop: offers keep their natural height (on phones they share what's left: see below) */
  .offers { flex: 0 1 auto; min-height: min-content; }

  .selected-tag { font-size: clamp(12px, calc(var(--dh) * .064), 15px); }

  /* Board: sized to fit both the width and the height left over */
  .board-wrap { flex: 1; min-height: 0; container-type: size; display: flex; justify-content: center; align-items: center; }
  .board-grid {
    --bw: min(100cqw, 100cqh);
    width: var(--bw); height: var(--bw);
    grid-template-rows: repeat(3, minmax(0, 1fr)) minmax(0, .72fr);
  }
  /* With Wraparound's row the board is taller than wide: the squares keep their size */
  .board-grid.has-wrap {
    --bw: min(100cqw, 100cqh / 1.13);
    height: calc(var(--bw) * 1.13);
    grid-template-rows: repeat(3, minmax(0, 1fr)) minmax(0, .72fr) minmax(0, .5fr);
  }
  .wrap-chip .chip-pts { font-size: clamp(10px, 12cqi, 17px); }
  .wrap-chip .line-map { height: 86%; width: auto; aspect-ratio: 1; max-height: 30px; }
  .cell { aspect-ratio: auto; font-size: calc(var(--bw) * .095); }
  .chip { min-height: 0; overflow: hidden; }
  .chip-label { font-size: clamp(10px, 19cqi, 13px); white-space: nowrap; }
  .chip-pts { font-size: clamp(10px, 33cqi, 17px); }
  .hand { margin-top: 0; }
  .hand-card { --w: min(58px, calc((100cqi + 42px) / 8), 8.5dvh); }
}

/* Short phones: tighten spacing so the board keeps a playable size */
@media (max-height: 760px) {
  #app { padding-top: max(8px, env(safe-area-inset-top)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .screen { gap: 8px; }
  .stat { padding: 2px 8px; }
  .stat-val { font-size: 20px; }
  .stats .icon { height: auto; min-height: 40px; }
  .score { padding: 6px 10px; gap: 4px; }
  .score-row { height: 24px; }
  .score-num { font-size: 24px; }
  .score-num .muted { font-size: .62em; }
  .bar { height: 12px; }
  .o-strip .relic-strip { grid-template-columns: repeat(var(--cols, 6), minmax(0, 40px)); justify-content: center; }
  .hand { min-height: 0; }
  .menu-actions .lg { min-height: 46px; font-size: 19px; }
  .discard-pile { --pile-h: 51px; }
  .discard-pile .pile-label { font-size: 17px; }
  .xl { min-height: 54px; font-size: 22px; }
  .tagline { font-size: 14px; }
  .h1 { font-size: 26px; }
  .offers { padding-bottom: 8px; }
  .deck-chip { height: 44px; }
  .relic-strip { grid-template-columns: repeat(var(--cols, 6), minmax(0, 44px)); justify-content: center; }
  .o-strip .relic-strip { grid-template-columns: repeat(var(--cols, 6), minmax(0, 34px)); }
  .o-strip .relic-strip.rows2 { grid-template-columns: repeat(var(--cols), minmax(0, 36px)); gap: 4px 8px; }

  /* Sheets: tighter, so end-of-board and game-over sheets fit without scrolling */
  .sheet { gap: 10px; padding-top: 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); font-size: 14px; line-height: 1.35; }
  .stamp { font-size: 24px; padding: 4px 14px; }
  .result-grid span { padding: 4px 8px; }
  .result-grid b { font-size: 18px; }
  .post { padding: 8px; gap: 4px; }
  .post-title { font-size: 18px; }
  .post input, .signin input { min-height: 42px; }
  .sheet .xl { min-height: 48px; font-size: 20px; }
  .sheet .md { min-height: 44px; font-size: 16px; }
  .speed { gap: 4px; }
  .seg button { min-height: 40px; }
}

/* Very short phones (iPhone SE with browser bars): drop secondary details */
@media (max-height: 620px) {
  .screen { gap: 6px; }
  .score-foot { height: 20px; font-size: 12px; }
  .stat .label { font-size: 12px; }
  .stat-val { font-size: 18px; }
  .stats .icon { min-height: 36px; }
  .hand { padding-top: 10px; }
  .discard-pile { --pile-h: 47px; }
  .discard-pile .pile-label { font-size: 16px; }
  .discard-pile .pile-hint { font-size: 12px; }
  .sub { font-size: 13px; }
  .relic-strip { grid-template-columns: repeat(var(--cols, 6), minmax(0, 36px)); }
  .h1 { font-size: 22px; }
  .shop-head .btn { min-height: 38px; font-size: 16px; }
  .offer { gap: 4px; }
  .section { gap: 4px; }
  .section-head > .px { white-space: nowrap; }
  .offer-name { font-size: 16px; }
  .buy { min-height: 38px; font-size: 17px; }
  .deck-buy { gap: 6px; }
  .deck-chip { height: 38px; }
  .small { min-height: 30px; }

  /* Sheets on the smallest phones */
  .sheet { gap: 8px; padding-top: 12px; }
  .stamp { font-size: 22px; }
  .sheet .xl { min-height: 46px; font-size: 19px; }
  .sheet .md { min-height: 42px; }
  .sheet .speed .sub { display: none; }
}

/* ---------- Phones: the shop's five offers share the height the rest of the shop leaves, so it never scrolls. With room
   they're rows: art beside name, price and what the item does, in as many lines as fit (a cut description ends in an
   ellipsis; the sheet has it all), or only name and price on a tighter screen. With too little room for rows (a short
   phone before a boss), five tiles side by side. Both the list and each row are size containers for this. Each offer
   keeps a fifth of the list, so buying one leaves a gap instead of growing the rest. */
@media all {
  .offers-box { flex: 1 1 0; min-height: 128px; max-height: 620px; container: offers / size; }
  .offers { height: 100%; display: flex; flex-direction: column; gap: 7px; overflow: visible; margin: 0; padding: 2px 0 4px; scroll-snap-type: none; }
  .offer-slot { flex: 0 0 calc((100% - (var(--offers) - 1) * 7px - var(--groups) * 23px) / var(--offers)); min-height: 0; max-height: 116px; transform: rotate(calc(var(--tilt) * .2)); container: offer / size; }
  .panel.offer {
    --art: clamp(28px, calc(100cqh - 14px), 60px);
    position: relative; display: grid; grid-template-columns: var(--art) minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 10px; row-gap: 0;
    align-content: center; padding: 1px 8px 1px 5px; border-width: 2px; border-radius: 10px;
  }
  .panel.offer { grid-template-rows: auto auto auto; }
  .offer-art { grid-row: 1 / 4; width: var(--art); align-self: center; border-width: 2px; }
  .offer-tags { display: none; }
  .offer-art .glyph-art { font-size: calc(var(--art) * .5); }
  .offer-head { align-items: baseline; }
  .offer-name { font-size: 15px; line-height: 1; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; }
  .tile-price { font-size: 14px; line-height: 16px; }
  .offer-desc { font-size: 13px; line-height: 1.2; display: none; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; }
  @container offer (min-height: 47px) {
    .panel.offer { padding-block: 4px; row-gap: 2px; }
    .offer-name { font-size: 17px; }
    .offer-desc { display: -webkit-box; }
  }
  @container offer (min-height: 62px) { .offer-tags { display: flex; } }
  @container offer (min-height: 93px) { .offer-desc { -webkit-line-clamp: 2; } }
  /* Too little height for rows: tiles of art and name, the price on the art */
  @container offers (max-height: 228px) {
    .offers { flex-direction: row; gap: 6px; }
    .offer-divider { display: none; }
    .offer-slot { flex-basis: calc((100% - (var(--offers) - 1) * 6px) / var(--offers)); max-height: none; transform: rotate(calc(var(--tilt) * .4)); }
    .offers .panel.offer {
      --art: min(calc(100cqw - 12px), calc(100cqh - 50px));
      display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 3px; padding: 4px; text-align: center;
    }
    .offers .offer-head { display: contents; }
    .offers .offer-name { font-size: clamp(10px, 3vw, 12px); line-height: 1.1; -webkit-line-clamp: 2; overflow-wrap: break-word; }
    .offers .tile-price { position: absolute; top: 6px; left: 6px; padding: 0 3px; font-size: 12px; line-height: 14px; }
    .offers .offer-desc, .offers .offer-tags { display: none; }
    /* A tall tile has room for the description too, in small print */
    @container offer (min-height: 150px) {
      .offers .offer-desc { display: -webkit-box; -webkit-line-clamp: 4; font-size: 11px; line-height: 1.15; }
    }
    @container offer (min-height: 200px) { .offers .offer-desc { -webkit-line-clamp: 7; } }
  }
  .empty-offers { flex: 0 0 auto; }
}

/* ---------- Wide screens: the phone layout, wider, with sheets in the middle ---------- */
@media (min-width: 760px) {
  #app.screen-shop, #app.screen-play { max-width: 560px; }
  .sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 18px; padding-bottom: 20px; }
  @keyframes sheet-in { from { transform: translate(-50%, -46%); opacity: 0; } }
}

/* ---------- Admin stats page (admin.html) ---------- */
body.admin { overflow-y: auto; }
#admin { max-width: 960px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.admin-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.admin-days { width: min(280px, 100%); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .admin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile-value { font-size: 28px; line-height: 1.1; }
.tile small { font-size: 13px; color: var(--muted); }
.admin-card { padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.admin-card h2 { font-size: 22px; }
.admin-card p { color: var(--soft); font-size: 14px; }
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 180px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 14px; }
.bar-row:hover { background: rgba(255, 255, 255, .05); border-radius: 6px; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
.bar-track { height: 12px; }
.bar-mark { display: block; height: 100%; background: #b8870f; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; color: #fff; font-weight: 700; }
.bar-value small { margin-left: 6px; font-weight: 500; color: var(--muted); }
.cols { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid rgba(255, 255, 255, .15); }
.col { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 2px; }
.col:hover { background: rgba(255, 255, 255, .06); }
.col-mark { display: block; width: 100%; background: #b8870f; border-radius: 4px 4px 0 0; min-height: 1px; }
.cols-axis { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.admin details { font-size: 14px; color: var(--soft); }
.admin summary { cursor: pointer; color: var(--muted); }

/* ---------- Phone preview for admins (phone.html) ---------- */
body.phone-preview { height: 100vh; height: 100dvh; overflow: hidden; }
#phone { height: 100%; display: flex; flex-direction: column; }
.phone-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; padding: 12px 16px; background: var(--panel-deep); border-bottom: 3px solid var(--ink); position: relative; }
.phone-bar h1 { font-size: 22px; margin-right: auto; }
.phone-devices { width: min(560px, 100%); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.phone-devices button { min-height: 38px; font-size: 14px; }
.phone-size { font-variant-numeric: tabular-nums; }
.phone-bar .btn { min-height: 40px; font-size: 16px; }
.phone-stage { flex: 1; min-height: 0; padding: 20px 16px; display: flex; justify-content: center; align-items: flex-start; overflow: hidden; }
.phone-device { flex-shrink: 0; border: 12px solid #0b1211; border-radius: 44px; overflow: hidden; background: #000; box-shadow: 0 0 0 3px #2c3a38, 0 18px 50px rgba(0, 0, 0, .55); transform-origin: top center; }
.phone-device iframe { display: block; border: 0; }
.phone-preview #admin { width: 100%; }

/* Early access: the menu's badge (tap for a short note), and the note on the leaderboards */
.ea-badge {
  position: absolute; z-index: 3; cursor: pointer;
  background: var(--blue); color: #fff; border: 3px solid var(--ink); border-radius: 8px;
  padding: 2px 9px; transform: rotate(-8deg); box-shadow: 0 4px 0 var(--ink);
  text-shadow: 0 2px 0 rgba(0, 0, 0, .35);
}
.ea-badge:active { transform: rotate(-8deg) translateY(2px); box-shadow: 0 2px 0 var(--ink); }
.ea-tip {
  position: absolute; left: 50%; z-index: 4; width: min(300px, calc(100vw - 32px)); translate: -50% 0;
  display: flex; flex-direction: column; gap: 10px; align-items: flex-start; text-align: left;
  padding: 12px 14px; border-radius: 12px; border: 3px solid var(--blue); box-shadow: 0 5px 0 var(--ink);
  background: var(--panel); color: var(--soft); font-size: 14px; line-height: 1.4;
}
.ea-tip b { color: #fff; }
.lb-note { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--soft); padding: 0 2px; }
.ea-tag { flex-shrink: 0; padding: 0 6px; border-radius: 6px; background: var(--blue); color: #fff; font-size: 14px; }

/* Help sheet: the message form and the answers */
.help-form { display: flex; flex-direction: column; gap: 6px; }
.help-form .label small { font-weight: 500; letter-spacing: 0; }
.help-form select, .help-form textarea, .help-form input {
  min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 3px solid var(--ink);
  background: var(--card); color: var(--card-ink); font-family: var(--body); font-size: 16px; font-weight: 500;
}
.help-form textarea { resize: vertical; min-height: 96px; }
.help-form .btn { margin-top: 4px; }
.faq { display: flex; flex-direction: column; gap: 6px; }
.faq details { background: rgba(0, 0, 0, .2); border-radius: 10px; padding: 10px 12px; }
.faq summary { cursor: pointer; font-weight: 700; color: #fff; }
.faq p { margin-top: 6px; font-size: 14px; }
.feedback-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.feedback-list li { display: flex; flex-direction: column; gap: 4px; padding-bottom: 10px; border-bottom: 2px solid var(--panel-deep); }
.feedback-list p { white-space: pre-wrap; }
.feedback-list small { font-size: 12px; overflow-wrap: anywhere; }
