:root {
  --ink: #1c1714;
  --paper: #fbf6ec;
  --paper-deep: #f3ead8;
  --gold: #e0c48a;
  --gold-deep: #b68a45;
  --lacquer: #8d2433;
  --felt: #1a5a43;
  --felt-deep: #0e3328;
  --room: #091611;
  --line: rgba(28, 23, 20, 0.12);
  --card: 78px;
  --hand-card: 86px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

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

button, input { font: inherit; }

h1, h2, .brand, .sheet h1 {
  font-family: "Shippori Mincho", Palatino, "Palatino Linotype", serif;
  font-weight: 500;
}

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

.lobby-overlay {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 20px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(ellipse 80% 55% at 50% 18%, rgba(212, 177, 90, 0.16), transparent 58%),
    radial-gradient(ellipse 90% 50% at 50% 100%, rgba(15, 61, 44, 0.5), transparent 55%),
    linear-gradient(180deg, #101816 0%, #0b100e 100%);
}

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

.lobby-felt {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -8%;
  height: 42%;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(47, 179, 90, 0.14), transparent 55%),
    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);
  padding: 28px 24px 22px;
  display: grid;
  gap: 18px;
  color: #f4ead6;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background: linear-gradient(165deg, rgba(28, 32, 30, 0.94), rgba(14, 16, 15, 0.92));
}

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

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

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

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

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

.lobby-title {
  margin: 0;
  font-size: clamp(2.4rem, 9vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: #f4ead6;
}

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

.lobby-copy,
.deal-note {
  margin: 0;
  color: #cbbfa8;
  line-height: 1.5;
}

.lobby-brand .lobby-copy {
  max-width: 32ch;
  font-size: 0.98rem;
}

.lobby-card.is-players .lobby-hand,
.lobby-card.is-players .lobby-copy {
  display: none;
}

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

.lobby-subtitle {
  margin: 0;
  font-size: 1.15rem;
  text-align: center;
}

.lobby-button {
  width: 100%;
  min-height: 56px;
}

.lobby-button-primary {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 64px;
}

.lobby-button-hint {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.8;
}

.lobby-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.lobby-actions .btn {
  flex: 1;
  white-space: nowrap;
  text-align: center;
  padding-inline: 14px;
}

.lobby-footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 4px;
  margin-top: 6px;
}

.lobby-text-link {
  border: 0;
  background: none;
  color: #d4b15a;
  cursor: pointer;
  padding: 0.35rem 0.45rem;
}

.lobby-footer-sep { color: #cbbfa8; }

.lobby-label {
  margin: 0;
  color: #cbbfa8;
  font-size: 0.92rem;
}

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

.lobby-input:focus {
  border-color: #d4b15a;
  outline: none;
}

.lobby-stepper {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(244, 234, 214, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.lobby-stepper strong {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 700;
}

.lobby-stepper-button {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: #f4ead6;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.lobby-stepper-button:disabled {
  opacity: 0.28;
  cursor: default;
}

.lobby-hint,
.lobby-error,
.lobby-share-status {
  margin: 0;
  line-height: 1.5;
}

.lobby-hint,
.lobby-share-status { color: #cbbfa8; }

.lobby-error { color: #f0c2c6; }

.room-code {
  margin: 0;
  text-align: center;
  font-size: 2rem;
  letter-spacing: 0.28em;
  color: #d4b15a;
  font-weight: 700;
}

.room-seats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.room-seats li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: #f4ead6;
}

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

.lobby-option {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lobby-section > .btn.ghost { width: 100%; }

.btn.primary {
  background: #f4ead6;
  color: #0c1210;
  font-weight: 600;
}

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

fieldset {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 8px;
  color: #cbbfa8;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.count {
  display: flex;
  gap: 6px;
}

.count label { position: relative; flex: 1; }

.count input {
  position: absolute;
  inset: 0;
  margin: 0;
  cursor: pointer;
  appearance: none;
}

.count span {
  display: block;
  padding: 8px 0;
  text-align: center;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px rgba(244, 234, 214, 0.28);
}

.count input:checked + span {
  background: #f4ead6;
  color: #0c1210;
  box-shadow: none;
}

.names { display: grid; gap: 8px; }

.names label {
  display: grid;
  gap: 4px;
  color: #cbbfa8;
  font-size: 13px;
}

.names label[hidden] {
  display: none;
}

.names input {
  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;
}

.names input:focus {
  border-color: #d4b15a;
  outline: none;
}

.deal-note {
  min-height: 2.6em;
  font-size: 14px;
}

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

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

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

.btn:hover { filter: brightness(1.08); }

.btn.quiet {
  background: transparent;
  color: inherit;
  box-shadow: inset 0 0 0 1px currentColor;
}

.table {
  width: min(1180px, calc(100% - 16px));
  margin: 0 auto;
}

.stage {
  box-sizing: border-box;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0 10px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  flex: none;
}

.topbar-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; }

.leave-backdrop { z-index: 40; }

.leave-panel {
  width: min(420px, 100%);
  padding: 26px 24px 20px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 16px;
}

.leave-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.leave-panel .btn.quiet { color: var(--ink); }

.brand {
  margin: 0;
  font-size: 26px;
  line-height: 1;
}

.brand span {
  display: block;
  margin-top: 2px;
  color: var(--gold);
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

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

.standings li {
  min-width: 92px;
  padding: 6px 10px 7px;
  border-radius: 10px;
  background: rgba(255, 250, 243, 0.06);
  box-shadow: inset 0 0 0 1px rgba(224, 196, 138, 0.25);
}

.standings li.is-current { box-shadow: inset 0 0 0 1px var(--gold); }

.standings li.is-leader strong { color: var(--gold); }

.standings .who {
  display: block;
  font-size: 12px;
  opacity: 0.8;
}

.standings strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.felt {
  --ring-x: 42%;
  --ring-y: 38%;
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 42%, #227556 0%, var(--felt) 46%, var(--felt-deep) 100%);
  box-shadow:
    inset 0 0 0 10px #6b422c,
    inset 0 0 0 14px #3a2418,
    0 16px 40px rgba(0, 0, 0, 0.28);
}

.felt h2, .tray h2, .hand-dock h2 {
  margin: 0 0 8px;
  font-family: Outfit, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.seat-rail {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.seat-rail .seat { pointer-events: auto; }

.seat {
  position: absolute;
  left: calc(50% + var(--seat-x) * var(--ring-x));
  top: calc(50% - var(--seat-y) * var(--ring-y));
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: 8.5rem;
  color: var(--paper);
  transform: translate(-50%, -50%);
}

.seat.slot-s { flex-direction: column-reverse; }

.seat.slot-w,
.seat.slot-e {
  flex-direction: row;
  max-width: none;
  gap: 8px;
}

.seat.slot-e { flex-direction: row-reverse; }

.seat-play {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.seat.is-active { z-index: 3; }

.seat.is-active .seat-name,
.seat.is-leader .seat-score { color: var(--gold); }

.seat-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
  text-align: center;
}

.seat-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.seat-score {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.seat-count {
  font-size: 11px;
  opacity: 0.78;
}

.seat-cards {
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.seat-back,
.seat-claim {
  width: 30px;
  margin-left: -14px;
}

.seat-cards > :first-child { margin-left: 0; }

.seat-claim img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.card-back {
  width: 100%;
  aspect-ratio: 1280 / 2099;
  border-radius: 10px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.28);
  background:
    linear-gradient(145deg, rgba(212, 177, 90, 0.18), transparent 42%),
    repeating-linear-gradient(45deg, #3f2a1c 0 8px, #342218 8px 16px);
  border: 2px solid #d4b15a;
  color: #d4b15a;
  display: grid;
  place-items: center;
  font-family: "Cormorant Garamond", Georgia, serif;
}

.card-back-title {
  display: block;
  line-height: 1;
  letter-spacing: 0.08em;
  text-align: center;
  font-style: italic;
  font-size: 1.05rem;
}

.stack .card-back-title { font-size: 0.82rem; }

.seat-back .card-back {
  border-radius: 6px;
  border-width: 1.5px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}

.seat-back .card-back-title { font-size: 0.42rem; }

.seat-more {
  align-self: center;
  margin-left: 4px;
  font-size: 12px;
}

.seat .pips { justify-content: center; }

.table-center {
  position: absolute;
  left: 9rem;
  right: 9rem;
  top: 6.2rem;
  bottom: 3.4rem;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  overflow: auto;
}

.felt.seats-2 .table-center {
  left: 6rem;
  right: 6rem;
}

.callout-row {
  position: absolute;
  left: 16px;
  bottom: 14px;
  z-index: 4;
  display: flex;
  max-width: 11rem;
  margin: 0;
  pointer-events: none;
  text-align: left;
}

.felt-callout {
  margin: 0;
  color: var(--gold);
  font-size: 13px;
  line-height: 1.35;
  text-align: left;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}

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

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

.field { justify-content: center; }

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

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

.field .card,
.field .card-btn,
.capture-pile .card { width: 52px; }

.field .month-start { margin-left: 8px; }

.table-center .stack { width: 52px; }

.mini-row, .kasu-row, .hand, .field, .tray-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.mini { width: 34px; }

.pips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

.pip {
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(224, 196, 138, 0.14);
  color: var(--gold);
  font-size: 11px;
}

.pip.done { background: rgba(141, 36, 51, 0.85); color: #fffaf3; }

.tray p { margin: 6px 0 0; font-size: 12px; opacity: 0.78; }

.card, .card-btn {
  width: var(--card);
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.card img, .card-btn img, .mini img, .pending-card img, .drawn img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  pointer-events: none;
}

.card-btn { cursor: pointer; transition: transform 0.15s ease; }

.hand .card-btn { position: relative; }

.card-btn:hover { transform: translateY(-8px); }

.hand .card-btn.is-selected,
.hand .card-btn.is-selected:hover {
  z-index: 2;
  transform: translateY(-18px);
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 10px;
}

.hand .card, .hand .card-btn {
  width: min(var(--hand-card), calc((100% - 42px) / 8));
}

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

.card.is-match, .card-btn.is-match {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 10px;
}

.field .card.is-fresh {
  z-index: 1;
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 10px;
  transform: translateY(-10px);
  box-shadow: 0 10px 16px rgba(0, 0, 0, 0.4);
}

.capture-pile {
  position: relative;
  display: flex;
  align-items: flex-start;
}

.capture-pile[data-count="1"] {
  width: 66px;
  height: calc(52px * 2099 / 1280);
}

.capture-pile[data-count="1"] .card:not(.capture-top) {
  position: absolute;
  left: 0;
  top: 0;
}

.capture-pile .capture-top {
  z-index: 2;
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  border-radius: 8px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.45);
}

.capture-pile[data-count="1"] .capture-top {
  position: absolute;
  left: 14px;
  top: -12px;
}

.capture-pile:not([data-count="1"]) .capture-top {
  position: absolute;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
}

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

.hand .card.is-playing {
  z-index: 2;
  transform: translateY(-18px);
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 10px;
}

.mountain {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  flex: none;
}

.mountain-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.mountain-card {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mountain-card p,
.mountain > p {
  margin: 6px 0 0;
  font-size: 13px;
}

.stack {
  position: relative;
  display: block;
  width: 52px;
  aspect-ratio: 1280 / 2099;
  margin: 0 0 8px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

button.stack { cursor: pointer; }

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

.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 { overflow: visible; }

.is-incoming {
  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; }
}

.field .card.is-fresh.is-slapped {
  animation: slap-fresh 240ms ease-out;
}

@keyframes slap-fresh {
  0% { transform: translateY(-34px) scale(1.06); }
  55% { transform: translateY(-4px) scale(0.98); }
  100% { transform: translateY(-10px); }
}

.capture-pile[data-count="1"] .capture-top.is-slapped {
  animation: slap-one 240ms ease-out;
}

@keyframes slap-one {
  0% { transform: translateY(-32px) scale(1.05); }
  100% { transform: none; }
}

.capture-pile:not([data-count="1"]) .capture-top.is-slapped {
  animation: slap-group 240ms ease-out;
}

@keyframes slap-group {
  0% { transform: translateX(-50%) translateY(-30px) scale(1.05); }
  100% { transform: translateX(-50%); }
}

.fanfare-backdrop {
  position: fixed;
  inset: 0;
  z-index: 28;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(8, 12, 10, 0.42);
  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-banner {
  position: relative;
  z-index: 1;
  margin: 0 1.5rem;
  max-width: 12em;
  text-align: center;
  font-family: "Shippori Mincho", Palatino, serif;
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  font-weight: 500;
  line-height: 1.05;
  color: #f4ead6;
  text-shadow: 0 0 28px rgba(212, 177, 90, 0.55);
  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.42); }
  82% { background: rgba(8, 12, 10, 0.42); }
  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; }
}

@media (prefers-reduced-motion: reduce) {
  .is-incoming,
  .stack.is-shuffling .shuffle-half,
  .is-slapped,
  .fanfare-backdrop,
  .fanfare-banner { animation: none; }
  .fanfare-piece { display: none; }
}

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

.stack .card-back {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.stack .card-back:nth-child(1) { transform: translate(7px, 7px); }
.stack .card-back:nth-child(2) { transform: translate(3px, 3px); }

.stack[data-count="1"] .card-back { transform: none; }

.stack[data-count="2"] .card-back:nth-child(1) { transform: translate(4px, 4px); }
.stack[data-count="2"] .card-back:nth-child(2) { transform: none; }

.drawn,
.drawn .card,
.pending-card,
.pending-card .card {
  width: 52px;
}

.tray, .log {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 250, 243, 0.05);
}

.hand-dock {
  flex: none;
  margin: 0;
  padding: 8px 12px 8px;
  border-radius: 14px;
  background: rgba(255, 250, 243, 0.05);
}

.hand-dock .btn { padding: 7px 16px; }

.prompt {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(251, 246, 236, 0.1);
}

.prompt p { margin: 0; line-height: 1.4; }

.pending-card { width: 56px; flex: none; }

.hand { justify-content: center; min-height: 0; padding-top: 0; }

.hand .prompt-actions { flex: 1 0 100%; justify-content: center; }

.empty-note { margin: 0; opacity: 0.75; }

.log ol {
  margin: 0;
  padding-left: 18px;
  color: rgba(251, 246, 236, 0.78);
  font-size: 13px;
}

.log li + li { margin-top: 3px; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 10, 8, 0.72);
}

.summary {
  width: min(920px, 100%);
  max-height: min(84vh, 760px);
  overflow: auto;
  padding: 26px 26px 20px;
  color: var(--ink);
  background: var(--paper);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.4);
}

.summary h2 {
  margin: 0;
  font-family: "Shippori Mincho", Palatino, serif;
  font-size: 34px;
  font-weight: 500;
}

.summary .lead-line { margin: 6px 0 14px; }

.summary table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.summary th, .summary td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.summary th {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.up { color: #1d6b45; }
.down { color: var(--lacquer); }

.transfers, .left-over { margin: 12px 0; padding-left: 18px; }

.left-over { color: #5c5146; }

details summary { cursor: pointer; }

.summary-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: flex-start;
}

.summary .card { width: 38px; }

.summary-none { color: #5c5146; }

.yaku-set + .yaku-set { margin-top: 8px; }

.yaku-name {
  margin: 0 0 3px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #5c5146;
}

.summary .overlay-actions { margin-top: 8px; }

.summary .btn.quiet { color: var(--ink); }

dialog {
  width: min(640px, calc(100% - 28px));
  max-height: min(86vh, 820px);
  padding: 0;
  color: var(--ink);
  background: var(--paper);
  border: 0;
  border-radius: 16px;
}

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

.rules-wrap {
  padding: 26px 26px 18px;
  overflow: auto;
  max-height: min(86vh, 820px);
}

.rules-lang {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.rules-lang .btn[aria-pressed="true"] {
  background: var(--lacquer);
  color: #fffaf3;
  box-shadow: none;
}

.rules-close { margin-top: 18px; }

.rules {
  padding: 0;
}

.rules[lang="ja"] {
  font-family: "Shippori Mincho", "Hiragino Mincho ProN", Palatino, serif;
}

.rules[lang="ja"] p,
.rules[lang="ja"] li { line-height: 1.75; }

.rules h2, .rules h3 {
  font-family: "Shippori Mincho", Palatino, serif;
  font-weight: 500;
}

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

.rules h3 { margin: 22px 0 6px; font-size: 20px; }

.rules p, .rules li { line-height: 1.5; }

.rules table { width: 100%; border-collapse: collapse; }

.rules th, .rules td { padding: 4px 8px 4px 0; text-align: left; }

@media (max-width: 800px) {
  .stage {
    gap: 6px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-right: env(safe-area-inset-right);
    padding-left: env(safe-area-inset-left);
  }
  .topbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .brand { font-size: 22px; min-width: 0; }
  .topbar-actions { flex: none; gap: 6px; }
  .topbar .btn.quiet { padding: 7px 12px; }
  .lobby-title { font-size: 2.4rem; }
  .lobby-hand { height: 118px; margin-bottom: 18px; }
  .lobby-hand img { width: 68px; }
  .felt { --ring-x: 40%; --ring-y: 36%; }
  .table-center { left: 5.2rem; right: 5.2rem; top: 5.6rem; bottom: 3.2rem; }
  .callout-row { left: 10px; bottom: 8px; max-width: 8.5rem; }
  .felt-callout { font-size: 12px; }
  .field .card, .field .card-btn, .capture-pile .card, .table-center .stack, .drawn, .drawn .card, .pending-card, .pending-card .card { width: 44px; }
  .capture-pile[data-count="1"] { width: 56px; height: calc(44px * 2099 / 1280); }
  .seat { max-width: 5.4rem; }
  .seat-back, .seat-claim { width: 26px; margin-left: -12px; }
  .card-back-title { font-size: 0.82rem; }
  .stack .card-back-title { font-size: 0.62rem; }
  .seat-back .card-back-title { font-size: 0.34rem; }
  :root { --card: 64px; --hand-card: 72px; }
}

@media (max-width: 520px) {
  .table { width: calc(100% - 8px); }
  .brand { font-size: 20px; }
  .brand span { letter-spacing: 0.08em; }
  .topbar .btn.quiet { padding: 6px 10px; font-size: 14px; }
  .sound-toggle { width: 2rem; height: 2rem; }
  .center-play { gap: 8px; }
  .felt h2, .hand-dock h2 { margin-bottom: 4px; }
  .felt {
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    padding: 10px 12px 8px;
  }
  .seat-rail {
    position: static;
    inset: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-evenly;
    align-items: flex-start;
    gap: 8px 6px;
    order: 1;
    flex: none;
  }
  .seat-rail .seat,
  .felt > .seat {
    position: static;
    left: auto;
    top: auto;
    transform: none;
    flex-direction: column;
    width: max-content;
    max-width: 5.4rem;
    gap: 2px;
  }
  .seat-rail-bottom { order: 4; }
  .field-row { flex-wrap: nowrap; }
  .felt .table-center,
  .felt.seats-2 .table-center {
    position: static;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    order: 2;
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
  }
  .center-play { width: 100%; align-items: center; }
  .field-wrap { flex: 1 1 auto; }
  .callout-row {
    position: static;
    order: 3;
    max-width: none;
    margin: 0;
  }
  .field .card, .field .card-btn, .capture-pile .card, .table-center .stack, .drawn, .drawn .card, .pending-card, .pending-card .card { width: 44px; }
  .capture-pile[data-count="1"] { width: 56px; height: calc(44px * 2099 / 1280); }
  .field.is-rows, .field-row { gap: 4px; }
  .seat-name { max-width: 4.8rem; font-size: 12px; }
  .seat-score { font-size: 15px; }
  .seat-count { font-size: 10px; }
  .seat-back, .seat-claim { width: 22px; margin-left: -10px; }
}
