/* Layout: a mahjong table seen from your seat, drawn on a fixed 1280×720 stage that is
   scaled to fit the window (PC first; phones play it sideways). Opponents sit right, across
   and left; each player's discards lie in front of them around the centre panel, and your
   hand runs along the bottom edge. There is no log: players speak in bubbles.
   Playing cards are drawn as mahjong tiles: ivory face, bamboo-green back, a visible thickness. */
:root {
  --felt: #0e3a2f;
  --felt-deep: #0a2c23;
  --felt-line: #1d5443;
  --rail: #1a1410;
  --ivory: #f2ecdc;
  --ivory-shade: #d8ceb3;
  --bamboo: #3f8a5c;
  --bamboo-deep: #2b6643;
  --ink: #1d1a16;
  --red: #b8322a;
  --gold: #e0b04a;
  --gold-deep: #b7862a;
  --text: #e9f1ec;
  --muted: #9cbcae;
  --danger: #ef8a7c;
  --good: #8fd6a5;
  --font-display: "Dela Gothic One", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-body: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --font-brush: "Yuji Syuku", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --fx-ink: #0b0908;
  --fx-ink-red: #6e1310;
  --tile-w-lg: 84px;
  --tile-w-xs: 36px;
  --tile-w-md: clamp(44px, 11vw, 60px);
  --rail-wood: #2a1c12;
  --plate: rgba(8, 16, 13, 0.86);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 40%, #13241d 0%, #070d0b 80%) fixed, #070d0b;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}
button { font: inherit; color: inherit; }
button:focus-visible, .tile:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.logo { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.04em; color: var(--ivory); }
.logo span { color: var(--gold); margin-left: 0.15em; }
.glyph {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 1.05rem;
  background: var(--ivory); color: var(--ink);
  box-shadow: 0 3px 0 var(--ivory-shade);
}
.label { font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.dealer {
  font-size: 0.68rem; font-weight: 700; padding: 0 5px; border-radius: 3px;
  background: var(--red); color: var(--ivory); letter-spacing: 0.05em;
}
.near { font-family: var(--font-num); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.mood { font-size: 0.7rem; padding: 1px 7px; border-radius: 999px; border: 1px solid currentColor; }
.mood.survival { color: var(--danger); }
.mood.steady { color: var(--muted); }
.mood.comfortable { color: var(--gold); }
.dots { display: inline-flex; gap: 5px; padding-block: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); 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; } 50% { opacity: 1; } }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 8px; height: 8px; border-radius: 2px; background: var(--felt-line); }
.pips i.done { background: var(--muted); }
.pips i.now { background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.stack { display: inline-grid; }
.stack i { display: block; width: 18px; height: 5px; margin-top: -1px; border-radius: 2px; background: var(--bamboo); box-shadow: 0 1px 0 var(--ivory-shade); }

/* ---- the stage -------------------------------------------------------- */
#viewport { position: fixed; inset: 0; overflow: hidden; }
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 1280px; height: 720px;
  transform: translate(-50%, -50%) scale(var(--s, 1));
  font-size: 18px;
}
.table { position: absolute; inset: 0; }
.felt {
  position: absolute; inset: 6px;
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 44%, #15523f 0%, var(--felt) 45%, var(--felt-deep) 100%);
  box-shadow:
    0 0 0 10px var(--rail-wood),
    0 0 0 12px #000,
    inset 0 0 80px rgba(0, 0, 0, 0.55),
    0 20px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.felt::after { /* faint weave */
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.012) 0 2px, transparent 2px 5px);
}
.watermark {
  position: absolute; left: 50%; top: 300px; transform: translate(-50%, -50%);
  font-family: var(--font-display); font-size: 150px; letter-spacing: 0.06em; white-space: nowrap;
  color: rgba(0, 0, 0, 0.13); pointer-events: none;
}
.watermark span { margin-left: 0.2em; }
#board, #mine { position: absolute; inset: 0; pointer-events: none; }
#board > *, #mine > * { pointer-events: auto; }

/* HUD: logo and buttons in the top corners of the felt */
.hud {
  position: absolute; left: 26px; right: 26px; top: 16px;
  display: flex; align-items: center; gap: 10px; pointer-events: none;
}
.hud > * { pointer-events: auto; }
.hud .logo { margin: 0; font-size: 26px; text-shadow: 0 2px 0 #000; }
.hud .spacer { flex: 1; }
.chip-btn {
  min-height: 40px; padding: 0 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(224, 176, 74, 0.45); background: rgba(0, 0, 0, 0.35);
  color: var(--ivory); font-size: 16px; font-weight: 700;
}
.chip-btn:hover { border-color: var(--gold); color: var(--gold); }
.sound-btn { min-width: 5.2em; }

/* centre panel: hand number, cards left, and each seat's points facing that seat */
.compass {
  position: absolute; width: 220px; height: 220px; border-radius: 24px;
  background: linear-gradient(160deg, #10201a, #050a08);
  box-shadow: 0 0 0 3px #000, 0 0 0 5px rgba(224, 176, 74, 0.35), 0 12px 30px rgba(0, 0, 0, 0.55), inset 0 0 24px rgba(0, 0, 0, 0.8);
}
.compass .edge { position: absolute; inset: 0; pointer-events: none; }
.e-pts {
  position: absolute; left: 0; right: 0; bottom: 18px; text-align: center;
  font-family: var(--font-num); font-weight: 600; font-size: 24px; color: var(--ivory);
  display: flex; justify-content: center; align-items: center; gap: 6px;
}
.e-dealer {
  font-style: normal; font-family: var(--font-body); font-size: 13px; font-weight: 700;
  padding: 0 5px; border-radius: 4px; background: var(--red); color: var(--ivory);
}
.lamp {
  position: absolute; left: 36px; right: 36px; bottom: 7px; height: 5px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
}
.edge.turn .lamp { background: var(--gold); box-shadow: 0 0 14px 2px rgba(224, 176, 74, 0.8); animation: lamp 1.2s ease-in-out infinite; }
.edge.turn .e-pts { color: var(--gold); }
.c-mid {
  position: absolute; inset: 58px; display: grid; place-items: center; align-content: center; gap: 4px; text-align: center;
}
.c-hand { white-space: nowrap; font-family: var(--font-brush); font-size: 32px; line-height: 1; color: var(--gold); text-shadow: 0 2px 0 #000; }
.c-wall { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); font-family: var(--font-num); }

/* discards: identical boxes turned to face their owner; the first row is nearest the centre */
.river, .backs { position: absolute; display: flex; flex-wrap: wrap; align-content: flex-start; }
.river { gap: 3px; min-height: 104px; padding: 2px; border-radius: 8px; transition: background 0.2s; }
.river.turn { background: rgba(224, 176, 74, 0.07); }
.river .tile.sideways { margin-inline: 7px; }
.backs { gap: 4px; justify-content: center; }

/* nameplates */
.np {
  position: absolute; width: 270px;
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 10px 14px 10px 10px; border-radius: 16px;
  background: var(--plate);
  border: 1px solid rgba(224, 176, 74, 0.28);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s;
}
.np.active { border-color: var(--gold); animation: pulse 1.6s ease-in-out infinite; }
.avatar {
  width: 80px; height: 80px; margin: -8px 0 -8px -4px; border-radius: 50%;
  display: block; position: relative;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.6));
}
.avatar .face { width: 100%; height: 100%; display: block; }
.np.active .avatar { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: none; } 50% { transform: translateY(-3px) scale(1.04); } }
.face.mini { width: 26px; height: 26px; vertical-align: middle; margin-right: 6px; }
.standings .nm { display: flex; align-items: center; min-width: 0; }
.np-body { display: grid; gap: 1px; min-width: 0; }
.np p { margin: 0; }
.np-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 700; font-size: 19px; line-height: 1.25; }
.np-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.np-name .dealer { font-size: 13px; padding: 0 6px; }
.np-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-sub .mood { font-size: 12px; }
.np-pts { display: flex; align-items: baseline; gap: 6px; line-height: 1.1; }
.np-pts b { font-family: var(--font-num); font-size: 30px; font-weight: 600; color: var(--ivory); font-variant-numeric: tabular-nums; }
.np-pts small { font-size: 13px; color: var(--muted); }
.np-pts .near { font-size: 14px; margin-left: 4px; }
.np .wallet { font-size: 12px; }

/* riichi stick: white bar with a red dot, laid along the bottom of the nameplate */
.stick {
  position: absolute; right: 16px; bottom: -6px; width: 92px; height: 12px; border-radius: 6px;
  background: var(--ivory); display: grid; place-items: center;
  box-shadow: 0 3px 0 var(--ivory-shade), 0 0 0 2px #000;
}
.stick span { width: 8px; height: 8px; border-radius: 50%; background: var(--red); }

/* speech bubbles instead of a log. They sit over the character's portrait and point at it:
   above for you and the player on the left, below for the player on the right (the player
   across sits just above them), to the right for the player across (top edge). */
.speech {
  --bubble: var(--ivory);
  position: absolute; left: 4px; bottom: calc(100% + 12px); z-index: 8; width: max-content; max-width: 300px;
  margin: 0; padding: 10px 14px; border-radius: 14px;
  background: var(--bubble); color: var(--ink); font-size: 16px; font-weight: 500; line-height: 1.4;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
  animation: speech 7s ease both;
}
.speech::before {
  content: ""; position: absolute; left: 30px; bottom: -9px;
  border: 10px solid transparent; border-bottom: 0; border-top-color: var(--bubble);
}
.np.s3 .speech { max-width: 290px; }
.np.s1 .speech { bottom: auto; top: calc(100% + 12px); }
.np.s1 .speech::before { bottom: auto; top: -9px; border: 10px solid transparent; border-top: 0; border-bottom-color: var(--bubble); }
.np.s2 .speech { left: calc(100% + 16px); bottom: auto; top: 6px; max-width: 200px; }
.np.s2 .speech::before { left: -9px; bottom: auto; top: 18px; border: 10px solid transparent; border-left: 0; border-right-color: var(--bubble); }
.speech.thinking { animation: speech-in 0.2s ease both; padding: 8px 14px; }
.speech.thinking .dots i { background: var(--ink); }

/* your side: status line, hand, buttons */
.status {
  position: absolute; left: 50%; top: 534px; transform: translateX(-50%);
  margin: 0; padding: 6px 20px; border-radius: 999px; max-width: 640px; width: max-content;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(224, 176, 74, 0.35);
  font-size: 17px; text-align: center; text-wrap: balance;
}
.status.empty { display: none; }
.hand {
  position: absolute; left: 300px; right: 370px; top: 590px;
  display: flex; justify-content: center; align-items: flex-end; gap: 8px;
}
.hand .gap { width: 16px; }
.hand .tile.lg { box-shadow: 0 5px 0 var(--bamboo-deep), 0 10px 18px rgba(0, 0, 0, 0.55); }
.hand .tile.lg.win { box-shadow: 0 5px 0 var(--gold-deep), 0 0 0 3px var(--gold), 0 0 24px rgba(224, 176, 74, 0.7); }
.hand button.tile.selected { box-shadow: 0 5px 0 var(--gold-deep), 0 0 0 3px var(--gold), 0 10px 18px rgba(0, 0, 0, 0.55); }
.hand .mark { width: 24px; height: 24px; font-size: 13px; top: -9px; right: -9px; }
.plus { font-family: var(--font-num); color: var(--gold); align-self: center; font-size: 28px; }
.actions {
  position: absolute; right: 26px; bottom: 26px;
  display: flex; gap: 12px; align-items: flex-end;
}
.act {
  min-height: 44px; padding: 0 20px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--muted); background: rgba(0, 0, 0, 0.2); font-weight: 700;
}
.act:hover:not(:disabled) { border-color: var(--text); }
.act.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.act.gold:hover:not(:disabled) { background: #ecc066; }
.act:disabled { opacity: 0.35; cursor: not-allowed; }
.act.big {
  min-width: 150px; min-height: 66px; padding: 0 22px; border-radius: 14px; font-size: 22px;
  background: rgba(0, 0, 0, 0.6); border: 2px solid rgba(233, 241, 236, 0.5);
  box-shadow: 0 6px 0 #000, 0 10px 20px rgba(0, 0, 0, 0.4);
}
.act.big.gold { background: linear-gradient(180deg, #f3cd72, var(--gold) 55%, var(--gold-deep)); border-color: #ffe39d; color: var(--ink); }
.act.big:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 3px 0 #000; }
.act.big.call { min-width: 180px; font-family: var(--font-brush); font-size: 34px; animation: call 0.9s ease-in-out infinite alternate; }

/* phones held upright: the table still fits, but sideways is much bigger */
.rotate-hint {
  display: none; position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  margin: 0; padding: 8px 16px; border-radius: 999px; width: max-content; max-width: calc(100% - 32px); text-align: center;
  background: rgba(0, 0, 0, 0.75); border: 1px solid var(--gold-deep); color: var(--ivory); font-size: 13px; z-index: 30;
}
@media (orientation: portrait) and (max-width: 820px) {
  body.at-table .rotate-hint { display: block; }
}

/* ---- tiles ------------------------------------------------------------ */
.tile {
  --w: var(--tile-w-xs);
  width: var(--w); height: calc(var(--w) * 1.36);
  position: relative; flex: none;
  display: inline-grid; grid-template-rows: 1fr 1fr; place-items: center;
  border: 0; padding: 0;
  border-radius: calc(var(--w) * 0.14);
  background: linear-gradient(180deg, #fbf7ec, var(--ivory));
  color: var(--ink);
  box-shadow: 0 calc(var(--w) * 0.07) 0 var(--bamboo-deep), 0 calc(var(--w) * 0.07 + 1px) 3px rgba(0, 0, 0, 0.45);
  font-family: var(--font-display);
  line-height: 1;
  user-select: none;
}
.tile.xs { --w: var(--tile-w-xs); }
.tile.lg { --w: var(--tile-w-lg); }
.tile.md { --w: var(--tile-w-md); }
.tile.bk { --w: 36px; }
.tile .rank { font-size: calc(var(--w) * 0.46); align-self: end; }
.tile .suit { font-size: calc(var(--w) * 0.42); align-self: start; font-family: var(--font-body); }
.tile.red { color: var(--red); }
.tile.joker { background: linear-gradient(180deg, #2a2420, var(--ink)); color: var(--gold); grid-template-rows: 1fr auto; }
.tile.joker .j-word { font-size: calc(var(--w) * 0.2); letter-spacing: 0.08em; writing-mode: vertical-rl; align-self: center; }
.tile.joker .j-mult { font-family: var(--font-num); font-size: calc(var(--w) * 0.22); font-weight: 600; padding-bottom: calc(var(--w) * 0.08); }
.tile.back {
  background: linear-gradient(180deg, var(--bamboo), var(--bamboo-deep));
  box-shadow: 0 calc(var(--w) * 0.07) 0 var(--ivory-shade), 0 calc(var(--w) * 0.07 + 1px) 3px rgba(0, 0, 0, 0.45);
}
.tile.sideways { transform: rotate(90deg); margin-inline: calc(var(--w) * 0.18); }
.tile.fresh { outline: 2px solid var(--gold); outline-offset: 1px; }
.tile.win { box-shadow: 0 calc(var(--w) * 0.07) 0 var(--gold-deep), 0 0 0 2px var(--gold); }
button.tile { cursor: pointer; transition: transform 0.12s ease; }
button.tile:hover { transform: translateY(-4px); }
button.tile.selected { transform: translateY(-12px); box-shadow: 0 calc(var(--w) * 0.07) 0 var(--gold-deep), 0 0 0 2px var(--gold); }
.mark {
  position: absolute; top: -7px; right: -7px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gold); color: var(--ink);
  font-family: var(--font-num); font-size: 0.68rem; font-weight: 700;
}

/* ---- overlays --------------------------------------------------------- */
#overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(6, 22, 17, 0.72);
  backdrop-filter: blur(2px);
  overflow-y: auto;
}
.sheet {
  width: min(560px, 100%); margin-block: auto; flex: none;
  background: var(--rail); border: 1px solid var(--felt-line); border-radius: 14px;
  padding: 24px; display: grid; gap: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.sheet h1, .sheet h2, .sheet h3 { margin: 0; text-wrap: balance; }
.sheet h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; }
.sheet h3 { font-size: 0.85rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sheet p { margin: 0; }
.sheet .row { display: flex; gap: 10px; flex-wrap: wrap; }
.eyebrow { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); }
.intro .logo { font-size: clamp(1.9rem, 8.4vw, 3.6rem); line-height: 1; }
.intro > * { min-width: 0; }
.intro { position: relative; width: min(640px, 100%); }
.picker { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pick { padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; opacity: 0.55; transition: opacity 0.15s, transform 0.15s; }
.pick img { display: block; width: 100%; height: auto; }
.pick:hover { opacity: 0.9; transform: translateY(-2px); }
.pick.on { opacity: 1; transform: scale(1.06); filter: drop-shadow(0 0 10px rgba(224, 176, 74, 0.8)); }
.picked { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); }
.picked img { width: 72px; height: 72px; flex: none; }
.picked p { margin: 0; font-size: 0.9rem; color: var(--muted); }
.picked b { color: var(--text); font-size: 1.05rem; }
.picked em { font-style: normal; color: var(--gold); font-size: 0.8rem; margin-left: 6px; }
.sheet-tools { position: absolute; top: 14px; right: 14px; display: flex; gap: 8px; }
.sheet-tools .act { border-color: var(--muted) !important; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 0.85rem; }
.tagline { font-size: 1.05rem; }
.note { color: var(--muted); font-size: 0.85rem; }
.note code { font-family: var(--font-num); color: var(--text); }
.rivals { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rivals li { display: flex; gap: 12px; align-items: flex-start; font-size: 0.88rem; color: var(--muted); }
.rivals b { color: var(--text); }
.rivals em { font-style: normal; color: var(--gold); font-size: 0.78rem; margin-left: 4px; }
.hand.show { position: static; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
.calc { font-family: var(--font-num); font-size: 1rem; }
.calc b { color: var(--gold); font-size: 1.2rem; }
.calc small { font-family: var(--font-body); color: var(--muted); }
.gold-text { color: var(--gold); }
.transfers { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.88rem; }
.standings { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.standings li {
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline;
  padding: 6px 8px; border-radius: 6px; background: rgba(255, 255, 255, 0.03);
}
.final .standings li { grid-template-columns: 22px minmax(0, 1fr) auto auto auto; }
.standings li.me { background: rgba(224, 176, 74, 0.12); }
.place { font-family: var(--font-display); color: var(--gold); }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; text-align: right; }
.diff.up { color: var(--good); }
.diff.down { color: var(--danger); }
.standings .near { color: var(--text); font-size: 0.85rem; }
.rules ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.9rem; }
.scores { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.scores td { padding: 4px 0; border-bottom: 1px solid var(--felt-line); }
.scores tr.jk td { color: var(--gold); }

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

/* ---- on-chain ---------------------------------------------------------- */
.wallet { font-family: var(--font-num); font-size: 0.72rem; color: var(--gold); flex-basis: 100%; font-variant-numeric: tabular-nums; }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.88rem; color: var(--muted); }
.steps li:last-child { color: var(--text); }
.steps a, .eyebrow a { color: var(--gold); text-decoration: none; border-bottom: 1px solid currentColor; }
.steps li.busy { list-style: none; }
.error { color: var(--danger); font-size: 0.9rem; }
.act.ghost { border-color: transparent; }

/* ---- lobby ------------------------------------------------------------- */
.lobby { display: grid; gap: 12px; }
.lobby .row.join { align-items: center; }
.code { font-family: var(--font-num); font-size: 2.4rem; font-weight: 600; letter-spacing: 0.3em; color: var(--gold); margin: 0; line-height: 1; }
.code-input, .nick-input {
  min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--muted);
  background: rgba(0, 0, 0, 0.25); color: var(--text); font: inherit;
}
.code-input { width: 7.5em; font-family: var(--font-num); letter-spacing: 0.25em; text-transform: uppercase; }
.nick-row { display: grid; gap: 4px; }
.nick-input { width: min(100%, 20em); }
.code-input:focus-visible, .nick-input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.members { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.members li { padding: 8px 10px; border-radius: 6px; background: rgba(255, 255, 255, 0.05); overflow-wrap: anywhere; }
.members li.empty { color: var(--muted); border: 1px dashed var(--felt-line); background: transparent; }
.glyph.human { background: var(--gold); box-shadow: 0 3px 0 var(--gold-deep); font-family: var(--font-body); font-weight: 700; }

/* ---- effects ------------------------------------------------------------ */
#fx { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }

.cutin { position: absolute; inset: 0; display: grid; place-items: center; animation: cut-fade 0.18s ease-out both; }
.cutin.out { animation: cut-out 0.28s ease-in both; }
.cutin .rays { position: absolute; left: 50%; top: 50%; translate: -50% -50%; width: 160vmax; height: 160vmax; fill: rgba(224, 176, 74, 0.13); animation: spin 6s linear infinite; }
.cutin .band {
  position: absolute; left: -10vw; top: 50%; translate: 0 -50%; width: 120vw; min-height: clamp(150px, 30vh, 260px);
  display: flex; align-items: center; justify-content: center; gap: clamp(8px, 3vw, 40px);
  transform: skewY(-6deg);
  animation: band-in 0.32s cubic-bezier(.2,.9,.3,1.2) both;
}
.cutin .ink { position: absolute; inset: -10% 0; width: 100%; height: 120%; filter: drop-shadow(0 10px 30px rgba(0,0,0,0.6)); }
.cutin .words { position: relative; display: grid; justify-items: center; transform: skewY(6deg); text-align: center; }
.cutin .title {
  font-family: var(--font-brush); font-size: clamp(4rem, 20vw, 11rem); line-height: 0.95; color: var(--ivory);
  text-shadow: 0 0 2px #000, 4px 4px 0 var(--red), 0 0 40px rgba(224, 176, 74, 0.6);
  animation: brush 0.45s cubic-bezier(.2,1.4,.4,1) 0.08s both;
}
.cutin-ron .title, .cutin-yakuman .title { color: var(--gold); }
.cutin .kanji { font-family: var(--font-brush); font-size: clamp(1.1rem, 4vw, 2rem); color: var(--gold); letter-spacing: 0.4em; margin-top: 4px; }
.cutin .sub {
  margin-top: 10px; padding: 4px 14px; border: 2px solid var(--red); color: var(--ivory); background: rgba(110, 19, 16, 0.85);
  font-weight: 700; font-size: clamp(0.9rem, 3vw, 1.2rem); transform: rotate(-3deg);
  animation: stamp 0.3s cubic-bezier(.3,1.6,.5,1) 0.4s both;
}
.cutin .who { font-weight: 700; color: var(--gold); letter-spacing: 0.12em; font-size: clamp(0.85rem, 2.6vw, 1.1rem); margin-bottom: 6px; padding: 1px 10px; border-bottom: 1px solid currentColor; }
.cutin .portrait { position: relative; transform: skewY(6deg); width: clamp(100px, 20vw, 230px); flex: none; animation: slide-in 0.4s cubic-bezier(.2,1,.3,1) both; }
.cutin .portrait img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6)); }
.cutin-riichi .portrait { width: clamp(80px, 14vw, 150px); }
.cutin-riichi .band { min-height: clamp(110px, 20vh, 170px); }
.cutin-riichi .title { font-size: clamp(3rem, 14vw, 7rem); color: var(--ivory); }
.cutin-yakuman .title { font-size: clamp(4.5rem, 24vw, 13rem); animation: brush 0.6s cubic-bezier(.2,1.4,.4,1) 0.1s both, glow 0.9s ease-in-out 0.7s infinite alternate; }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  display: grid; justify-items: center; padding: 10px 60px; width: max-content; max-width: 100vw;
  background: linear-gradient(90deg, transparent, rgba(11, 9, 8, 0.85) 20%, rgba(11, 9, 8, 0.85) 80%, transparent);
  animation: banner 1.5s ease-in-out both;
}
.banner .b-text { font-family: var(--font-brush); font-size: clamp(2rem, 8vw, 3.6rem); color: var(--ivory); text-shadow: 3px 3px 0 var(--red); white-space: nowrap; }
.banner .b-sub { color: var(--gold); font-size: 0.9rem; letter-spacing: 0.2em; white-space: nowrap; }

.chip-fly {
  position: absolute; left: 0; top: 0; width: 18px; height: 18px; margin: -9px 0 0 -9px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3c4, var(--gold) 45%, var(--gold-deep));
  box-shadow: 0 0 0 2px rgba(0,0,0,0.25) inset, 0 2px 6px rgba(0,0,0,0.5);
}

/* tiles land on the table */
.river .tile.land { animation: drop 0.28s cubic-bezier(.2,1.3,.4,1) both; }
.hand .tile.drawn-in { animation: draw-in 0.25s ease-out both; }
.hand.deal .tile { animation: deal-in 0.35s cubic-bezier(.2,1.2,.4,1) both; }
.hand.deal .tile:nth-child(2) { animation-delay: 0.06s; }
.hand.deal .tile:nth-child(3) { animation-delay: 0.12s; }
.hand.deal .tile:nth-child(4) { animation-delay: 0.18s; }
.stick.new { animation: stick-in 0.35s cubic-bezier(.2,1.3,.4,1) both; }
/* the final rank stamp */
.standings li .place { display: inline-grid; place-items: center; }
.final .standings li:nth-child(2) .place {
  width: 28px; height: 28px; border: 2px solid var(--red); border-radius: 4px; color: var(--red); background: rgba(184, 50, 42, 0.12);
  font-family: var(--font-brush); animation: stamp 0.35s cubic-bezier(.3,1.6,.5,1) 0.3s both;
}

@keyframes cut-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cut-out { to { opacity: 0; transform: scale(1.06); } }
@keyframes band-in { from { transform: skewY(-6deg) translateX(-110%); } to { transform: skewY(-6deg) translateX(0); } }
@keyframes brush { from { opacity: 0; transform: scale(2.2) rotate(-6deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes stamp { from { opacity: 0; transform: scale(2.4) rotate(-12deg); } to { opacity: 1; transform: rotate(-3deg); } }
@keyframes slide-in { from { opacity: 0; transform: skewY(6deg) translateX(-60px); } to { opacity: 1; transform: skewY(6deg); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow { from { text-shadow: 0 0 2px #000, 4px 4px 0 var(--red), 0 0 30px rgba(224,176,74,.5); } to { text-shadow: 0 0 2px #000, 4px 4px 0 var(--red), 0 0 80px rgba(255,220,120,1); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-30%, -50%); } 20%, 75% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-70%, -50%); } }
@keyframes drop { from { opacity: 0; transform: translateY(-26px) scale(1.25); } to { opacity: 1; transform: none; } }
@keyframes draw-in { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: none; } }
@keyframes deal-in { from { opacity: 0; transform: translateY(40px) rotateX(70deg); } to { opacity: 1; transform: none; } }
@keyframes stick-in { from { opacity: 0; transform: translateX(-30px) rotate(-20deg); } to { opacity: 1; transform: none; } }
.tile.sideways.land { animation: none; }

@keyframes pulse { 0%, 100% { box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 0 1px var(--gold); } 50% { box-shadow: 0 10px 26px rgba(0,0,0,0.45), 0 0 0 1px var(--gold), 0 0 26px rgba(224,176,74,0.45); } }
@keyframes lamp { from { opacity: 0.55; } to { opacity: 1; } }
@keyframes speech { 0% { opacity: 0; transform: translateY(6px) scale(0.92); } 4% { opacity: 1; transform: none; } 88% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-4px); } }
@keyframes speech-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes call { from { box-shadow: 0 6px 0 #000, 0 0 0 rgba(224,176,74,0); } to { box-shadow: 0 6px 0 #000, 0 0 30px rgba(224,176,74,0.9); } }

/* short landscape phones: keep the sheets compact */
@media (max-height: 500px) {
  .sheet { padding: 16px 20px; gap: 10px; width: min(620px, 100%); }
  .sheet h2 { font-size: 1.2rem; }
  .intro .logo { font-size: 2.2rem; }
  .picker { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 4px; }
  .picked img { width: 52px; height: 52px; }
  .standings li { padding: 3px 8px; }
  .tile.md { --w: 42px; }
}

/* ---- title screen ------------------------------------------------------ */
.title-screen { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; overflow: hidden; background: #0a0612; }
.title-bg { position: absolute; inset: -40px; background-position: center; background-size: cover; filter: blur(28px) brightness(0.55) saturate(1.2); }
.title-art {
  position: relative; width: min(100vw, 150vh); aspect-ratio: 3 / 2; container-type: size;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.7);
}
.title-art img { display: block; width: 100%; height: 100%; }
.hot {
  position: absolute; padding: 0; border: 0; border-radius: 999px; background: transparent; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.hot:hover, .hot:focus-visible { background: rgba(255, 240, 200, 0.12); box-shadow: 0 0 22px rgba(255, 210, 110, 0.55); outline: none; }
.hot:active { transform: translateY(1px) scale(0.99); }
.hot.play { border-radius: 4cqw; animation: play-glow 1.6s ease-in-out infinite; }
@keyframes play-glow { 0%, 100% { box-shadow: 0 0 0 rgba(200, 120, 255, 0); } 50% { box-shadow: 0 0 3cqw rgba(200, 120, 255, 0.55); } }
.title-foot {
  position: absolute; left: 0; right: 0; bottom: max(8px, env(safe-area-inset-bottom, 0px)); margin: 0; text-align: center;
  font-size: 12px; letter-spacing: 0.2em; color: rgba(255, 255, 255, 0.55); pointer-events: none;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.to-title { position: absolute; top: 14px; left: 14px; min-height: 36px; padding: 0 12px; border-radius: 999px; font-size: 0.85rem; border-color: var(--muted) !important; }
.intro .eyebrow { margin-top: 40px; }
.settings .set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.seg { display: inline-flex; gap: 6px; }
.seg .act { min-width: 84px; }

/* ---- ranking ------------------------------------------------------------ */
.sheet.ranking { width: min(720px, 100%); }
.rank-wrap { max-height: min(56vh, 520px); overflow: auto; border-radius: 10px; border: 1px solid var(--felt-line); }
.rank { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rank th { position: sticky; top: 0; background: var(--rail); text-align: left; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; font-weight: 500; }
.rank td { padding: 7px 10px; border-top: 1px solid rgba(255, 255, 255, 0.05); white-space: nowrap; }
.rank .num { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.rank .pos { font-family: var(--font-num); color: var(--muted); width: 2.5em; }
.rank .top .pos { font-weight: 700; }
.rank .top1 .pos { color: #f3cd72; }
.rank .top2 .pos { color: #d7dde2; }
.rank .top3 .pos { color: #d4925a; }
.rank .who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.rank .net small { font-size: 0.7rem; color: var(--muted); }
.rank .net.up { color: var(--gold); }
.rank .net.down { color: var(--danger); }
.rank tr.me td { background: rgba(224, 176, 74, 0.12); }
.ai-tag, .you-tag { display: inline-block; font-size: 0.65rem; font-weight: 700; padding: 0 5px; border-radius: 3px; margin-right: 6px; vertical-align: 1px; }
.ai-tag { background: var(--felt-line); color: var(--ivory); }
.you-tag { background: var(--gold); color: var(--ink); margin-left: 4px; }

/* turn clock (online): a bar that empties, red for the last five seconds */
.actions { flex-wrap: wrap; justify-content: flex-end; }
.clock { flex-basis: 100%; order: -1; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, 0.5); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1); }
.clock i { display: block; height: 100%; background: var(--gold); transform-origin: left; animation: clock linear forwards; }
.clock.urgent i { background: var(--danger); }
.clock.urgent { animation: pulse-red 0.6s ease-in-out infinite alternate; }
@keyframes clock { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes pulse-red { to { box-shadow: inset 0 0 0 1px var(--danger), 0 0 12px rgba(255, 90, 90, 0.6); } }

.credits { margin: 0; font-size: 0.72rem; color: var(--muted); line-height: 1.5; }

.cpu-tag { display: inline-block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.04em; padding: 0 6px; border-radius: 3px; border: 1px solid var(--muted); color: var(--muted); vertical-align: 1px; }
.pick-note { margin: -4px 0 0; font-size: 0.78rem; color: var(--muted); }

/* ---- your ron chance (only on your screen) ------------------------------- */
.tile.ron-target {
  position: relative; z-index: 3;
  box-shadow: 0 0 0 3px var(--gold), 0 0 18px 6px rgba(255, 205, 90, 0.9);
  animation: ron-target 0.7s ease-in-out infinite alternate;
}
@keyframes ron-target { from { scale: 1.08; } to { scale: 1.3; } }
.hand .tile.ron-in { animation: ron-in 0.7s ease-in-out infinite alternate; }
@keyframes ron-in { from { translate: 0 0; } to { translate: 0 -8px; } }
.np.ron-from { border-color: var(--red); box-shadow: 0 0 0 2px var(--red), 0 0 26px rgba(224, 87, 74, 0.6); }
.ron-hint { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.ron-hint svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ron-hint .beam { fill: none; stroke: #ffd36b; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 2 14; filter: drop-shadow(0 0 6px rgba(255, 200, 80, 0.9)); animation: beam 0.6s linear infinite; }
@keyframes beam { to { stroke-dashoffset: -32; } }
.ron-hint .ring { fill: none; stroke: #ffd36b; stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: ring 1s ease-out infinite; }
@keyframes ring { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.9); opacity: 0; } }
.ron-tag {
  position: absolute; transform: translate(-50%, -100%); white-space: nowrap;
  padding: 5px 14px 6px; border-radius: 999px; font-family: var(--font-brush); font-size: 24px; line-height: 1;
  color: var(--ink); background: linear-gradient(180deg, #ffe39d, var(--gold)); box-shadow: 0 4px 0 var(--gold-deep), 0 0 20px rgba(255, 210, 110, 0.8);
  animation: ron-tag 0.7s ease-in-out infinite alternate;
}
.ron-tag::after { content: ""; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); border: 8px solid transparent; border-bottom: 0; border-top-color: var(--gold); }
@keyframes ron-tag { from { translate: 0 0; } to { translate: 0 -6px; } }
.ron-hint.fresh .ron-tag { animation: tag-in 0.35s cubic-bezier(.2, 1.6, .4, 1) both, ron-tag 0.7s 0.35s ease-in-out infinite alternate; }
@keyframes tag-in { from { opacity: 0; scale: 0.4; } to { opacity: 1; scale: 1; } }
.ron-flash { position: absolute; inset: 6px; border-radius: 28px; box-shadow: inset 0 0 140px 30px rgba(255, 205, 90, 0.75); animation: ron-flash 1.1s ease-out forwards; }
@keyframes ron-flash { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .tile.ron-target, .hand .tile.ron-in, .ron-tag, .ron-hint .beam, .ron-hint .ring { animation: none; } }

/* ---- first-game guide ---------------------------------------------------- */
.guide {
  position: absolute; left: 20px; bottom: 128px; width: 372px; z-index: 7;
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: start;
  padding: 14px 16px 14px 12px; border-radius: 16px;
  background: rgba(255, 250, 238, 0.97); color: var(--ink);
  box-shadow: 0 0 0 3px var(--gold), 0 14px 30px rgba(0, 0, 0, 0.55);
}
.guide.pop { animation: guide-in 0.3s cubic-bezier(.2, 1.4, .4, 1) both; }
.guide img { width: 64px; height: 64px; }
.guide p { margin: 0; font-size: 15px; line-height: 1.42; }
.guide .g-who { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: #8a6a1c; margin-bottom: 2px; }
.guide .g-btns { display: flex; gap: 8px; margin-top: 10px; }
.guide .act { min-height: 38px; font-size: 15px; }
.guide .act.ghost { border-color: rgba(0, 0, 0, 0.25); color: #4a4436; }
@keyframes guide-in { from { opacity: 0; transform: translateY(10px) scale(0.96); } to { opacity: 1; transform: none; } }

.members li.away { opacity: 0.6; }
.members li small { color: var(--muted); font-size: 0.75em; }
.share-row { margin-top: -6px; }
.offline { margin: 0; padding: 8px 12px; border-radius: 10px; background: rgba(224, 176, 74, 0.12); border: 1px solid var(--gold-deep); color: var(--gold); font-size: 0.9rem; }

/* ---- table talk ------------------------------------------------------------ */
.chat-btn { border-color: var(--gold); }
.chatbox {
  position: absolute; right: 26px; top: 64px; width: 420px; z-index: 12;
  display: grid; gap: 10px; padding: 14px; border-radius: 16px;
  background: rgba(8, 16, 13, 0.95); border: 1px solid var(--gold-deep); box-shadow: 0 14px 30px rgba(0, 0, 0, 0.6);
}
.stamps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.stamp {
  min-height: 44px; padding: 4px 6px; border-radius: 10px; cursor: pointer; font-size: 15px; font-weight: 700; line-height: 1.2;
  border: 1px solid rgba(233, 241, 236, 0.25); background: rgba(255, 255, 255, 0.06); color: var(--ivory);
}
.stamp:hover { border-color: var(--gold); color: var(--gold); }
.chat-form { display: flex; gap: 8px; }
.chat-form input {
  flex: 1; min-width: 0; min-height: 46px; padding: 0 12px; border-radius: 10px; font: inherit; font-size: 18px;
  border: 1px solid rgba(233, 241, 236, 0.3); background: rgba(0, 0, 0, 0.4); color: var(--ivory);
}
.chat-form input:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.chat-form .act { min-height: 46px; padding: 0 18px; font-size: 17px; }
.speech.chat { --bubble: #fff3c4; box-shadow: 0 0 0 2px var(--gold), 0 8px 20px rgba(0, 0, 0, 0.45); font-weight: 700; }

/* ---- riichi bets and folding ---- */
.c-pot {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--gold-deep); color: var(--gold);
  font-family: var(--font-num); font-size: 14px; font-weight: 700; white-space: nowrap;
}
.c-pot.bump { animation: pot-bump 0.6s ease-out; }
.chip-ico {
  width: 12px; height: 12px; border-radius: 50%;
  background: radial-gradient(circle, #ffe39d 0 35%, var(--gold) 36% 60%, var(--gold-deep) 61%);
  box-shadow: 0 1px 0 #000;
}
@keyframes pot-bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
.np.folded { opacity: 0.55; filter: grayscale(0.7); }
.np.folded::after {
  content: 'FOLD'; position: absolute; top: -10px; right: -6px; padding: 1px 7px; border-radius: 6px;
  background: #3a4a44; color: var(--text); font: 700 11px/1.4 var(--font-num); letter-spacing: 0.12em;
  box-shadow: 0 2px 0 #000;
}
.backs.folded { opacity: 0.35; filter: grayscale(1); }
/* sits above Discard / Riichi so the row never grows into the hand */
.act.big.fold {
  position: absolute; right: 0; bottom: calc(100% + 16px);
  min-width: 150px; min-height: 50px; font-size: 18px; border-color: rgba(159, 181, 170, 0.6); color: var(--muted);
}
.act.big.fold.armed { color: var(--text); border-color: var(--red); background: rgba(224, 87, 74, 0.28); }
.hand.me-folded .tile { opacity: 0.45; filter: grayscale(0.8); }
@media (prefers-reduced-motion: reduce) { .c-pot.bump { animation: none; } }
