@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/assets/fonts/rubik-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Rubik';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url(/assets/fonts/rubik-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --font: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --felt-1: #1b7a53;
  --felt-2: #0f5a3c;
  --felt-3: #093a27;
  --ink: #f5f1e6;
  --ink-dim: rgba(245, 241, 230, 0.72);
  --sun: #ffd23f;
  --sun-ink: #3b2a00;
  --mint: #7dffb6;
  --t-red: #d7263d;
  --t-yellow: #e08e00;
  --t-blue: #1f5ed6;
  --t-black: #1f2328;
  --tw: 34px;
  --th: 46px;
  --mw: 26px;
  --mh: 35px;
  --pw: 38px;
  --ph: 51px;
  --gap: 3px;
  --cols: 10;
  --page: #fbf7ee;
  --page-ink: #1f2a24;
  --page-muted: #5d6a62;
  --page-line: #e7dfcc;
  --brand: #0f5a3c;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--page-ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

[hidden]:not(.start) {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ───────────────────────── game shell ───────────────────────── */

.game {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 520px;
  max-height: 1100px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% 38%, var(--felt-1) 0%, var(--felt-2) 55%, var(--felt-3) 100%);
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
}

.game::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: 0.32;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
}

.g-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.08));
  position: relative;
  z-index: 5;
}

.logo {
  display: inline-flex;
  gap: 2px;
  text-decoration: none;
  flex: none;
}

.logo .lt {
  width: 21px;
  height: 27px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  font: 800 15px/1 var(--font);
  background: linear-gradient(180deg, #fffefa, #f1e6c9);
  box-shadow: inset 0 -2px 0 rgba(160, 120, 60, 0.25), 0 1px 2px rgba(0, 0, 0, 0.35);
}

.lt.c0, .tile.c0 { color: var(--t-red); }
.lt.c1, .tile.c1 { color: var(--t-yellow); }
.lt.c2, .tile.c2 { color: var(--t-blue); }
.lt.c3, .tile.c3 { color: var(--t-black); }

.g-info {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-info b {
  color: var(--ink);
  font-weight: 700;
}

.g-tools {
  display: flex;
  gap: 4px;
  flex: none;
}

.ib {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.ib:hover { background: rgba(255, 255, 255, 0.18); }
.ib:active { transform: scale(0.94); }
.ib svg { width: 19px; height: 19px; }
.ib[aria-pressed='false'] .on,
.ib[aria-pressed='true'] .off { display: none; }

/* opponents */
.opps {
  display: flex;
  gap: 6px;
  padding: 4px 8px 2px;
  order: 1;
  position: relative;
  z-index: 3;
}

.opp {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 7px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.2);
  border: 0;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 0.25s, box-shadow 0.25s;
}

.opp.turn {
  background: rgba(255, 210, 63, 0.16);
  box-shadow: 0 0 0 1.5px rgba(255, 210, 63, 0.75), 0 4px 16px rgba(255, 210, 63, 0.18);
}

.av {
  --h: 200;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font: 800 14px/1 var(--font);
  color: #fff;
  background: radial-gradient(circle at 32% 28%, hsl(var(--h) 90% 72%), hsl(var(--h) 65% 42%) 70%);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.3);
  position: relative;
}

.opp-meta {
  min-width: 0;
  flex: 1;
  line-height: 1.15;
}

.opp-name {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.opp-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--ink-dim);
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px 1px 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
  font-weight: 600;
  color: var(--ink);
}

.chip.hot { background: #ff5d5d; color: #fff; }
.chip.ok { background: rgba(125, 255, 182, 0.2); color: var(--mint); }
.chip svg { width: 10px; height: 10px; }

.opp-disc {
  flex: none;
  min-width: var(--mw);
  min-height: var(--mh);
  display: grid;
  place-items: center;
}

.opp-disc:empty::before {
  content: '';
  width: var(--mw);
  height: var(--mh);
  border-radius: 5px;
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
}

.dots {
  position: absolute;
  right: -2px;
  bottom: -3px;
  display: none;
  gap: 2px;
  padding: 3px 4px;
  background: var(--sun);
  border-radius: 99px;
}

.opp.thinking .dots { display: flex; }

.dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sun-ink);
  animation: blink 1s infinite;
}

.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes blink {
  0%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* table with melds */
.tablezone {
  order: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.tz-empty {
  margin: auto;
  text-align: center;
  color: rgba(245, 241, 230, 0.5);
  font-size: 13px;
  max-width: 260px;
  line-height: 1.45;
}

.tz-empty b {
  display: block;
  font-size: 15px;
  color: rgba(245, 241, 230, 0.75);
  margin-bottom: 2px;
}

.mgroup {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mg-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}

.mg-label .av {
  width: 16px;
  height: 16px;
  font-size: 9px;
  box-shadow: none;
}

.mg-melds {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
}

.meld {
  display: inline-flex;
  gap: 1px;
  padding: 3px;
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.2);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.25);
  position: relative;
  transition: box-shadow 0.2s, background 0.2s;
}

.meld.fresh {
  background: rgba(255, 210, 63, 0.12);
  box-shadow: inset 0 0 0 1.5px rgba(255, 210, 63, 0.65);
}

.meld.can {
  cursor: pointer;
  background: rgba(125, 255, 182, 0.14);
  box-shadow: 0 0 0 2px var(--mint), 0 0 18px rgba(125, 255, 182, 0.35);
  animation: canpulse 1.6s ease-in-out infinite;
}

.meld.over {
  background: rgba(125, 255, 182, 0.28);
  transform: scale(1.03);
}

@keyframes canpulse {
  50% { box-shadow: 0 0 0 2px var(--mint), 0 0 4px rgba(125, 255, 182, 0.2); }
}

.meld .tile {
  --w: var(--mw);
  --h: var(--mh);
  cursor: default;
}

/* middle row: stock, atu, discard, status */
.mid {
  order: 3;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 10px 4px;
  position: relative;
  z-index: 2;
}

.pile {
  position: relative;
  flex: none;
  border: 0;
  padding: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: default;
}

.pile .lbl {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-dim);
  white-space: nowrap;
}

.pile-slot {
  width: var(--pw);
  height: var(--ph);
  display: grid;
  place-items: center;
  border-radius: 7px;
  position: relative;
}

.pile-slot:empty {
  border: 1.5px dashed rgba(255, 255, 255, 0.22);
}

.pile .tile {
  --w: var(--pw);
  --h: var(--ph);
}

.stack {
  position: relative;
  width: var(--pw);
  height: var(--ph);
}

.back {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--pw) * 0.16);
  background:
    radial-gradient(circle at 50% 45%, rgba(15, 90, 60, 0.18) 0 18%, transparent 19%),
    linear-gradient(180deg, #fffcf2, #efe2c2);
  box-shadow: inset 0 1px 0 #fff, inset 0 -2px 0 rgba(160, 120, 60, 0.25), 0 1px 0 rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.25);
}

.back:nth-child(1) { transform: translate(-3px, -4px); }
.back:nth-child(2) { transform: translate(-1.5px, -2px); }

.stack .cnt {
  position: absolute;
  right: -7px;
  top: -10px;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 99px;
  background: #0b2f20;
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.15);
  z-index: 2;
}

.pile.act {
  cursor: pointer;
}

.pile.act .pile-slot,
.pile.act .stack {
  animation: bob 1.4s ease-in-out infinite;
}

.pile.act .pile-slot::after,
.pile.act .stack::after {
  content: '';
  position: absolute;
  inset: -5px;
  border-radius: 11px;
  box-shadow: 0 0 0 2px var(--sun), 0 0 18px rgba(255, 210, 63, 0.55);
  pointer-events: none;
}

@keyframes bob {
  50% { transform: translateY(-3px); }
}

.atu-pile .tile::after {
  content: '★';
  position: absolute;
  top: -7px;
  right: -7px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--sun);
  color: var(--sun-ink);
  font-size: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.showatu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  border: 0;
  border-radius: 99px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 700;
  background: var(--sun);
  color: var(--sun-ink);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  animation: pop 0.35s cubic-bezier(0.2, 1.4, 0.4, 1) both, bob 1.4s 0.4s ease-in-out infinite;
  z-index: 4;
}

@keyframes pop {
  from { transform: translateX(-50%) scale(0.6); opacity: 0; }
}

.status {
  flex: 1;
  min-width: 0;
  align-self: center;
  text-align: center;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink);
  padding: 0 2px;
}

.status small {
  display: block;
  font-size: 11.5px;
  color: var(--ink-dim);
}

.meter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
  font-weight: 700;
}

.meter .bar {
  width: 54px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.meter .bar i {
  display: block;
  height: 100%;
  background: var(--sun);
  border-radius: 99px;
  transition: width 0.3s;
}

.meter.done .bar i { background: var(--mint); }
.meter.done { color: var(--mint); }

.mydisc .pile-slot {
  border: 1.5px dashed rgba(255, 255, 255, 0.28);
}

.mydisc.armed .pile-slot {
  border-color: var(--sun);
  background: rgba(255, 210, 63, 0.12);
  cursor: pointer;
}

.mydisc.over .pile-slot {
  background: rgba(255, 210, 63, 0.3);
  transform: scale(1.06);
}

/* action bar */
.actions {
  order: 4;
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 4px 8px 8px;
  position: relative;
  z-index: 3;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 13px;
  border: 0;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.13);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, transform 0.1s, opacity 0.2s;
}

.btn svg { width: 17px; height: 17px; flex: none; }
.btn:hover { background: rgba(255, 255, 255, 0.2); }
.btn:active { transform: scale(0.96); }

.btn:disabled {
  opacity: 0.38;
  cursor: default;
  transform: none;
}

.btn.primary {
  background: var(--sun);
  color: var(--sun-ink);
  box-shadow: 0 3px 0 #c99a12, 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn.primary:hover { background: #ffdb5c; }
.btn.primary:disabled { box-shadow: none; background: rgba(255, 210, 63, 0.35); }

.btn.mint {
  background: var(--mint);
  color: #053521;
  box-shadow: 0 3px 0 #3cc882, 0 6px 16px rgba(0, 0, 0, 0.25);
}

.btn .pts {
  font-size: 11.5px;
  padding: 1px 6px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.15);
}

.btn.icon-only { padding: 0 10px; }

/* rack */
.rack {
  order: 5;
  position: relative;
  z-index: 4;
  margin: 0 auto;
  width: 100%;
  max-width: calc(var(--cols) * var(--tw) + (var(--cols) - 1) * var(--gap) + 34px);
  padding: 7px 10px calc(6px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background:
    repeating-linear-gradient(92deg, rgba(255, 255, 255, 0.05) 0 2px, transparent 2px 11px, rgba(90, 45, 10, 0.05) 11px 13px, transparent 13px 23px),
    linear-gradient(180deg, #e9b874 0%, #cf9350 45%, #b0733a 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 -8px 24px rgba(0, 0, 0, 0.35);
}

.rack.dragging { z-index: 60; }

.rack-row {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tw));
  gap: var(--gap);
  justify-content: center;
  padding: 3px 0 8px;
  position: relative;
}

.rack-row::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -4px;
  bottom: 1px;
  height: 7px;
  border-radius: 4px;
  background: linear-gradient(180deg, #96602c, #6c4018);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.slot {
  width: var(--tw);
  height: var(--th);
  position: relative;
  z-index: 1;
  border-radius: calc(var(--tw) * 0.16);
}

.slot:empty {
  background: rgba(95, 50, 15, 0.12);
  box-shadow: inset 0 1px 2px rgba(60, 30, 5, 0.18);
}

.slot.over {
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.2);
}

.rack .tile {
  --w: var(--tw);
  --h: var(--th);
}

/* tiles */
.tile {
  --w: var(--tw);
  --h: var(--th);
  position: relative;
  width: var(--w);
  height: var(--h);
  padding: 0;
  border: 0;
  border-radius: calc(var(--w) * 0.16);
  background: linear-gradient(180deg, #fffefa 0%, #fbf4e3 55%, #f0e4c7 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -2px 0 rgba(160, 120, 60, 0.24),
    0 1px 0 rgba(0, 0, 0, 0.22),
    0 2px 4px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--h) * 0.05);
  font-family: var(--font);
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
  transition: transform 0.16s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.16s;
  outline: none;
}

.tile b {
  font-size: calc(var(--h) * 0.45);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.045em;
  margin-top: calc(var(--h) * 0.06);
  font-feature-settings: 'tnum' 0;
}

.tile i {
  width: calc(var(--w) * 0.19);
  height: calc(var(--w) * 0.19);
  border-radius: 50%;
  background: currentColor;
  opacity: 0.92;
}

.symbols .tile.c1 i { border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.symbols .tile.c2 i { border-radius: 1.5px; }
.symbols .tile.c3 i { border-radius: 0; transform: rotate(45deg) scale(0.85); }

.tile.jk svg {
  width: 82%;
  height: 82%;
}

.tile:focus-visible {
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--t-blue);
}

.rack .tile.sel {
  transform: translateY(-24%);
  box-shadow:
    inset 0 1px 0 #fff,
    inset 0 -2px 0 rgba(160, 120, 60, 0.24),
    0 0 0 2.5px var(--sun),
    0 10px 18px rgba(0, 0, 0, 0.35);
}

.rack .tile.ok::before {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: calc(var(--h) * -0.13);
  height: 3px;
  border-radius: 3px;
  background: var(--mint);
  box-shadow: 0 0 6px rgba(125, 255, 182, 0.8);
}

.tile.must {
  box-shadow:
    inset 0 1px 0 #fff,
    0 0 0 2.5px #ff8a3d,
    0 2px 6px rgba(0, 0, 0, 0.3);
}

.tile.fresh {
  animation: glow 1.4s ease-out 1;
}

@keyframes glow {
  0% { box-shadow: 0 0 0 3px #fff, 0 0 22px 6px rgba(255, 255, 255, 0.9); }
}

.tile.hint {
  animation: hintpulse 0.9s ease-in-out 4;
}

@keyframes hintpulse {
  50% { box-shadow: 0 0 0 3px #7dd3ff, 0 0 18px 4px rgba(125, 211, 255, 0.85); }
}

.tile.twin::after {
  content: '★';
  position: absolute;
  top: 1px;
  right: 2px;
  font-size: calc(var(--h) * 0.2);
  color: #d89a00;
  line-height: 1;
}

.tile.dragging {
  z-index: 100;
  cursor: grabbing;
  transition: none;
  box-shadow: 0 16px 30px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--sun);
}

/* opponent / meld mini tiles */
.opp-disc .tile {
  --w: var(--mw);
  --h: var(--mh);
  cursor: default;
}

.static .tile,
.tile.static {
  cursor: default;
}

/* toast */
.toast {
  position: absolute;
  left: 50%;
  top: 92px;
  transform: translate(-50%, calc(-100% + 10px));
  opacity: 0;
  max-width: min(92%, 420px);
  padding: 9px 15px;
  border-radius: 13px;
  background: rgba(10, 30, 21, 0.94);
  color: var(--ink);
  font-size: 13.5px;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.25s;
  z-index: 80;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -100%);
}

.toast.err { background: rgba(120, 22, 32, 0.96); }

.banner {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  padding: 14px 26px;
  border-radius: 18px;
  font-size: clamp(22px, 6vw, 34px);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--sun-ink);
  background: var(--sun);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  z-index: 90;
  pointer-events: none;
  white-space: nowrap;
  animation: bannerIn 1.8s cubic-bezier(0.2, 1.2, 0.3, 1) both;
}

@keyframes bannerIn {
  0% { transform: translate(-50%, -50%) scale(0.4) rotate(-6deg); opacity: 0; }
  18% { transform: translate(-50%, -50%) scale(1.06) rotate(1deg); opacity: 1; }
  28% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  82% { opacity: 1; }
  100% { transform: translate(-50%, -60%) scale(0.96); opacity: 0; }
}

/* popover chooser */
.chooser {
  position: absolute;
  z-index: 85;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 30, 21, 0.96);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.chooser .btn { height: 34px; font-size: 12.5px; }

.arrange-menu {
  position: absolute;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 30, 21, 0.97);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  min-width: 190px;
}

.arrange-menu .btn {
  justify-content: flex-start;
  background: transparent;
  font-weight: 600;
}

.arrange-menu .btn:hover { background: rgba(255, 255, 255, 0.1); }
.arrange-menu small { color: var(--ink-dim); font-weight: 500; margin-left: auto; padding-left: 10px; }

/* ghost tiles flying to hidden hands */
.ghost {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  margin: 0;
}

/* ───────────────────────── start screen ───────────────────────── */

.start {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: radial-gradient(100% 70% at 50% 30%, rgba(27, 122, 83, 0.55), rgba(5, 32, 21, 0.86));
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
  transition: opacity 0.3s, visibility 0.3s;
}

.start[hidden] {
  display: grid;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  width: 100%;
  max-width: 460px;
  text-align: center;
}

.hero-tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.hero-tiles .tile {
  --w: 46px;
  --h: 62px;
  cursor: default;
  animation: drop 0.6s cubic-bezier(0.2, 1.3, 0.35, 1) both;
}

.hero-tiles .tile b { font-size: 30px; }
.hero-tiles .tile i { display: none; }
.hero-tiles .tile:nth-child(2) { animation-delay: 0.07s; transform: rotate(-3deg); }
.hero-tiles .tile:nth-child(3) { animation-delay: 0.14s; }
.hero-tiles .tile:nth-child(4) { animation-delay: 0.21s; transform: rotate(3deg); }
.hero-tiles .tile:nth-child(5) { animation-delay: 0.28s; }

@keyframes drop {
  from { transform: translateY(-40px) rotate(-12deg); opacity: 0; }
}

.start h1 {
  margin: 0;
  font-size: clamp(30px, 8.5vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.start .lead {
  margin: 8px auto 16px;
  max-width: 400px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ink-dim);
}

.opts {
  display: grid;
  gap: 10px;
  text-align: left;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 18px;
  padding: 12px;
}

.opt-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin: 0 0 5px 2px;
}

.seg {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.seg button {
  flex: 1;
  border: 0;
  border-radius: 9px;
  padding: 8px 6px;
  background: transparent;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink-dim);
  transition: background 0.15s, color 0.15s;
}

.seg button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--felt-3);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.modes button {
  border: 0;
  text-align: left;
  border-radius: 13px;
  padding: 10px 11px;
  background: rgba(0, 0, 0, 0.25);
  cursor: pointer;
  box-shadow: inset 0 0 0 1.5px transparent;
  transition: box-shadow 0.15s, background 0.15s;
}

.modes button b {
  display: block;
  font-size: 14.5px;
}

.modes button span {
  display: block;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--ink-dim);
  margin-top: 2px;
}

.modes button[aria-pressed='true'] {
  background: rgba(255, 210, 63, 0.14);
  box-shadow: inset 0 0 0 1.5px var(--sun);
}

.start-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.start-actions .btn {
  height: 50px;
  font-size: 17px;
  border-radius: 15px;
}

.start-foot {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-dim);
}

.start-foot a {
  color: var(--ink);
}

.badges-row {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--ink-dim);
}

.badges-row span::before {
  content: '✓ ';
  color: var(--mint);
  font-weight: 700;
}

/* ───────────────────────── dialogs ───────────────────────── */

dialog {
  outline: none;
  border: 0;
  padding: 0;
  border-radius: 22px;
  width: min(94vw, 540px);
  max-height: 88vh;
  background: #10261c;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(3, 18, 11, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

dialog[open] {
  animation: dlgIn 0.28s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes dlgIn {
  from { transform: translateY(14px) scale(0.97); opacity: 0; }
}

.dlg {
  padding: 18px 18px 16px;
  overflow-y: auto;
  max-height: 88vh;
}

.dlg h2 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.dlg .sub {
  margin: 0 0 14px;
  color: var(--ink-dim);
  font-size: 14px;
}

.dlg-x {
  position: absolute;
  right: 10px;
  top: 10px;
}

.dlg-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.dlg-actions .btn {
  flex: 1;
  height: 46px;
  font-size: 15px;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.score-table th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  text-align: right;
  padding: 0 4px 6px;
}

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

.score-table td {
  padding: 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: right;
  vertical-align: top;
  font-variant-numeric: tabular-nums;
}

.score-table td.total {
  font-weight: 800;
  font-size: 15px;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.who .av {
  width: 26px;
  height: 26px;
  font-size: 12px;
}

.score-table .detail { display: none; }

@media (min-width: 520px) {
  .score-table .detail { display: table-cell; }
  .score-table .brk { display: none; }
}

.notes {
  display: block;
  font-size: 11.5px;
  color: var(--ink-dim);
  font-weight: 500;
}

.pos { color: var(--mint); }
.neg { color: #ff8b8b; }

.reveal {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 6px;
}

.reveal .tile {
  --w: 22px;
  --h: 30px;
  cursor: default;
}

.reveal .tile b { font-size: 14px; }

.standings {
  display: grid;
  gap: 8px;
  margin: 6px 0 4px;
}

.standing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.standing.first {
  background: rgba(255, 210, 63, 0.16);
  box-shadow: inset 0 0 0 1.5px rgba(255, 210, 63, 0.6);
}

.standing .rank {
  width: 22px;
  font-weight: 800;
  color: var(--ink-dim);
}

.standing .pts {
  margin-left: auto;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}

.set-list {
  display: grid;
  gap: 12px;
}

.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14.5px;
}

.set-row small {
  display: block;
  color: var(--ink-dim);
  font-size: 12px;
}

.switch {
  position: relative;
  width: 46px;
  height: 28px;
  flex: none;
  border-radius: 99px;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition: background 0.2s;
}

.switch::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.switch[aria-checked='true'] { background: #2fbf71; }
.switch[aria-checked='true']::after { transform: translateX(18px); }

.menu-list {
  display: grid;
  gap: 6px;
}

.menu-list .btn {
  justify-content: flex-start;
  height: 48px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.07);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 4px;
}

.stat {
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.stat b {
  display: block;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.stat span {
  font-size: 12px;
  color: var(--ink-dim);
}

.help-body {
  font-size: 14px;
  line-height: 1.55;
  color: rgba(245, 241, 230, 0.9);
}

.help-body h3 {
  font-size: 14px;
  margin: 14px 0 4px;
  color: var(--sun);
  letter-spacing: 0.01em;
}

.help-body ul {
  margin: 4px 0;
  padding-left: 18px;
}

.help-body a { color: var(--ink); }

.disc-history {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.disc-history .tile {
  --w: 28px;
  --h: 38px;
  cursor: default;
}

/* confetti */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
}

/* ───────────────────────── responsive game layouts ───────────────────────── */

@media (max-width: 519px) {
  .opps { gap: 5px; padding: 4px 6px 2px; }
  .opp { gap: 5px; padding: 4px 5px 4px 4px; }
  .opp .av { width: 28px; height: 28px; font-size: 13px; }
}

@media (min-width: 720px) {
  .g-head { padding: 10px 18px; }
  .logo .lt { width: 25px; height: 32px; font-size: 18px; }
  .g-info { font-size: 14px; }
  .opps { max-width: 980px; margin: 0 auto; width: 100%; gap: 10px; padding: 6px 16px 2px; }
  .opp { padding: 8px 12px; gap: 10px; }
  .av { width: 40px; height: 40px; font-size: 17px; }
  .opp-name { font-size: 14.5px; }
  .opp-sub { font-size: 12.5px; }
  .tablezone { max-width: 1040px; width: 100%; margin: 0 auto; padding: 12px 18px; }
  .mid { max-width: 980px; width: 100%; margin: 0 auto; gap: 14px; padding: 8px 16px 6px; }
  .status { font-size: 15px; }
  .status small { font-size: 13px; }
  .btn { height: 42px; font-size: 14.5px; padding: 0 16px; }
  .actions { gap: 8px; padding-bottom: 10px; }
  .toast { font-size: 14.5px; }
  .meld { padding: 4px; gap: 2px; }
  .mg-melds { gap: 8px 12px; }
}

/* short landscape phones: piles in a side column, opponents across the top */
.side { display: contents; }

@media (max-height: 540px) and (orientation: landscape) {
  .game {
    display: grid;
    grid-template-columns: minmax(150px, 22%) 1fr;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      'head head'
      'side opps'
      'side table'
      'side actions'
      'rack rack';
    min-height: 300px;
  }
  .g-head { grid-area: head; padding: 3px 10px; padding-top: max(3px, env(safe-area-inset-top)); }
  .logo .lt { width: 17px; height: 22px; font-size: 12px; }
  .ib { width: 30px; height: 30px; }
  .opps { grid-area: opps; padding: 2px 8px 0; gap: 6px; }
  .opp { padding: 3px 8px; }
  .av { width: 26px; height: 26px; font-size: 12px; }
  .mid {
    grid-area: side;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-content: center;
    justify-items: center;
    gap: 6px 4px;
    padding: 4px 4px 4px max(6px, env(safe-area-inset-left));
  }
  .mid .status { grid-column: 1 / -1; order: -1; font-size: 12px; }
  .meter { margin-top: 2px; }
  .tablezone { grid-area: table; padding: 6px 10px; }
  .actions { grid-area: actions; padding: 2px 8px 4px; }
  .btn { height: 32px; font-size: 12.5px; padding: 0 10px; }
  .rack { grid-area: rack; padding: 4px 10px calc(3px + env(safe-area-inset-bottom)); }
  .rack-row { padding: 2px 0 6px; }
}

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

/* ───────────────────────── page content ───────────────────────── */

.ad-slot {
  display: none;
  max-width: 980px;
  margin: 18px auto;
  padding: 0 16px;
  text-align: center;
}

.ad-slot.on {
  display: block;
  min-height: 120px;
}

.ad-slot .ad-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--page-muted);
  margin-bottom: 4px;
}

.content {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 40px;
}

.content > section + section {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--page-line);
}

.content h2 {
  font-size: clamp(24px, 5vw, 32px);
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin: 0 0 12px;
  color: #13261d;
}

.content h3 {
  font-size: 19px;
  letter-spacing: -0.01em;
  margin: 26px 0 8px;
  color: #13261d;
}

.content p,
.content li {
  font-size: 16.5px;
  color: #2c3a33;
}

.content a { color: var(--brand); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }

.content .kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 6px;
}

.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 6px;
  padding: 0;
  list-style: none;
}

.toc a {
  display: inline-block;
  padding: 7px 13px;
  border-radius: 99px;
  background: #fff;
  border: 1px solid var(--page-line);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--page-ink);
}

.toc a:hover { border-color: var(--brand); }

.vtable {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 6px;
  font-size: 15.5px;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--page-line);
}

.vtable th,
.vtable td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--page-line);
}

.vtable th {
  background: #f4eedf;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--page-muted);
}

.vtable tr:last-child td { border-bottom: 0; }
.vtable td:last-child { font-weight: 700; white-space: nowrap; }

.example {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  margin: 12px 0;
  padding: 14px;
  border-radius: 16px;
  background: linear-gradient(135deg, #165f41, #0d4630);
  color: var(--ink);
}

.example .ex-tiles {
  display: flex;
  gap: 2px;
}

.example .tile {
  --w: 30px;
  --h: 40px;
  cursor: default;
}

.example .ex-txt {
  font-size: 14px;
  line-height: 1.4;
  color: var(--ink-dim);
}

.example .ex-txt b { color: var(--ink); }

.tips {
  counter-reset: tip;
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 12px;
}

.tips li {
  counter-increment: tip;
  position: relative;
  padding: 14px 16px 14px 56px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 0 0 1px var(--page-line);
}

.tips li::before {
  content: counter(tip);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--t-red);
  background: linear-gradient(180deg, #fffefa, #f1e6c9);
  box-shadow: inset 0 -2px 0 rgba(160, 120, 60, 0.25), 0 1px 2px rgba(0, 0, 0, 0.2);
}

.tips li:nth-child(4n + 2)::before { color: var(--t-yellow); }
.tips li:nth-child(4n + 3)::before { color: var(--t-blue); }
.tips li:nth-child(4n + 4)::before { color: var(--t-black); }

.tips strong { display: block; color: #13261d; margin-bottom: 2px; }

.faq details {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 0 0 1px var(--page-line);
  margin: 8px 0;
}

.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 44px 14px 16px;
  font-weight: 700;
  font-size: 16px;
  position: relative;
}

.faq summary::-webkit-details-marker { display: none; }

.faq summary::after {
  content: '+';
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 22px;
  font-weight: 500;
  color: var(--brand);
  transition: transform 0.2s;
}

.faq details[open] summary::after { transform: translateY(-50%) rotate(45deg); }

.faq details > div {
  padding: 0 16px 14px;
}

.faq details p { margin: 0; }

.cta-band {
  margin-top: 40px;
  padding: 22px;
  border-radius: 20px;
  background: radial-gradient(120% 120% at 20% 0%, #1d7c55, #0b3d29);
  color: var(--ink);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.cta-band p { margin: 0; color: var(--ink); font-size: 17px; font-weight: 600; }

.cta-band .btn { height: 46px; font-size: 15.5px; text-decoration: none; }

.site-foot {
  border-top: 1px solid var(--page-line);
  padding: 24px 20px 36px;
  text-align: center;
  font-size: 14px;
  color: var(--page-muted);
}

.site-foot nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-bottom: 8px;
}

.site-foot a { color: var(--page-ink); }

/* plain pages (privacy, 404) */
.page-head {
  background: radial-gradient(120% 120% at 50% 0%, var(--felt-1), var(--felt-3));
  color: var(--ink);
  padding: 16px 20px;
}

.page-head .wrap {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.page-head .btn { text-decoration: none; height: 40px; }

.score-table .detail-notes { display: none; }
@media (min-width: 520px) {
  .score-table .detail-notes { display: block; }
}
