:root {
  --ink: #1c1714;
  --paper: #fbf6ec;
  --gold: #e0c48a;
  --gold-deep: #b68a45;
  --lacquer: #8d2433;
  --room: #091611;
  --felt: #1a5a43;
  --ad-banner-height: 0px;
  --ad-banner-lift: 0px;
  --ad-banner-reserve: calc(var(--ad-banner-height) + var(--ad-banner-lift));
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--paper);
  font-family: Outfit, "Segoe UI", sans-serif;
  background:
    radial-gradient(ellipse at 50% 0%, #1d4d3c 0%, var(--room) 55%, #050b09 100%);
}

h1, h2, h3, .brand, .lobby-title, .callout, .koi-banner, .sheet h2, .veil h2 {
  font-family: "Shippori Mincho", Palatino, serif;
  font-weight: 500;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

img {
  display: block;
  width: 100%;
  height: auto;
  -webkit-user-drag: none;
  user-select: none;
}

#app {
  width: min(480px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
}

.lobby {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom) + var(--ad-banner-reserve, 0px));
}

.lobby-atmosphere {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.lobby-felt {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -8%;
  height: 42%;
  background: linear-gradient(180deg, transparent, rgba(8, 38, 28, 0.55));
  border-radius: 50% 50% 0 0 / 28% 28% 0 0;
}

.lobby-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  display: grid;
  gap: 16px;
  padding: 26px 22px 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  background: linear-gradient(165deg, rgba(28, 32, 30, 0.94), rgba(14, 16, 15, 0.92));
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.lobby-brand { display: grid; justify-items: center; text-align: center; gap: 6px; }

.lobby-hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 132px;
  margin-bottom: 8px;
}

.lobby-hand img {
  width: 76px;
  margin: 0 -12px;
  border-radius: 6px;
  box-shadow: 0 0 0 3px #e4cba8, 0 10px 18px rgba(0, 0, 0, 0.45);
}

.lobby-hand img:first-child { transform: rotate(-12deg) translateY(-6px); }
.lobby-hand img:last-child { transform: rotate(12deg) translateY(-6px); }

.lobby-title {
  margin: 0;
  font-size: clamp(2.5rem, 10vw, 3.3rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
}

.byline {
  margin: 0;
  font-family: "Cormorant Garamond", Palatino, serif;
  font-style: italic;
  font-size: 1.15rem;
  letter-spacing: 0.18em;
  color: #d4b15a;
}

.lobby-copy {
  margin: 0;
  color: #d9d0c2;
  font-size: 0.95rem;
  line-height: 1.45;
}

.nowrap { white-space: nowrap; }

.fine {
  margin: 0;
  color: #b7aa98;
  font-size: 0.82rem;
}

.room-code {
  margin: 0;
  text-align: center;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  letter-spacing: 0.22em;
  color: #f4ead6;
}

.room-code-input {
  text-align: center;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.room-seats {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: center;
  color: #d9d0c2;
}

#online-error:empty,
#room-error:empty { display: none; }

#online-error,
#room-error { color: #e7b4b4; }

.skill-choice { display: flex; gap: 8px; }

.skill-choice button {
  flex: 1;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(244, 234, 214, 0.28);
  background: transparent;
  color: #f4ead6;
  font: inherit;
  cursor: pointer;
}

.skill-choice button.is-selected {
  background: rgba(212, 177, 90, 0.22);
  border-color: #d4b15a;
}

.lobby-section { display: grid; gap: 10px; }

.lobby-subtitle { margin: 0; font-size: 1.6rem; }

.lobby-label {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cbbfa8;
}

.lobby-input, .lobby-select {
  width: 100%;
  padding: 0.75rem 0.95rem;
  color: #f4ead6;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(244, 234, 214, 0.2);
  border-radius: 999px;
}

.lobby-button {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 14px 18px;
  text-align: center;
}

.lobby-button-hint {
  color: rgba(255, 250, 243, 0.75);
  font-size: 0.78rem;
  font-weight: 400;
}

.lobby-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 22px; }

a.text-link { font: inherit; text-decoration: none; }

.share-status { text-align: center; }

.remove-ads {
  display: grid;
  justify-items: center;
  gap: 0.45rem;
  margin: 0.4rem 0 0;
}

.remove-ads[hidden] { display: none; }

.remove-ads .btn { min-width: 12rem; }

.remove-ads-note {
  margin: 0;
  color: #cbbfa8;
  font-size: 0.85rem;
  text-align: center;
}

.text-link, .bar-leave, .sheet-quiet {
  padding: 0;
  border: 0;
  background: none;
  color: #d4b15a;
  cursor: pointer;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-toggle {
  width: 2.15rem;
  height: 2.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid rgba(244, 234, 214, 0.28);
  border-radius: 999px;
  background: rgba(12, 18, 16, 0.45);
  color: #f4ead6;
  cursor: pointer;
}

.sound-toggle:hover {
  color: #d4b15a;
  border-color: rgba(212, 177, 90, 0.55);
}

.sound-toggle.is-muted { color: #cbbfa8; }

.sound-toggle svg { display: block; }

.lobby-actions, .sheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: var(--lacquer);
  color: #fffaf3;
  cursor: pointer;
}

.btn.primary { background: var(--lacquer); }

.btn.ghost {
  background: transparent;
  color: #f4ead6;
  box-shadow: inset 0 0 0 1px rgba(244, 234, 214, 0.35);
}

.btn.dark {
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(28, 23, 20, 0.35);
}

.btn.koi {
  background: #d4b15a;
  color: #1c1714;
  font-weight: 600;
}

.btn.quiet {
  padding: 7px 14px;
  background: rgba(12, 18, 16, 0.45);
  color: #f4ead6;
  box-shadow: inset 0 0 0 1px rgba(244, 234, 214, 0.28);
  font-size: 0.85rem;
}

button.card { cursor: pointer; }

.table {
  position: relative;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  background:
    radial-gradient(ellipse at 50% 0%, #1d4d3c 0%, var(--room) 55%, #050b09 100%);
}

.stage {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 8px 0;
}

.play-screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  padding: 2px 4px 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar {
  flex: none;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 12px 4px;
}

.brand { margin: 0; font-size: 1.25rem; line-height: 1; }

.round-label {
  margin: 2px 0 0;
  color: var(--gold);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.felt {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin: 0 0 8px;
  border-radius: 22px;
  background: radial-gradient(circle at 50% 42%, #227556 0%, #1a5a43 48%, #0e3d2c 100%);
  box-shadow:
    inset 0 0 0 8px #6b422c,
    inset 0 0 0 11px #3a2418;
}

.felt h2 {
  margin: 0 0 6px;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
}

.seat {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  padding: 10px 12px 0;
  text-align: center;
}

.seat-near { padding: 4px 12px 10px; }

.seat-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin: 0;
  padding: 2px 12px 4px;
  border-radius: 12px;
}

.seat.is-active .seat-meta {
  background: rgba(8, 28, 18, 0.55);
  outline: 2px solid #7ed36a;
  box-shadow: 0 0 0 1px rgba(126, 211, 106, 0.28);
}

.seat-name { font-size: 0.95rem; line-height: 1.1; }

.seat-score {
  font-size: 1.35rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.seat-count, .progress, .empty-note, .cue {
  margin: 0;
  color: #d7cbb8;
  font-size: 0.68rem;
  line-height: 1.3;
}

.progress { max-width: 100%; padding: 0 8px; }

.yaku-now {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
}

.backs, .claims {
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.backs .card, .claims .card {
  width: 26px;
  margin-left: -14px;
}

.backs .card:first-child, .claims .card:first-child { margin-left: 0; }

.claims .more {
  align-self: center;
  margin-left: 4px;
  color: #d7cbb8;
  font-size: 0.72rem;
}

.table-center {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  justify-content: safe center;
  gap: 8px;
  padding: 12px 16px 8px;
  overflow: auto;
}

.center-play {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.field-wrap { flex: 1; min-width: 0; }

.field, .field-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 6px;
}

.field.is-rows { flex-direction: column; align-items: center; }

.field.is-rows .field-row { width: 100%; }

.field .card,
.field .capture-show {
  width: calc((100% - 18px) / 4);
  max-width: 64px;
  flex: 0 0 auto;
}

.field .card img { width: 100%; height: auto; display: block; }

.field .card.is-drawn {
  position: relative;
  z-index: 3;
  top: -10px;
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 8px;
  box-shadow: 0 12px 18px rgba(0, 0, 0, 0.45);
}

.field .capture-show {
  position: relative;
  width: calc((100% - 18px) / 4);
  max-width: 64px;
}

.field .capture-show .card {
  width: 100%;
  max-width: none;
}

.field .capture-show .card + .card:not(.is-drawn) { margin-top: -36px; }

.field .capture-show .card.is-drawn {
  position: absolute;
  left: 14px;
  top: 16px;
  margin-top: 0;
}

.mountain {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 78px;
  text-align: center;
}

.mountain p, .felt-note {
  margin: 6px 0 0;
  color: #f4ead6;
  font-size: 0.75rem;
  line-height: 1.35;
  text-align: center;
}

.felt-note { margin: 0; }

.felt-note .cue { display: block; color: #d7cbb8; }

.stack {
  --pile: 0px;
  position: relative;
  display: block;
  box-sizing: content-box;
  width: 48px;
  height: calc(48px * 2099 / 1280);
  margin: 7px 0 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.stack[data-count="2"] { --pile: 4px; }
.stack[data-count="3"] { --pile: 7px; }

.stack[data-count="2"],
.stack[data-count="3"] {
  width: calc(48px + var(--pile));
  height: calc(48px * 2099 / 1280 + var(--pile));
}

button.stack { cursor: pointer; }

.stack.is-drawable {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 8px;
  animation: mountain-tap 1.2s ease-in-out infinite;
}

.stack .card-back {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: calc(48px * 2099 / 1280);
  aspect-ratio: auto;
}

.stack[data-count="2"] .card-back:nth-child(1) { top: 4px; left: 4px; }

.stack[data-count="3"] .card-back:nth-child(1) { top: 7px; left: 7px; }
.stack[data-count="3"] .card-back:nth-child(2) { top: 3px; left: 3px; }

.shuffle-half { position: absolute; inset: 0; }
.shuffle-half.is-right { z-index: 1; }

.stack.is-shuffling .shuffle-half.is-left { animation: shuffle-left 5.6s ease-in-out 1 both; }
.stack.is-shuffling .shuffle-half.is-right { animation: shuffle-right 5.6s ease-in-out 1 both; }

@keyframes shuffle-left {
  0%, 14% { transform: translate(0, 0) rotate(0deg); }
  40%, 62% { transform: translate(-36px, -8px) rotate(-11deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes shuffle-right {
  0%, 14% { transform: translate(0, 0) rotate(0deg); }
  40%, 62% { transform: translate(32px, 6px) rotate(10deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

.felt.is-shuffling .table-center,
.felt.is-shuffling .mountain,
.felt.is-dealing .table-center { overflow: visible; }

.is-incoming {
  position: relative;
  z-index: 6;
  animation: deal-fly 150ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes deal-fly {
  from { transform: translate(var(--deal-x), var(--deal-y)) rotate(-8deg); }
  to { transform: none; }
}

@keyframes mountain-tap {
  50% { transform: translateY(-5px); }
}

.card {
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 6px;
}

.card img, .card-back { border-radius: 5px; }

.card-back {
  width: 100%;
  aspect-ratio: 1280 / 2099;
  border: 1.5px solid #d4b15a;
  background:
    linear-gradient(145deg, rgba(212, 177, 90, 0.18), transparent 42%),
    repeating-linear-gradient(45deg, #3f2a1c 0 7px, #342218 7px 14px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}

.hand-dock {
  flex: none;
  margin: 0 0 8px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  border-radius: 14px;
  background: rgba(255, 250, 243, 0.05);
}

.taken {
  margin: 8px 4px 12px;
  padding: 14px 12px 8px;
  border-radius: 18px;
  background: rgba(8, 16, 13, 0.72);
  box-shadow: inset 0 0 0 1px rgba(212, 177, 90, 0.35);
}

.taken > h2 {
  margin: 0 0 12px;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  color: #f4ead6;
}

.taken-player + .taken-player { margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(212, 177, 90, 0.22); }

.taken-player h3 {
  margin: 0;
  text-align: center;
  font-size: 1.2rem;
  color: #f7f1e4;
}

.taken-empty {
  margin: 8px 0 12px;
  text-align: center;
  color: #d7cbb8;
  font-size: 0.85rem;
}

.taken-group { margin: 10px 0 14px; }

.taken-group h4 {
  margin: 0 0 6px;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #e0c48a;
}

.taken-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px 8px;
}

.taken-card { margin: 0; max-width: 92px; }

.taken-card img {
  width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
}

.taken-card figcaption { margin-top: 4px; text-align: center; }

.taken-card .catalog-jp { display: block; font-size: 0.72rem; }

.taken-card .catalog-en { display: block; font-size: 0.68rem; line-height: 1.25; }

.hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 92px;
  padding: 10px 4px 4px;
}

.hand .card {
  width: calc(100% / 5.65);
  max-width: 74px;
  margin-left: calc(100% / 5.65 * -0.3);
  border-radius: 7px;
}

.hand .card:first-child { margin-left: 0; }

.hand .card img { box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35); }

@media (hover: hover) {
  .hand .card:hover { transform: translateY(-12px); z-index: 2; }
}

.hand .card.is-picked,
.hand .card.is-playing,
.card.is-match {
  z-index: 2;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 8px;
}

.hand .card.is-picked,
.hand .card.is-playing { position: relative; top: -14px; }

.field.is-choosing .card:not(.is-match):not(.is-drawn),
.hand.is-choosing .card:not(.is-playing) { opacity: 0.38; }

.is-fresh { animation: arrive 0.45s ease; }

@keyframes arrive {
  from { margin-top: 10px; }
  to { margin-top: 0; }
}

.callout {
  margin: 0;
  padding: 0 12px;
  text-align: center;
  color: #fffaf3;
  font-size: 1.35rem;
}

.koi-banner {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 46%;
  width: max-content;
  max-width: calc(100% - 36px);
  margin: 0;
  padding: 16px 18px;
  border-radius: 16px;
  background: rgba(8, 16, 13, 0.92);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.4), inset 0 0 0 1px rgba(212, 177, 90, 0.7);
  color: #fffaf3;
  font-size: 1.45rem;
  line-height: 1.2;
  text-align: center;
  transform: translate(-50%, -50%);
}

.sheet, .veil {
  position: absolute;
  z-index: 5;
}

.sheet {
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  max-height: min(78dvh, 560px);
  overflow: auto;
  padding: 16px 16px 14px;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.sheet.end-sheet {
  top: 58px;
  bottom: auto;
  max-height: calc(100% - 188px);
}

.sheet h2 { margin: 0 0 4px; font-size: 1.8rem; line-height: 1.1; }

.hand-summary { margin-top: 10px; }

.hand-summary h3 {
  margin: 0;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
}

.hand-summary .yaku-list { margin: 2px 0 0; }

.hand-summary .yaku-list li { align-items: baseline; }

.hand-summary .yaku-list span { flex: none; }

.hand-summary .yaku-list b {
  max-width: 68%;
  font-weight: 500;
  text-align: right;
}

.held-line {
  margin: 4px 0 0;
  color: #5c5146;
  font-size: 0.82rem;
}

.sheet p { margin: 6px 0; line-height: 1.4; }

.sheet .score-line {
  margin: 8px 0;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.yaku-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
}

.yaku-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(28, 23, 20, 0.1);
}

.yaku-list span { color: #5c5146; font-size: 0.85rem; }

.sheet-actions { margin-top: 12px; }

.sheet-actions .btn { flex: 1; }

.veil {
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #07110e;
  text-align: center;
}

.veil h2 { margin: 0 0 8px; font-size: 2.2rem; }

.veil p { color: #d9d0c2; }

.leave-sheet { z-index: 8; }

.cards-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100dvh;
  padding: 18px 16px calc(24px + env(safe-area-inset-bottom) + var(--ad-banner-reserve, 0px));
  overflow: auto;
}

.cards-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cards-bar h1 { margin: 0; font-size: 2rem; }

.cards-lead { margin: 0; color: #d9d0c2; line-height: 1.4; }

#cards-list { display: grid; gap: 18px; }

.catalog-month { display: grid; gap: 8px; }

.catalog-month h2 {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  margin: 0;
  font-size: 1.35rem;
}

.catalog-jp {
  font-family: "Shippori Mincho", Palatino, serif;
  line-height: 1.1;
  color: #e0c48a;
}

.catalog-month h2 > .catalog-jp { font-size: 1.15rem; letter-spacing: 0.08em; }

.catalog-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.catalog-when {
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cbbfa8;
}

.catalog-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.catalog-card { margin: 0; min-width: 0; }

.catalog-card img {
  width: 100%;
  border-radius: 6px;
  box-shadow: 0 0 0 2px #e4cba8, 0 8px 12px rgba(0, 0, 0, 0.4);
}

.catalog-card figcaption {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 5px;
  text-align: center;
}

.catalog-card .catalog-jp { font-size: 0.95rem; }

.catalog-card .catalog-en {
  font-size: 0.72rem;
  line-height: 1.15;
  color: #f4ead6;
}

.rules {
  width: auto;
  max-width: 100%;
  margin: 0;
  padding: 8px 4px 4px;
  color: var(--ink);
}

.rules h2 { margin: 0 0 8px; font-size: 2rem; }

.rules h3 { margin: 16px 0 4px; font-size: 1.25rem; }

.rules p { line-height: 1.45; }

.rules table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.rules th, .rules td {
  padding: 6px 4px;
  border-bottom: 1px solid rgba(28, 23, 20, 0.12);
  text-align: left;
  vertical-align: top;
}

.rules th:last-child, .rules td:last-child { text-align: right; }

dialog {
  width: min(520px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: min(86dvh, 720px);
  margin: auto;
  overflow: auto;
  padding: 18px 18px 14px;
  border: 0;
  border-radius: 18px;
  background: var(--paper);
  color: var(--ink);
}

dialog::backdrop { background: rgba(5, 10, 8, 0.72); }

body.has-ad-banner dialog {
  max-height: calc(100dvh - var(--ad-banner-reserve, 0px) - 28px);
  margin: 14px auto calc(var(--ad-banner-reserve, 0px) + 12px);
}

@media (min-width: 840px) {
  body { display: grid; place-items: center; }

  #app {
    height: min(960px, 100dvh);
    min-height: 0;
    border-radius: 28px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  }

  .lobby, .table, .cards-page { height: 100%; min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .is-fresh, .stack.is-drawable, .is-incoming, .stack.is-shuffling .shuffle-half,
  .fanfare-backdrop, .fanfare-banner { animation: none; }
  .fanfare-piece, .fanfare-trophy { display: none; }
  .hand .card, .lobby-hand img { transition: none; }
}

.fanfare-backdrop {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(8, 12, 10, 0.62);
  animation: fanfare-wash 3.4s ease-out forwards;
}

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

.fanfare-piece {
  position: absolute;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(212, 177, 90, 0.35);
  animation-name: confetti-fall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}

.fanfare-trophy {
  position: absolute;
  display: block;
  filter: drop-shadow(0 10px 8px rgba(0, 0, 0, 0.35));
  animation-name: trophy-fall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

.fanfare-trophy svg {
  display: block;
  width: 100%;
  height: auto;
}

.fanfare-banner {
  position: relative;
  z-index: 1;
  margin: 0 1.2rem;
  max-width: calc(100% - 2.4rem);
  padding: 0.38em 0.55em 0.44em;
  text-align: center;
  font-family: "Shippori Mincho", Palatino, serif;
  font-size: clamp(2.1rem, 8vw, 3.6rem);
  font-weight: 600;
  line-height: 1.15;
  color: #f7f1e4;
  background: rgba(16, 28, 20, 0.94);
  border: 1px solid rgba(224, 196, 138, 0.85);
  border-radius: 16px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  animation: fanfare-flash 3.4s ease-out;
}

@keyframes fanfare-wash {
  0% { background: rgba(212, 177, 90, 0.28); }
  18% { background: rgba(8, 12, 10, 0.62); }
  82% { background: rgba(8, 12, 10, 0.62); }
  100% { background: rgba(8, 12, 10, 0); }
}

@keyframes fanfare-flash {
  0% { opacity: 0; transform: scale(0.72); }
  14% { opacity: 1; transform: scale(1.06); }
  24% { transform: scale(1); }
  86% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.04); }
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, 0, 0) rotate(0deg); opacity: 1; }
  100% { transform: translate3d(var(--drift), 110vh, 0) rotate(540deg); opacity: 0.2; }
}

@keyframes trophy-fall {
  0% { transform: translate3d(0, -12vh, 0) rotate(calc(var(--wobble) * -0.4)); opacity: 0; }
  14% { opacity: 1; }
  100% { transform: translate3d(var(--drift), 108vh, 0) rotate(var(--wobble)); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .fanfare-backdrop, .fanfare-banner { animation: none; }
  .fanfare-piece, .fanfare-trophy { display: none; }
}
