:root {
  --bg: #f6f0e6;
  --bg2: #e7e0d4;
  --ink: #1c1917;
  --muted: #6e665e;
  --accent: #c44b2f;
  --accent-deep: #9a3a22;
  --teal: #2a7a6a;
  --gold: #c9a227;
  --line: rgba(28, 25, 23, 0.12);
  --card-w: 100px;
  --card-h: 140px;
  --radius: 10px;
  --font: "Zen Maru Gothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-display: "Shippori Mincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* aliases used elsewhere */
  --coral: var(--accent);
  --mint: var(--teal);
  --lemon: #e8d5a3;
  --sky: #8fadbf;
  --grape: #5c6bc0;
  --wood: #3e2f26;
  --steam: #f6f0e6;
  --mist: #e7e0d4;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(ellipse 70% 50% at 50% -10%, rgba(196, 92, 38, 0.08), transparent),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
}

body {
  padding: 0.5rem clamp(0.4rem, 2vw, 1rem) 1rem;
}

body.in-lobby {
  height: 100dvh;
  height: 100svh;
  max-height: 100dvh;
  max-height: 100svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding:
    max(0.5rem, env(safe-area-inset-top))
    max(0.75rem, env(safe-area-inset-right))
    max(0.5rem, env(safe-area-inset-bottom))
    max(0.75rem, env(safe-area-inset-left));
}

body.in-lobby #lobby,
body.in-lobby .lobby-stage {
  flex: 1 1 auto;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 0;
}

.lobby-stage {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(0.75rem, 2vw, 1.75rem);
  align-items: stretch;
  height: 100%;
  min-height: 0;
}

/* display:grid must not override the hidden attribute */
#lobby[hidden],
.lobby-stage[hidden] {
  display: none !important;
}

.lobby-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: clamp(0.5rem, 2vh, 1.5rem);
  border-radius: calc(var(--radius) + 4px);
  background:
    radial-gradient(ellipse 80% 55% at 50% 20%, rgba(201, 162, 39, 0.16), transparent 60%),
    radial-gradient(ellipse 70% 50% at 70% 80%, rgba(196, 75, 47, 0.12), transparent 55%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.55), rgba(246, 240, 230, 0.2));
  overflow: hidden;
  animation: lobby-visual-in 0.7s var(--ease) both;
}

.lobby-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 0;
  overflow: auto;
  animation: lobby-panel-in 0.65s var(--ease) 0.08s both;
}

.hero {
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
  z-index: 1;
}

.hero-title {
  margin: 0;
  line-height: 0;
}

.title-logo {
  display: block;
  width: min(100%, 28rem);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 10px 18px rgba(62, 47, 38, 0.18));
  animation: lobby-logo-in 0.8s var(--ease) both;
}

.hero-sub {
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: clamp(0.92rem, 1.4vw, 1.08rem);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.45;
  text-wrap: balance;
  word-break: keep-all;
  line-break: strict;
}

.hero-sub-br {
  display: none;
}

.lobby-card-fan {
  position: relative;
  width: min(100%, 22rem);
  height: clamp(7.5rem, 18vh, 11rem);
  margin: clamp(1rem, 3vh, 2rem) auto 0;
  z-index: 0;
}

.lobby-fan-card {
  --i: 0;
  position: absolute;
  left: 50%;
  bottom: 0;
  width: clamp(4.2rem, 9vw, 5.6rem);
  height: auto;
  border-radius: 8px;
  box-shadow: 0 10px 22px rgba(43, 42, 50, 0.18);
  transform-origin: 50% 100%;
  transform: translateX(-50%) rotate(calc((var(--i) - 2) * 14deg)) translateY(0.15rem);
  animation: lobby-fan-in 0.75s var(--ease) calc(0.12s + var(--i) * 0.05s) both;
}

@keyframes lobby-visual-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lobby-panel-in {
  from {
    opacity: 0;
    transform: translateX(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lobby-logo-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lobby-fan-in {
  from {
    opacity: 0;
    transform: translateX(-50%) rotate(0deg) translateY(1.2rem) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) rotate(calc((var(--i) - 2) * 14deg)) translateY(0.15rem);
  }
}

@keyframes bounce-in {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#global-status {
  flex: 0 0 auto;
  text-align: center;
  min-height: 1.25rem;
  color: var(--muted);
  font-size: 0.9rem;
}

#global-status:empty,
#global-status[hidden] {
  display: none;
  min-height: 0;
  margin: 0;
}

body.in-game #global-status {
  display: none !important;
}

.lobby-card {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  padding: 1.15rem 1.25rem 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius);
  box-shadow: 0 12px 0 rgba(196, 75, 47, 0.12), 0 18px 40px rgba(43, 42, 50, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.95);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}

/* Short PC viewport: allow page scroll so the layout doesn't crush */
@media (min-width: 641px) and (max-height: 780px) {
  body.in-lobby {
    height: auto;
    min-height: 100dvh;
    min-height: 100svh;
    max-height: none;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body.in-lobby #lobby,
  body.in-lobby .lobby-stage {
    flex: 0 0 auto;
    height: auto;
    min-height: calc(100dvh - 1.5rem);
    min-height: calc(100svh - 1.5rem);
  }

  .lobby-stage {
    height: auto;
    align-items: stretch;
  }

  .lobby-visual {
    overflow: visible;
    min-height: 18rem;
  }

  .lobby-panel {
    overflow: visible;
    justify-content: flex-start;
    padding: 0.35rem 0;
  }

  .lobby-card {
    max-height: none;
    overflow: visible;
  }
}

.lobby-card label,
.lobby-card legend {
  display: block;
  margin: 0.55rem 0 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.lobby-card > label[for="name-input"] {
  margin-top: 0;
}

.lobby-settings {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.55rem;
  min-height: 0;
}

.rule-fieldset {
  margin: 1rem 0 0;
  padding: 0.75rem 0.85rem;
  border: 2px dashed var(--sky);
  border-radius: 12px;
  background: rgba(126, 200, 255, 0.12);
}

.rule-fieldset.nested {
  margin: 0;
  border-style: solid;
  border-width: 1px;
  border-color: var(--line);
  background: #faf7f3;
}

.lobby-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.lobby-details summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--muted);
  user-select: none;
}

.lobby-details summary::-webkit-details-marker {
  display: none;
}

.lobby-details summary::after {
  content: "▸";
  color: var(--muted);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
}

.lobby-details[open] summary::after {
  transform: rotate(90deg);
}

.lobby-details .details-summary-val {
  margin-left: auto;
  margin-right: 0.35rem;
  font-weight: 600;
  color: var(--ink);
  font-size: 0.78rem;
}

.lobby-details .rule-fieldset {
  margin-top: 0;
  border-radius: 0 0 8px 8px;
  border-top: 1px solid var(--line);
}

.lobby-settings-grid {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.75rem;
}

.lobby-setting-cell {
  display: grid;
  grid-template-columns: minmax(5.5rem, 7.5rem) minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.lobby-setting-cell label {
  margin: 0;
  line-height: 1.3;
}

.lobby-setting-cell input,
.lobby-setting-cell select {
  width: 100%;
  max-width: 8.5rem;
  justify-self: end;
  text-align: center;
}

.lobby-settings-grid .settings-hint {
  margin: 0.2rem 0 0;
}

.join-row {
  display: flex;
  gap: 0.45rem;
  align-items: stretch;
}

.join-row input {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.join-row .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.radio-row {
  display: flex !important;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0 !important;
  font-size: 0.84rem !important;
  color: var(--ink) !important;
  font-weight: 500 !important;
  cursor: pointer;
}

.lobby-card input[type="text"],
.lobby-card input[type="number"],
.lobby-card select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 2px solid #ffe0c8;
  background: #fffaf3;
  color: var(--ink);
  font: inherit;
  font-size: 0.95rem;
  border-radius: 10px;
}

.settings-fieldset .settings-hint {
  margin: 0.5rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
  line-height: 1.4;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.85rem;
  flex: 0 0 auto;
}

.btn-row-rest {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.lobby-guide-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

/* PC: settings always expanded / scannable (must stay [open] so controls work) */
@media (min-width: 641px) {
  .lobby-details summary {
    pointer-events: none;
    cursor: default;
    padding-bottom: 0.35rem;
  }

  .lobby-details summary::after {
    display: none;
  }

  .lobby-details .details-summary-val {
    display: none;
  }

  .lobby-details-rules .rule-fieldset.nested {
    border-top: none;
    padding-top: 0.15rem;
  }

  .lobby-details-match .lobby-settings-grid {
    border-top: none;
  }

  .lobby-details input,
  .lobby-details select,
  .lobby-details .radio-row,
  .lobby-details label {
    pointer-events: auto;
  }
}

.host-confirm-modal {
  width: min(420px, 100%);
}

.host-confirm-body {
  padding: 0.35rem 1.1rem 1.15rem;
}

.host-confirm-list {
  list-style: none;
  margin: 0 0 0.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #faf7f3;
  overflow: hidden;
}

.host-confirm-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.host-confirm-list li:last-child {
  border-bottom: none;
}

.host-confirm-list span {
  color: var(--muted);
  font-weight: 600;
}

.host-confirm-list strong {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.host-confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.85rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0.7rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn:hover:not(:disabled) {
  background: #faf7f3;
  border-color: var(--accent);
}

.btn:active:not(:disabled) {
  transform: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-deep);
}

.btn.danger {
  background: #a33b2b;
  border-color: #a33b2b;
  color: #fff;
}

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.btn.big {
  font-size: 1.05rem;
  padding: 0.85rem 1.25rem;
}

.table-shell {
  max-width: 960px;
  margin: 0 auto;
}

.table-shell.table-playing.play-stage {
  max-width: min(1280px, 100%);
}

.table-playing.play-stage {
  max-width: min(1280px, 100%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  height: calc(100dvh - 0.75rem);
  max-height: calc(100dvh - 0.75rem);
  overflow: hidden;
  min-height: 0;
}

body.match-playing {
  background:
    radial-gradient(ellipse 80% 45% at 50% -8%, rgba(196, 75, 47, 0.1), transparent 55%),
    linear-gradient(180deg, var(--steam) 0%, var(--mist) 100%);
  overflow: hidden;
  height: 100dvh;
  padding: 0.35rem clamp(0.4rem, 1.5vw, 1rem);
}

body.match-playing #table {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.match-playing #global-status {
  display: none;
}

body.match-playing .table-playing .turn-banner {
  background: color-mix(in srgb, var(--turn-seat, var(--accent)) 8%, #fff);
  border-color: color-mix(in srgb, var(--turn-seat, var(--accent)) 28%, var(--line));
}

.table-playing > .turn-banner,
.table-playing > .seat-row,
.table-playing > .field-mat,
.table-playing > .hand-dock,
.table-playing > .hand-stage,
.table-playing > .play-dock,
.table-playing > .scores,
.table-playing > .opponent-zone,
.table-playing > .center-zone,
.table-playing > .hand-zone,
.table-playing > .actions,
.table-playing > .log {
  margin: 0;
}

.turn-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  padding: 0.4rem 0.7rem;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-left-color: var(--seat, var(--accent));
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
  animation: none;
}

.turn-banner-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
}

.turn-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: stretch;
  margin-left: auto;
}

.btn-tool {
  min-height: 2.05rem;
  padding: 0.3rem 0.55rem !important;
  font-size: 0.74rem !important;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  background: #fff !important;
  color: var(--ink) !important;
  border: 1px solid color-mix(in srgb, var(--ink) 18%, #fff) !important;
  box-shadow: none;
}

.btn-tool:hover,
.btn-tool:focus-visible {
  background: #fff !important;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line)) !important;
  color: var(--accent-deep) !important;
}

.room-chip--inline,
.mode-badge--inline {
  display: inline-block;
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  letter-spacing: 0.02em;
}

.turn-phase {
  background: color-mix(in srgb, var(--seat, var(--accent)) 12%, #f0ebe4);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.score-pill {
  padding: 0.35rem 0.65rem;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--line);
  border-bottom: 3px solid var(--seat, #ddd);
  display: flex;
  gap: 0.45rem;
  align-items: baseline;
  font-weight: 600;
}

.turn-banner strong {
  font-size: 1.02rem;
  color: var(--seat, var(--coral));
}

.turn-you {
  font-weight: 700;
  color: var(--accent);
}

.hot-tag {
  margin-left: 0.15rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.table-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.brand {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.82rem;
  color: var(--muted);
}

.mode-badge,
.room-chip {
  padding: 0.2rem 0.55rem;
  background: #efe9e2;
  color: var(--ink);
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
  border: 1px solid var(--line);
}

.room-chip {
  letter-spacing: 0.08em;
}

.scores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
}

.scoreboard {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.score-pill.active {
  background: color-mix(in srgb, var(--seat, var(--accent)) 22%, #fff);
  border-color: color-mix(in srgb, var(--seat, var(--accent)) 55%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--seat, var(--accent)) 35%, transparent);
}

.score-pill strong {
  font-size: 1.35rem;
  color: var(--seat, var(--coral));
  font-variant-numeric: tabular-nums;
}

.goal {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
}

/* Seat chips — replace dashboard scores + opponent panels */
.seat-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0.05rem 0.05rem 0.15rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.seat-chip {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.5rem;
  row-gap: 0;
  flex: 1 1 0;
  min-width: 6.5rem;
  padding: 0.35rem 0.5rem 0.35rem 0.55rem;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--seat, var(--accent));
  box-shadow: 0 1px 0 rgba(28, 25, 23, 0.04);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.seat-chip.is-turn {
  border-color: color-mix(in srgb, var(--seat, var(--accent)) 55%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--seat, var(--accent)) 22%, transparent);
}

.seat-chip.is-me {
  background: color-mix(in srgb, var(--seat, var(--accent)) 7%, #fff);
}

.seat-chip-name {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-chip-name small {
  margin-left: 0.25rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.seat-chip-score {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-variant-numeric: tabular-nums;
}

.seat-chip-score strong {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}

.seat-chip-hand {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.goal-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.45rem 0.7rem;
  border-radius: 12px;
  background: transparent;
  border: 1px dashed color-mix(in srgb, var(--ink) 18%, transparent);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.goal-chip strong {
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
}

.opponents-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.opp-block {
  flex: 1 1 120px;
  background: #fff;
  border-radius: var(--radius);
  padding: 0.4rem 0.55rem;
  border: 1px solid color-mix(in srgb, var(--seat, #ccc) 55%, var(--line));
  border-left: 3px solid var(--seat, #eee);
}

.opp-block h3 {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  color: var(--seat);
}

.opp-block small {
  color: var(--muted);
  font-weight: 500;
}

.hand-zone,
.center-zone,
.actions,
.log,
.field-mat,
.hand-stage,
.play-dock {
  margin: 0;
}

/* Field mat — soft paper; height owned by parent flex, not content */
.field-mat.center-zone {
  text-align: center;
  padding: 0.45rem 0.55rem;
  background: color-mix(in srgb, var(--turn-seat, var(--accent)) 8%, #fff);
  border-radius: 12px;
  border: 1px dashed color-mix(in srgb, var(--turn-seat, var(--accent)) 35%, var(--line));
  box-shadow: none;
  color: var(--ink);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  gap: 0.65rem;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}

.field-rail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.4rem;
  min-width: 0;
}

.field-rail--tools {
  align-items: stretch;
  width: 5.5rem;
}

.field-rail--tools .btn-tool {
  width: 100%;
  min-height: 2.15rem;
  writing-mode: horizontal-tb;
}

.field-rail--piles {
  align-items: center;
  width: 5.5rem;
}

.field-mat .hint,
.field-mat .big-hint {
  color: var(--muted);
}

.field-mat .pending.pop {
  background: var(--lemon);
  color: var(--ink);
  animation: field-meta-in 0.28s var(--ease) both;
}

/* Meta fills the middle cell — no height jumping */
.field-mat-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.field-mat-idle {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: color-mix(in srgb, var(--muted) 55%, transparent);
  user-select: none;
}

.field-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  max-width: 28rem;
  text-align: center;
}

.field-status-phase {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent-deep);
  letter-spacing: 0.06em;
}

.field-status-event {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.field-status-msg {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.field-status-limits {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.field-mat-meta.is-cook {
  justify-content: flex-start;
  padding: 0.25rem 0;
  overflow: auto;
}

.field-mat-meta .cook-preview {
  width: min(100%, 26rem);
  margin-top: 0.35rem;
  text-align: left;
}

.field-mat-meta > .pending,
.field-mat-meta > .taste-actions,
.field-mat-meta > .hint,
.field-mat-meta > .cook-reveal {
  animation: field-meta-in 0.28s var(--ease) both;
  max-width: 100%;
  max-height: 100%;
}

/* Avoid remount flicker while CPU acks refresh the reveal UI */
.field-mat-meta.is-reveal > .cook-reveal,
.field-mat-meta > .cook-reveal {
  animation: none;
}

.field-mat-meta .cook-reveal {
  margin: 0;
  max-height: 100%;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100%, 34rem);
}

.field-mat-meta.is-reveal .cook-reveal {
  width: 100%;
  max-width: 100%;
  justify-content: center;
  overflow: hidden;
}

@keyframes field-meta-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .field-mat-meta > .pending,
  .field-mat-meta > .taste-actions,
  .field-mat-meta > .hint,
  .field-mat-meta > .cook-reveal,
  .field-mat .pending.pop {
    animation: none;
  }
}

.piles {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 0;
  align-items: flex-end;
}

.piles--rail {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.pile {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.pile-label {
  margin-top: 0.2rem;
}

.pile strong {
  font-size: 1.25rem;
  color: var(--ink);
  display: block;
  font-variant-numeric: tabular-nums;
}

.pile-stack {
  position: relative;
  width: 2.4rem;
  height: 3.2rem;
  margin: 0 auto;
}

.pile-layer {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background:
    repeating-linear-gradient(-20deg, #ff8e53, #ff8e53 6px, #ff6b6b 6px, #ff6b6b 12px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  transform: translate(calc(var(--i, 0) * 2px), calc(var(--i, 0) * -2px));
}

.pile-layer.is-face {
  background: linear-gradient(180deg, #fff8f0, #f0e4d6);
  border-color: var(--line);
}

.pile-deck {
  animation: wiggle 3.5s ease-in-out infinite;
}

@keyframes wiggle {
  0%,
  100% {
    transform: rotate(0);
  }
  50% {
    transform: rotate(-2deg);
  }
}

.pending.pop {
  margin: 0.5rem 0;
  padding: 0.55rem 0.85rem;
  background: var(--lemon);
  border-radius: 12px;
  font-weight: 700;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  max-width: 100%;
  box-sizing: border-box;
  animation: bounce-in 0.3s var(--ease) both;
}

.pending-decl {
  text-align: center;
  line-height: 1.35;
}

.timer {
  margin-left: 0;
  padding: 0.15rem 0.5rem;
  background: #fff;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: inline-block;
  flex-shrink: 0;
}

.taste-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.taste-btn {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    transform: scale(1.05);
  }
}

/* Hand + dock cluster */
.hand-dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-height: 0;
  max-height: 42%;
  overflow: visible;
}

.hand-stage.hand-zone {
  padding: 0.55rem 0.5rem 0.3rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 252, 247, 0.92));
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  box-shadow: 0 6px 16px rgba(28, 25, 23, 0.04);
  min-height: 0;
  overflow: visible;
  display: flex;
  flex-direction: column;
}

.hand-zone-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
  flex: 0 0 auto;
}

.hand-stage-title {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.hand-zone-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hand-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, #fff);
  color: var(--accent-deep);
  font-size: 0.75rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hand-my-score {
  margin-left: 0.1rem;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

.hand-my-score small {
  margin-left: 0.1rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
}

.hand-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: flex-end;
  justify-content: center;
}

.card-row.hand {
  flex-wrap: nowrap;
  justify-content: flex-start;
  width: 100%;
  gap: 0.35rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding: 1rem 0.15rem 0.45rem; /* room for selected card lift */
  flex: 0 0 auto;
  /* Keep empty-hand height equal to a single card row */
  min-height: calc(var(--card-h) + 1.45rem);
  height: calc(var(--card-h) + 1.45rem);
  align-content: center;
  align-items: flex-end;
  box-sizing: border-box;
}

.card-row.hand .card-wrap {
  flex: 0 0 var(--card-w);
  width: var(--card-w);
  min-width: var(--card-w);
  max-width: var(--card-w);
}

.card-row.hand .card img {
  height: auto;
  aspect-ratio: 5 / 6.2;
}

.turn-tools--mobile {
  display: none;
}

.seat-row {
  flex: 0 0 auto;
}

.turn-banner {
  flex: 0 0 auto;
}

.card-wrap {
  position: relative;
  width: var(--card-w);
  transition: transform 0.2s var(--ease), filter 0.2s var(--ease);
}

.card-wrap:hover {
  transform: translateY(-8px) rotate(-1deg);
  z-index: 2;
}

.card-wrap.selected {
  transform: translateY(-12px) scale(1.04);
  z-index: 3;
  filter: drop-shadow(0 10px 12px rgba(196, 75, 47, 0.18));
}

.card {
  width: 100%;
  padding: 0;
  border: 3px solid #fff;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 18px rgba(28, 25, 23, 0.1);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.2s ease;
}

.card-wrap.selected .card {
  border-color: var(--accent);
  box-shadow:
    0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent),
    0 12px 22px rgba(196, 75, 47, 0.22);
}

.card img {
  width: 100%;
  height: calc(var(--card-h) - 1.7rem);
  object-fit: cover;
  display: block;
  background: #fff3e8;
}

.card-name {
  font-size: 0.72rem;
  padding: 0.22rem;
  text-align: center;
  font-weight: 700;
  background: #fff8f0;
  line-height: 1.15;
}

.card-row.hand .card-name {
  font-size: clamp(0.55rem, 1.6vw, 0.72rem);
  padding: 0.15rem 0.1rem;
}

.card-info {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: var(--lemon);
  color: var(--ink);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  z-index: 4;
  line-height: 1;
  padding: 0;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.card.back {
  height: calc(var(--card-h) * 0.55);
  width: calc(var(--card-w) * 0.55);
  background:
    repeating-linear-gradient(-20deg, #ff8e53, #ff8e53 8px, #ff6b6b 8px, #ff6b6b 16px);
  border: 3px solid #fff;
  border-radius: 10px;
  cursor: default;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.center-zone:not(.field-mat) {
  text-align: center;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 255, 255, 0.75);
  border-radius: var(--radius);
  border: 1px dashed color-mix(in srgb, var(--turn-seat, var(--mint)) 45%, var(--line));
}

.play-dock.actions {
  padding: 0.2rem 0.1rem 0.05rem;
  flex: 0 0 auto;
  /* Fixed slot so phase/button swaps don't resize the field mat */
  height: 3.55rem;
  min-height: 3.55rem;
  max-height: 3.55rem;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.play-dock .action-dock {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.play-dock .action-row,
.play-dock .decl-btns {
  height: 2.85rem;
  min-height: 2.85rem;
  width: 100%;
  max-width: 42rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: nowrap;
}

.play-dock .action-row .btn,
.play-dock .decl-btns .btn {
  min-height: 2.75rem;
  height: 2.75rem;
}

.play-dock .action-dock-status {
  margin: 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 2.85rem;
}

.play-dock .action-dock-note {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 0.15rem);
  margin: 0;
  pointer-events: none;
}

.hand-stage .cook-preview {
  display: none; /* cook preview lives on the field mat */
}

.cook-preview {
  margin-top: 0.45rem;
  padding: 0.5rem 0.7rem;
  background: #f3fffb;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--mint) 45%, var(--line));
}

.cook-preview.valid {
  background: #e8fff6;
}

.cook-preview.invalid {
  border-color: var(--lemon);
  background: #fffceb;
}

.cook-preview.idle {
  text-align: center;
  color: var(--muted);
  font-weight: 600;
}

.cook-preview-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.cook-preview-total .total {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--coral);
}

.cook-preview-total .total small {
  font-size: 0.5em;
}

.cook-preview-lines {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.55rem;
  font-size: 0.78rem;
}

.cook-preview-lines li {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px dashed #cdeedf;
}

.cook-preview-lines li.cook-line-boost {
  color: #1a9a6e;
  font-weight: 800;
}

.cook-preview-lines li.cook-line-boost strong {
  color: #0d7a54;
}

.cook-preview-lines li.cook-line-cut {
  color: #c4472a;
  font-weight: 800;
}

.cook-preview-lines li.cook-line-cut strong {
  color: #a33620;
}

.cook-preview-note {
  color: #c47b00;
  font-size: 0.82rem;
  font-weight: 600;
}

.cook-preview-status.ok {
  color: #1a9a6e;
  font-weight: 800;
}

.cook-preview-status.warn {
  color: #c47b00;
  font-weight: 700;
}

.action-block {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.action-block.stack {
  flex-direction: column;
  align-items: stretch;
}

.action-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  width: 100%;
}

.action-row .btn {
  flex: 1;
}

.mini-card-row {
  display: flex;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.mini-card {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.decl-label {
  margin: 0;
  font-weight: 700;
  font-size: 0.9rem;
  text-align: center;
}

.decl-btns {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  justify-content: stretch;
  align-items: stretch;
  width: 100%;
}

.decl-btns .btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.45rem 0.3rem;
  font-weight: 800;
  font-size: 0.85rem;
}

.decl-btns .btn-clear-sel,
.action-row .btn-clear-sel {
  flex: 0 0 2.5rem;
  min-width: 2.5rem;
  padding: 0.45rem 0.25rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.action-dock {
  width: 100%;
}

.action-dock .action-row {
  width: 100%;
}

.action-dock .action-row .btn {
  min-height: 2.75rem;
}

.action-dock-note {
  margin: 0.25rem 0 0;
  text-align: center;
  font-size: 0.75rem;
}

.hint {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

.big-hint {
  font-size: 1.05rem;
  text-align: center;
}

.log {
  max-height: 5.5rem;
  overflow: auto;
  font-size: 0.72rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
}

.log h3 {
  margin: 0 0 0.25rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
}

.log ul {
  margin: 0;
  padding-left: 1.1rem;
}

.log-modal {
  width: min(28rem, 100%);
  max-height: min(70dvh, 32rem);
  display: flex;
  flex-direction: column;
}

.log-modal-list {
  margin: 0;
  padding: 0.15rem 0.85rem 0.85rem 1.35rem;
  overflow: auto;
  flex: 1 1 auto;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--ink);
}

.log-modal-list li {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.4rem 0;
}

.log-entry-text {
  display: block;
}

.log-card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin-top: 0.15rem;
}

.log-card-row .mini-card,
.log-card-row .mini-card--back {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.log-card-row .mini-card--back::after {
  font-size: 1.1rem;
}

.mini-card--back {
  display: inline-block;
  box-sizing: border-box;
  background: repeating-linear-gradient(
    -45deg,
    #d8d4cc,
    #d8d4cc 2px,
    #c8c4bc 2px,
    #c8c4bc 4px
  );
  position: relative;
}

.mini-card--back::after {
  content: "?";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85em;
  font-weight: 800;
  color: #6a6458;
}

.field-status-cards {
  justify-content: center;
  margin: 0.15rem 0 0.25rem;
}

.log-modal-empty {
  margin: 0.5rem 1rem 1rem;
  text-align: center;
}

/* Center waiting / finished cards in the viewport */
body.match-waiting,
body.match-finished {
  min-height: 100dvh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem clamp(0.5rem, 2vw, 1.25rem);
}

body.match-waiting #table,
body.match-finished #table {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  overflow: visible;
}

.panel.waiting,
.panel.finished {
  text-align: center;
  padding: 2.5rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  max-width: 28rem;
  margin: 0 auto;
  width: 100%;
  flex: 0 1 auto;
  box-shadow: 0 12px 0 rgba(196, 75, 47, 0.12), 0 18px 40px rgba(43, 42, 50, 0.08);
}

.panel.wait-panel {
  max-width: min(28rem, 96vw);
  padding: 1.5rem 1.25rem 1.35rem;
}

.wait-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  width: min(100%, 18rem);
  margin: 1.1rem auto 0;
}

.wait-start,
.wait-actions .wait-start-hint {
  width: 100%;
  margin: 0;
}

.wait-start.btn {
  min-height: 3.35rem;
  height: 3.35rem;
  font-size: 1.08rem;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent-deep) 55%, transparent);
  box-sizing: border-box;
}

.wait-start-hint {
  text-align: center;
  font-weight: 600;
  padding: 0.55rem 0.35rem;
}

.wait-guides {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.wait-guides .btn {
  min-height: 2.85rem;
  height: 2.85rem;
  font-weight: 700;
  border-radius: 12px;
  box-sizing: border-box;
}

.wait-home {
  margin-top: 0.85rem;
  min-height: 2.85rem;
  height: 2.85rem;
  font-weight: 700;
  border-radius: 12px;
  box-sizing: border-box;
}

.panel.result-panel {
  max-width: min(36rem, 96vw);
  text-align: left;
  max-height: calc(100dvh - 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.25rem 1.35rem;
  margin: 0 auto;
  width: 100%;
  flex: 0 1 auto;
}

.panel.result-panel h2,
.panel.result-panel .result-sub,
.panel.result-panel .scoreboard,
.panel.result-panel .result-actions {
  text-align: center;
}

.panel.finished h2 {
  color: var(--accent);
  font-family: var(--font-display);
  font-size: clamp(1.45rem, 3vw, 1.8rem);
  margin: 0;
  letter-spacing: 0.02em;
}

.result-sub {
  color: var(--muted);
  margin: 0.35rem 0 0.85rem;
  font-weight: 600;
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  margin-top: 1.25rem;
  flex: 0 0 auto;
}

.result-actions:has(.hint) {
  grid-template-columns: 1fr;
}

.result-actions .hint {
  margin: 0;
  grid-column: 1 / -1;
  text-align: center;
  font-weight: 600;
}

.result-actions .btn {
  min-height: 3rem;
  height: 3rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.98rem;
  font-weight: 700;
  border-radius: 12px;
  box-sizing: border-box;
}

.result-actions .btn.primary {
  box-shadow: 0 3px 0 color-mix(in srgb, var(--accent-deep) 55%, transparent);
}

.disconnect-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #fff3f0;
  border: 2px solid #e07050;
  border-radius: 12px;
  color: #8a2f1a;
  font-weight: 700;
}

.disconnect-banner-text {
  flex: 1;
  min-width: 10rem;
}

.disconnect-banner p {
  margin: 0;
}

.disconnect-banner-note {
  margin-top: 0.25rem !important;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a05038;
}

.disconnect-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cook-history {
  margin-top: 1.25rem;
  padding: 0.85rem 1rem;
  background: #faf7f3;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.cook-history h3 {
  margin: 0 0 0.65rem;
  font-size: 0.95rem;
  text-align: center;
}

.cook-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-height: min(42vh, 320px);
  overflow: auto;
}

.cook-history-item {
  padding: 0.55rem 0.65rem;
  background: color-mix(in srgb, var(--seat, #ccc) 14%, #fff);
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--seat, #ccc) 35%, var(--line));
  border-left: 4px solid var(--seat, var(--accent));
}

.cook-history-item.winning {
  border-color: var(--seat, var(--accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--seat, var(--accent)) 25%, transparent);
}

.cook-history-name {
  color: var(--seat, var(--ink));
}

.cook-history-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  margin-bottom: 0.35rem;
  font-size: 0.88rem;
}

.cook-history-index {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.cook-history-score {
  margin-left: auto;
  font-weight: 700;
  color: var(--teal);
  font-variant-numeric: tabular-nums;
}

.cook-history-win {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.result-scoreboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
  margin: 0.85rem 0 0.25rem;
}

.result-seat {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.65rem 0.8rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--seat) 18%, #fff);
  border: 2px solid color-mix(in srgb, var(--seat) 45%, #fff);
  text-align: left;
}

.result-seat.winner {
  box-shadow: 0 0 0 2px var(--seat);
}

.result-seat.is-cpu {
  background: color-mix(in srgb, var(--seat) 12%, #eef1f5);
  border-style: dashed;
}

.result-seat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
}

.result-seat-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.55rem;
  width: 100%;
}

.result-rank {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--seat);
  min-width: 2.2rem;
}

.result-seat-name {
  font-weight: 700;
  color: var(--seat);
}

.result-seat-score {
  margin-left: auto;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.result-seat-score small {
  font-size: 0.55em;
  margin-left: 0.15rem;
  color: var(--muted);
}

.player-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  line-height: 1.3;
}

.player-tag.cpu {
  background: #3d4a5c;
  color: #fff;
}

.player-tag.human {
  background: color-mix(in srgb, var(--seat, var(--accent)) 85%, #000);
  color: #fff;
}

.player-tag.win {
  background: var(--gold);
  color: #fff;
}

.rules-modal {
  width: min(720px, 100%);
  padding: 0 0 0.5rem;
}

.rules-sheet {
  padding: 0.5rem 0.85rem 0.85rem;
  max-height: min(78vh, 780px);
  overflow: auto;
}

.rules-sheet img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.room-code {
  font-size: 2rem;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: var(--grape);
}

.room-code-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  margin: 0.15rem 0 0.35rem;
}

.room-code-row .room-code {
  margin: 0;
}

.room-code-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.room-copy-btn {
  min-height: 2.5rem;
  height: 2.5rem;
  padding: 0.35rem 0.9rem;
  font-weight: 700;
  border-radius: 10px;
}

.host-room-note,
.host-confirm-warn {
  margin: 0.2rem 0 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #8a2f1a;
  line-height: 1.45;
  text-align: center;
}

.host-confirm-warn {
  text-align: left;
}

.reconnect-wait-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #fff8e8;
  border: 2px solid #c9a227;
  border-radius: 12px;
  color: #5c4a12;
  font-weight: 700;
}

.reconnect-wait-text p {
  margin: 0;
}

.reconnect-wait-note {
  margin-top: 0.2rem !important;
  font-size: 0.8rem;
  font-weight: 600;
}

.reconnect-wait-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wait-players {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin: 1rem 0;
}

.wait-chip {
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 2px solid var(--seat);
  border-radius: 999px;
  font-weight: 700;
  color: var(--seat);
}

/* Shared fan layout for completed dishes (PC + mobile) */
.cook-reveal-cards {
  --fan-step: 2.85rem;
  --fan-ang: 4deg;
  --fan-push: 1.55rem;
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: min(100%, 26rem);
  height: 9rem;
  margin: 0.35rem auto 0.2rem;
  padding: 0;
  overflow: visible;
  z-index: 1;
}

.cook-reveal-card {
  position: absolute;
  left: 50%;
  bottom: 0.1rem;
  display: block;
  flex: none;
  width: min(5.8rem, 18vw);
  max-width: 6.2rem;
  min-width: 4.2rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transform-origin: 50% 100%;
  --d: calc(var(--i, 0) - (var(--n, 1) - 1) / 2);
  transform: translateX(-50%) translateX(calc(var(--d) * var(--fan-step))) rotate(calc(var(--d) * var(--fan-ang)));
  z-index: calc(var(--i, 0) + 1);
  filter: drop-shadow(0 3px 6px rgba(28, 25, 23, 0.16));
  transition: transform 0.2s var(--ease);
}

.cook-reveal-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cook-reveal-cards.is-focusing .cook-reveal-card {
  --rel: calc(var(--i) - var(--focus));
  transform: translateX(-50%)
    translateX(calc(var(--d) * var(--fan-step) + var(--rel) * var(--fan-push)))
    rotate(calc(var(--d) * var(--fan-ang)));
}

.cook-reveal-cards.is-focusing .cook-reveal-card.is-focus {
  transform: translateX(-50%) translateX(calc(var(--d) * var(--fan-step)))
    rotate(calc(var(--d) * var(--fan-ang))) scale(1.08);
}

/* Briefly ignore neighbor hits while the fan spreads under the finger */
.cook-reveal-cards.is-settling .cook-reveal-card:not(.is-focus) {
  pointer-events: none;
}

.cook-reveal.is-win .cook-reveal-cards {
  height: 8.4rem;
  width: min(100%, 25rem);
}

.cook-reveal-card img {
  width: 100%;
  height: auto;
  aspect-ratio: 5 / 7;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid #fff;
  box-shadow: 0 4px 10px rgba(28, 25, 23, 0.14);
  display: block;
  pointer-events: none;
}

.cook-reveal-points {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--mint);
  margin-top: 0.35rem;
}

@media (prefers-reduced-motion: reduce) {
  .cook-reveal-card {
    transition: none;
  }
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(43, 42, 50, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
  max-height: min(90vh, 860px);
  overflow: auto;
  animation: bounce-in 0.28s var(--ease) both;
}

.modal-close {
  position: absolute;
  top: 0.4rem;
  right: 0.5rem;
  width: 2.2rem;
  height: 2.2rem;
  border: none;
  background: var(--lemon);
  border-radius: 50%;
  color: var(--ink);
  font-size: 1.3rem;
  cursor: pointer;
  font-weight: 800;
  z-index: 2;
}

.detail-modal {
  width: min(560px, 100%);
  padding: 1.25rem;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(120px, 180px) 1fr;
  gap: 1rem;
}

.detail-art {
  width: 100%;
  border-radius: 12px;
  border: 3px solid #ffe0c8;
}

.detail-cat {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 700;
}

.detail-title {
  margin: 0.2rem 0 0.6rem;
  font-size: 1.6rem;
  color: var(--coral);
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0;
}

.detail-base span,
.detail-count span,
.detail-effect span,
.detail-discard span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 700;
}

.detail-base,
.detail-count {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

.ref-stats {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--coral);
}

.detail-effect,
.detail-discard {
  margin: 0.55rem 0 0;
  line-height: 1.45;
  font-size: 0.92rem;
}

.ref-discard {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.ref-modal {
  width: min(720px, 100%);
}

.ref-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 1rem;
  border-bottom: 2px solid #ffe0c8;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.ref-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--coral);
}

.ref-actions {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.ref-actions .modal-close {
  position: static;
}

.ref-list {
  padding: 0.55rem 0.85rem 1.1rem;
}

.ref-group-title {
  margin: 0 0 0.55rem;
  color: var(--mint);
  font-size: 0.82rem;
}

.ref-group h3 {
  margin: 0.75rem 0 0.4rem;
  color: var(--mint);
  font-size: 0.85rem;
}

.ref-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  margin-bottom: 0.4rem;
  border: 1px solid var(--line);
  background: #fff;
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
}

.ref-row:hover {
  background: #fffaf4;
  border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.ref-row.dim {
  opacity: 0.45;
  background: #f4f2ef;
}

.ref-row img {
  width: 56px;
  height: 78px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.ref-row-body {
  min-width: 0;
  flex: 1;
}

.ref-row-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.55rem;
  margin-bottom: 0.2rem;
}

.ref-row strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.ref-effect {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.ref-row p {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.ref-sheet {
  padding: 0.75rem;
}

.ref-sheet img {
  width: 100%;
  height: auto;
}

.modal-backdrop:has(.detail-modal),
.detail-backdrop {
  z-index: 110;
}

.detail-modal--swap {
  animation: bounce-in 0.22s var(--ease) both;
}

.helper-body,
.ref-list {
  will-change: height;
}

/* FX */
.fx-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  overflow: hidden;
}

.fx-toast {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  background: #fff;
  padding: 0.65rem 1.2rem;
  border-radius: 999px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: toast-up 1.5s var(--ease) forwards;
  border: 3px solid var(--mint);
}

.fx-toast-draw {
  border-color: var(--sky);
}

.fx-splash {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splash 1.7s var(--ease) forwards;
}

.fx-splash span {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  padding: 0.6rem 1.2rem;
  background: #fff;
  border-radius: 20px;
  border: 4px solid var(--coral);
  box-shadow: 0 12px 0 rgba(255, 107, 107, 0.3);
}

.fx-taste-win span {
  border-color: var(--mint);
  color: #1a9a6e;
}

.fx-taste-lose span {
  border-color: var(--grape);
  color: var(--grape);
}

.fx-taste-card {
  animation: splash 2.3s var(--ease) forwards;
}

.fx-taste-inner {
  background: #fff;
  padding: 1rem 1.35rem 1.15rem;
  border-radius: 16px;
  border: 4px solid var(--seat, var(--coral));
  box-shadow: 0 14px 0 color-mix(in srgb, var(--seat, var(--coral)) 28%, transparent);
  text-align: center;
  min-width: min(18rem, 86vw);
  max-width: 22rem;
}

.fx-taste-win .fx-taste-inner {
  border-color: var(--mint);
  box-shadow: 0 14px 0 rgba(42, 122, 106, 0.25);
}

.fx-taste-lose .fx-taste-inner {
  border-color: #8b3a4a;
  box-shadow: 0 14px 0 rgba(139, 58, 74, 0.22);
}

.fx-taste-badge {
  display: inline-block;
  margin: 0 0 0.55rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.fx-taste-badge.ok {
  background: var(--mint);
  color: #fff;
}

.fx-taste-badge.ng {
  background: #8b3a4a;
  color: #fff;
}

.fx-taste-who {
  margin: 0.2rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--seat, var(--ink));
}

.fx-taste-detail {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.fx-taste-real,
.fx-taste-penalty,
.fx-taste-reward {
  margin: 0.55rem 0 0;
  font-weight: 800;
  font-size: 1rem;
}

.fx-taste-real {
  color: var(--mint);
  margin-bottom: 0.25rem;
}

.fx-taste-real-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin: 0 0 0.15rem;
}

.fx-taste-card-img {
  width: 36px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--line);
}

.fx-taste-penalty {
  color: #8b3a4a;
}

.fx-taste-reward {
  color: var(--accent);
}

.fx-cook-chef {
  margin: 0.2rem 0 0;
  font-weight: 700;
  color: var(--muted);
  font-size: 0.9rem;
}

.fx-cook {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 246, 232, 0.55);
  animation: fade-out 2.2s ease forwards;
  pointer-events: none;
}

.fx-cook--t1 {
  animation-duration: 1.4s;
  background: rgba(255, 246, 232, 0.35);
}

.fx-cook--t1 .fx-cook-inner {
  padding: 0.85rem 1.1rem;
  border-width: 2px;
  box-shadow: 0 8px 0 rgba(255, 230, 109, 0.25);
}

.fx-cook--t1 .fx-cook-title {
  font-size: 1.05rem;
}

.fx-cook--t1 .fx-cook-points {
  font-size: 2rem;
}

.fx-cook--t3 .fx-cook-inner {
  padding: 1.6rem 2rem;
  transform: scale(1.06);
}

.fx-cook--t3 .fx-cook-points {
  font-size: 3.4rem;
}

.fx-cook--t4,
.fx-cook--win {
  background: rgba(255, 236, 210, 0.72);
  animation-duration: 2.6s;
}

.fx-cook--t4 .fx-cook-inner,
.fx-cook--win .fx-cook-inner {
  padding: 1.8rem 2.2rem;
  border-width: 5px;
  box-shadow:
    0 18px 0 rgba(255, 230, 109, 0.45),
    0 0 0 6px rgba(255, 200, 120, 0.25);
  animation: bounce-in 0.45s var(--ease) both;
}

.fx-cook--t4 .fx-cook-title,
.fx-cook--win .fx-cook-title {
  font-size: 1.65rem;
}

.fx-cook--t4 .fx-cook-points,
.fx-cook--win .fx-cook-points {
  font-size: 3.8rem;
}

.fx-cook--win .fx-cook-title {
  color: var(--teal);
}

.fx-cook-burst {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx-cook-burst i {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--lemon);
  opacity: 0.85;
  animation: cook-burst-fly 0.9s ease-out forwards;
  animation-delay: calc(var(--i) * 0.03s);
}

.fx-cook-burst i:nth-child(3n) {
  background: var(--mint);
}
.fx-cook-burst i:nth-child(3n + 1) {
  background: var(--coral);
}
.fx-cook-burst i:nth-child(3n + 2) {
  background: var(--sky);
}

@keyframes cook-burst-fly {
  0% {
    transform: translate(-50%, -50%) scale(0.4);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1);
    opacity: 0;
  }
}

.fx-cook-inner {
  position: relative;
  z-index: 1;
  background: #fff;
  padding: 1.4rem 1.75rem;
  border-radius: 24px;
  border: 4px solid var(--lemon);
  text-align: center;
  box-shadow: 0 16px 0 rgba(255, 230, 109, 0.4);
  animation: bounce-in 0.4s var(--ease) both;
}

.fx-cook-title {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--coral);
}

.fx-cook-names {
  margin: 0.4rem 0;
  font-weight: 600;
  color: var(--muted);
}

.fx-cook-points {
  margin: 0;
  font-size: 3rem;
  font-weight: 800;
  color: var(--mint);
  animation: pop-score 0.5s var(--ease) 0.15s both;
}

.fx-cook-points small {
  font-size: 0.45em;
}

@keyframes toast-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 12px);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  80% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
}

@keyframes splash {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  20% {
    opacity: 1;
    transform: scale(1.08);
  }
  70% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.1);
  }
}

@keyframes pop-score {
  from {
    transform: scale(0.5);
  }
  to {
    transform: scale(1);
  }
}

@keyframes fade-out {
  0%,
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.fx-confetti {
  position: absolute;
  inset: 0;
}

.fx-confetti i {
  position: absolute;
  top: -10px;
  left: var(--x);
  width: 10px;
  height: 14px;
  background: var(--coral);
  border-radius: 2px;
  animation: fall var(--d) linear forwards;
}

.fx-confetti i:nth-child(3n) {
  background: var(--mint);
}
.fx-confetti i:nth-child(3n + 1) {
  background: var(--lemon);
}
.fx-confetti i:nth-child(3n + 2) {
  background: var(--sky);
}

@keyframes fall {
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0.8;
  }
}

.cook-reveal {
  margin: 0.35rem auto 0;
  max-width: min(36rem, 100%);
  padding: 0.65rem 0.75rem 0.75rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: center;
  animation: rise-in 0.35s var(--ease) both;
  color: var(--ink);
}

.field-mat .cook-reveal {
  background: rgba(255, 252, 247, 0.97);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.cook-reveal-label {
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 600;
}

.cook-reveal-chef {
  margin: 0.15rem 0 0.45rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  position: relative;
  z-index: 3;
}

/* Fan rules live in the shared block above; keep field spacing only */
.field-mat .cook-reveal-cards {
  margin-bottom: 0.2rem;
}

.cook-reveal-points {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.2rem 0;
}

.cook-reveal-win {
  color: var(--teal);
  font-weight: 700;
  margin: 0.15rem 0;
}

.cook-reveal .hint {
  margin: 0.2rem 0;
  font-size: 0.78rem;
}

.cook-reveal .btn.big {
  margin-top: 0.25rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.92rem;
}

.helper-modal {
  width: min(640px, 100%);
}

.panel-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.85rem 0.55rem;
  border-bottom: 1px solid var(--line);
}

.panel-tab {
  appearance: none;
  border: 1px solid var(--line);
  background: #f7f3ee;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.4rem 0.7rem;
  border-radius: 6px;
  cursor: pointer;
  line-height: 1.2;
}

.panel-tab:hover {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.panel-tab.active {
  background: #fff;
  color: var(--accent-deep);
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  box-shadow: 0 1px 0 rgba(31, 28, 26, 0.06);
}

.helper-body {
  padding: 0.75rem 1.1rem 1.25rem;
}

.helper-body section {
  margin-bottom: 0;
}

.helper-body h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--accent);
}

.helper-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.helper-list li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.helper-list .tag {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  background: #f0ebe4;
  border-radius: 4px;
  margin-right: 0.35rem;
}

.helper-list em {
  color: var(--teal);
  font-style: normal;
  font-weight: 600;
}

@media (max-width: 640px) {
  :root {
    --card-w: 78px;
    --card-h: 108px;
    --radius: 8px;
  }

  body {
    padding: 0.25rem 0.35rem 0.35rem;
  }

  body.in-lobby {
    padding:
      max(0.35rem, env(safe-area-inset-top))
      max(0.45rem, env(safe-area-inset-right))
      max(0.45rem, env(safe-area-inset-bottom))
      max(0.45rem, env(safe-area-inset-left));
    overflow: hidden;
    justify-content: center;
  }

  body.in-lobby #lobby,
  body.in-lobby .lobby-stage {
    max-width: none;
    flex: 0 1 auto;
    width: 100%;
    height: auto;
    max-height: 100%;
    min-height: 0;
    align-self: stretch;
  }

  .lobby-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    gap: 0.55rem;
    align-content: start;
  }

  .lobby-visual {
    padding: 0.35rem 0.25rem 0.15rem;
    border-radius: 0;
    background: transparent;
    justify-content: center;
    flex: 0 0 auto;
    overflow: visible;
    animation: lobby-visual-in 0.55s var(--ease) both;
  }

  .lobby-panel {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 0;
    height: auto;
    max-height: 100%;
    overflow: hidden;
    animation: lobby-panel-in 0.55s var(--ease) 0.05s both;
  }

  .lobby-card {
    flex: 0 1 auto;
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 100%;
    min-height: 0;
    padding: 0.95rem 0.85rem 1.05rem;
    margin: 0;
    box-shadow: 0 8px 0 rgba(196, 75, 47, 0.1), 0 12px 28px rgba(43, 42, 50, 0.06);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
  }

  .lobby-card-fan {
    display: none;
  }

  .hero {
    margin: 0 auto;
  }

  .title-logo {
    width: min(100%, 17.5rem);
  }

  .hero-sub {
    font-size: clamp(0.74rem, 3.5vw, 0.84rem);
    padding: 0 0.85rem;
    margin-top: 0.35rem;
    font-family: var(--font);
    line-height: 1.5;
    letter-spacing: 0.01em;
    max-width: 22.5rem;
    margin-left: auto;
    margin-right: auto;
    word-break: keep-all;
    line-break: strict;
  }

  .hero-sub-br {
    display: inline;
  }

  .lobby-card label,
  .lobby-card legend {
    margin: 0.45rem 0 0.25rem;
    font-size: 0.8rem;
  }

  .lobby-card > label[for="name-input"] {
    margin-top: 0;
  }

  .lobby-card input[type="text"],
  .lobby-card input[type="number"],
  .lobby-card select {
    padding: 0.9rem 0.95rem;
    font-size: 1.02rem;
    border-radius: 12px;
    min-height: 3.15rem;
    box-sizing: border-box;
  }

  .lobby-settings {
    margin-top: 0.7rem;
    gap: 0.55rem;
    flex: 0 0 auto;
  }

  .lobby-details summary {
    padding: 0.85rem 0.85rem;
    font-size: 0.95rem;
    min-height: 3.1rem;
    box-sizing: border-box;
  }

  .lobby-details .details-summary-val {
    font-size: 0.86rem;
  }

  .lobby-settings-grid {
    gap: 0.45rem;
    padding: 0.65rem 0.7rem 0.75rem;
  }

  .lobby-setting-cell {
    grid-template-columns: minmax(5rem, 6.5rem) minmax(0, 1fr);
    gap: 0.55rem;
  }

  .lobby-setting-cell input,
  .lobby-setting-cell select {
    max-width: 8.5rem;
    min-height: 2.85rem;
    padding: 0.6rem 0.65rem;
    font-size: 1rem;
  }

  .btn-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.85rem;
    flex: 0 0 auto;
  }

  .btn-row #btn-host {
    flex: 0 0 auto;
    height: 3.65rem;
    min-height: 3.65rem;
    padding: 0.9rem 1rem;
    font-size: 1.08rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 12px;
    box-shadow: 0 3px 0 color-mix(in srgb, var(--accent-deep) 55%, transparent);
  }

  /* Compact, even gaps — do not stretch to fill tall viewports */
  .btn-row-rest {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.65rem;
  }

  .btn-row-rest > * {
    flex: 0 0 auto;
  }

  .btn-row .join-row {
    gap: 0.55rem;
    align-items: stretch;
  }

  .btn-row .join-row input,
  .btn-row .join-row .btn,
  .btn-row #btn-solo {
    height: 3.25rem;
    min-height: 3.25rem;
    padding: 0.7rem 0.9rem;
    font-size: 1.02rem;
    font-weight: 700;
    border-radius: 12px;
    box-sizing: border-box;
  }

  .btn-row .join-row input {
    font-weight: 500;
  }

  .btn-row #btn-solo {
    letter-spacing: 0.01em;
  }

  .lobby-guide-row {
    gap: 0.55rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .lobby-guide-row .btn {
    height: 3rem;
    min-height: 3rem;
    padding: 0.65rem 0.75rem;
    font-size: 0.98rem;
    font-weight: 700;
    border-radius: 12px;
    box-sizing: border-box;
  }

  body.in-game {
    display: block;
    padding: 0.2rem 0.25rem max(0.5rem, env(safe-area-inset-bottom));
    overflow: auto;
    height: auto;
    min-height: 100dvh;
    min-height: 100svh;
  }

  body.in-game.match-playing {
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
    padding: 0.2rem 0.25rem max(0.2rem, env(safe-area-inset-bottom));
  }

  body.in-game.match-waiting,
  body.in-game.match-finished {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
    min-height: 100svh;
    padding: 0.35rem 0.35rem max(0.35rem, env(safe-area-inset-bottom));
  }

  body.in-game #table {
    display: block;
    overflow: visible;
    min-height: 0;
  }

  body.in-game.match-playing #table {
    height: 100%;
    overflow: hidden;
  }

  body.in-game.match-waiting #table,
  body.in-game.match-finished #table {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    flex: 1 1 auto;
    width: 100%;
    overflow: visible;
  }

  .table-playing,
  .table-playing.play-stage {
    max-width: 100%;
    height: calc(100dvh - 0.5rem);
    max-height: calc(100dvh - 0.5rem);
    min-height: 0;
    overflow: hidden;
    gap: 0.3rem;
  }

  body.match-playing {
    overflow: hidden;
    height: 100dvh;
    padding: 0.2rem 0.25rem max(0.2rem, env(safe-area-inset-bottom));
  }

  body.match-playing .table-playing {
    overflow: hidden;
  }

  body.match-playing .turn-tools--mobile {
    display: flex;
    flex-wrap: nowrap;
    width: 100%;
    flex-basis: auto;
    margin-left: 0;
    margin-top: 0.15rem;
    gap: 0.25rem;
  }

  body.match-playing .turn-tools--mobile .btn-tool {
    flex: 1 1 calc(25% - 0.25rem);
    min-width: 0;
    width: auto;
    min-height: 1.85rem;
    padding: 0.2rem 0.3rem !important;
    font-size: 0.68rem !important;
  }

  body.match-playing .field-rail--tools {
    display: none;
  }

  /* Left = field info, right = deck/discard (PC-like, tools stay in banner) */
  body.match-playing .field-mat.center-zone {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    padding: 0.35rem 0.4rem;
    gap: 0.35rem;
  }

  body.match-playing .field-rail--piles {
    width: 3.3rem;
    order: unset;
    flex-direction: column;
    justify-content: center;
    align-items: center;
  }

  body.match-playing .piles--rail {
    flex-direction: column;
    gap: 0.4rem;
  }

  body.match-playing .field-mat-meta {
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: auto;
  }

  /* Reveal: field fills leftover height; dock stays fixed; fan cards unchanged */
  body.match-playing .field-mat.center-zone:has(.field-mat-meta.is-reveal) {
    grid-template-columns: minmax(0, 1fr);
    padding: 0.25rem;
    flex: 1 1 0;
    max-height: none;
    min-height: 0;
  }

  body.match-playing .field-mat.center-zone:has(.field-mat-meta.is-reveal) .field-rail--piles {
    display: none;
  }

  body.match-playing .field-mat-meta.is-reveal {
    justify-content: flex-start;
    align-items: stretch;
    overflow: hidden;
    padding: 0;
    height: 100%;
    max-height: 100%;
  }

  body.match-playing .field-mat-meta.is-reveal .cook-reveal {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 0.15rem;
    overflow: auto;
    box-sizing: border-box;
    padding: 0.35rem 0.4rem 0.45rem;
  }

  body.match-playing .field-mat-meta.is-reveal .cook-reveal.is-win {
    gap: 0.1rem;
    padding: 0.3rem 0.35rem 0.4rem;
  }

  body.match-playing .hand-dock {
    max-height: none;
    flex: 0 0 auto;
    position: relative;
    z-index: 2;
    overflow: visible;
  }

  body.match-playing .hand-stage.hand-zone {
    overflow: hidden;
  }

  body.match-playing .card-row.hand {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
  }

  body.match-playing .turn-banner {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
  }

  body.match-playing .turn-banner-main {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  body.match-playing .turn-banner-main::-webkit-scrollbar {
    display: none;
  }

  body.match-playing .turn-banner-main > * {
    flex-shrink: 0;
  }

  body.match-playing .turn-banner-main strong {
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.match-playing .btn-tool {
    min-height: 1.85rem;
    font-size: 0.68rem !important;
  }

  body.match-playing .room-chip--inline,
  body.match-playing .mode-badge--inline {
    font-size: 0.6rem;
    padding: 0.08rem 0.32rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  body.match-playing .turn-phase,
  body.match-playing .turn-you {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .turn-banner {
    padding: 0.35rem 0.5rem;
    gap: 0.25rem 0.45rem;
    flex-shrink: 0;
  }

  .turn-banner strong {
    font-size: 0.92rem;
  }

  .turn-phase {
    font-size: 0.68rem;
    padding: 0.12rem 0.4rem;
  }

  .turn-you,
  .hot-tag {
    font-size: 0.72rem;
  }

  .seat-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.25rem;
    padding-bottom: 0.1rem;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .seat-row::-webkit-scrollbar {
    display: none;
  }

  .seat-chip {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    padding: 0.22rem 0.3rem 0.22rem 0.35rem;
    border-radius: 8px;
    column-gap: 0.25rem;
  }

  .seat-chip-name {
    font-size: 0.62rem;
  }

  .seat-chip-name small {
    display: none; /* keep one-line chips readable for 4 players */
  }

  .seat-chip-score strong {
    font-size: 0.92rem;
  }

  .seat-chip-hand {
    font-size: 0.5rem;
    font-weight: 600;
    opacity: 0.85;
  }

  .goal-chip {
    flex: 0 0 auto;
    max-width: none;
    padding: 0.22rem 0.4rem;
    font-size: 0.62rem;
  }

  .goal-chip strong {
    font-size: 0.78rem;
  }

  .scores {
    gap: 0.35rem;
    flex-shrink: 0;
    padding: 0.35rem 0.45rem;
  }

  .scoreboard {
    gap: 0.3rem;
    flex: 1 1 auto;
  }

  .score-pill {
    padding: 0.18rem 0.42rem;
    font-size: 0.72rem;
    gap: 0.3rem;
  }

  .score-pill strong {
    font-size: 1rem;
  }

  .goal {
    font-size: 0.68rem;
    white-space: nowrap;
  }

  .opponent-zone {
    flex-shrink: 0;
  }

  .opponents-row {
    gap: 0.35rem;
  }

  .opp-block {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.28rem 0.4rem;
    border-radius: 8px;
    border-width: 1px;
  }

  .opp-block h3 {
    font-size: 0.72rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.match-playing .opp-block .card-row.backs {
    display: none;
  }

  .center-zone,
  .field-mat.center-zone {
    padding: 0.35rem 0.4rem;
    margin: 0;
    flex-shrink: 1;
    border-radius: 10px;
  }

  .field-mat-meta {
    min-height: 0;
  }

  .piles {
    gap: 1rem;
    margin-bottom: 0;
  }

  .pile-stack {
    width: 1.55rem;
    height: 2.05rem;
  }

  .pile {
    font-size: 0.58rem;
  }

  .pile strong {
    font-size: 0.88rem;
  }

  body.match-playing .field-rail--piles .pile-label {
    font-size: 0.52rem;
    text-align: center;
    margin-top: 0.1rem;
  }

  body.match-playing .field-rail--piles .pile strong {
    font-size: 0.85rem;
    line-height: 1.1;
  }

  body.match-playing .field-status {
    padding: 0.2rem 0.35rem;
    max-width: 100%;
    gap: 0.2rem;
  }

  body.match-playing .field-status-phase {
    font-size: 1rem;
  }

  body.match-playing .field-status-event {
    font-size: 0.82rem;
  }

  body.match-playing .field-status-msg,
  body.match-playing .field-status-limits {
    font-size: 0.72rem;
  }

  body.match-playing .field-mat-meta .cook-preview {
    width: 100%;
    margin-top: 0.2rem;
    padding: 0.35rem 0.45rem;
  }

  .pending.pop {
    font-size: 0.75rem;
    padding: 0.35rem 0.45rem;
    margin-top: 0.25rem;
  }

  .taste-actions {
    margin-top: 0.3rem;
    gap: 0.35rem;
  }

  .taste-actions .btn {
    padding: 0.45rem 0.65rem;
    font-size: 0.82rem;
  }

  .big-hint {
    font-size: 0.85rem;
    margin: 0.25rem 0;
  }

  .hand-zone,
  .hand-stage.hand-zone {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 28dvh;
    overflow: hidden;
    padding: 0.3rem 0.3rem 0.2rem;
    margin: 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(28, 25, 23, 0.04);
  }

  .hand-zone-head {
    margin-bottom: 0.15rem;
  }

  .hand-zone-head h3 {
    font-size: 0.88rem;
  }

  .hand-hint {
    font-size: 0.65rem;
    text-align: right;
    max-width: 55%;
    line-height: 1.2;
  }

  .card-row {
    gap: 0.3rem;
  }

  .card-row.hand {
    gap: 0.25rem;
    padding: 0.85rem 0.1rem 0.25rem; /* room for selected lift */
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
    min-height: calc(var(--card-h) + 1.1rem);
    height: calc(var(--card-h) + 1.1rem);
  }

  .card-wrap:hover {
    transform: none;
  }

  body.match-playing .card-wrap.selected {
    transform: translateY(-8px) scale(1.03);
  }

  body.match-playing .card {
    border-width: 2px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(43, 42, 50, 0.1);
  }

  body.match-playing .card-name {
    display: block;
    font-size: 0.62rem;
    padding: 0.2rem 0.15rem;
    line-height: 1.15;
  }

  body.match-playing .card img {
    height: calc(var(--card-h) - 1.35rem);
  }

  body.match-playing .card-info {
    width: 1.35rem;
    height: 1.35rem;
    top: 3px;
    right: 3px;
    font-size: 0.72rem;
    border-width: 1px;
  }

  .card.back {
    height: calc(var(--card-h) * 0.45);
    width: calc(var(--card-w) * 0.45);
    border-width: 2px;
  }

  .cook-preview {
    margin-top: 0.45rem;
    padding: 0.45rem 0.55rem;
    border-radius: 8px;
    border-width: 1px;
  }

  .cook-preview-total .total {
    font-size: 1.45rem;
  }

  .cook-preview-lines {
    display: grid;
    grid-template-columns: 1fr 1fr;
    font-size: 0.72rem;
    gap: 0.1rem 0.35rem;
  }

  .cook-preview-lines li {
    border-bottom: none;
    padding: 0.05rem 0;
  }

  .cook-preview-note,
  .cook-preview-status {
    font-size: 0.72rem;
  }

  .actions,
  .play-dock.actions {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin: 0;
    position: relative;
    bottom: auto;
    z-index: 25;
    background: linear-gradient(180deg, rgba(246, 240, 230, 0.2), #f6f0e6 32%);
    border-top: 1px solid var(--line);
    padding: 0.25rem 0.15rem;
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
    box-shadow: 0 -8px 18px rgba(80, 40, 20, 0.06);
    border-radius: 12px 12px 0 0;
    box-sizing: border-box;
    height: calc(3.55rem + env(safe-area-inset-bottom, 0px));
    min-height: calc(3.55rem + env(safe-area-inset-bottom, 0px));
    max-height: calc(3.55rem + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
  }

  .actions .action-dock {
    min-height: 0;
    height: 100%;
  }

  .actions .hint:not(.action-dock-note):not(.action-dock-status),
  .actions .decl-label,
  .actions .big-hint {
    display: none;
  }

  .actions .action-dock-status {
    display: block;
  }

  .action-dock-note {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }

  .decl-btns {
    gap: 0.3rem;
  }

  .decl-btns .btn {
    min-height: 2.75rem;
    padding: 0.4rem 0.2rem;
    font-size: 0.78rem;
  }

  .action-block .btn,
  .action-row .btn {
    padding: 0.45rem 0.5rem;
    font-size: 0.82rem;
    min-height: 2.75rem;
  }

  .btn.big {
    padding: 0.45rem 0.65rem;
    font-size: 0.85rem;
  }

  body.match-playing .log {
    display: none;
  }

  .panel.waiting,
  .panel.finished {
    margin: 0 auto;
    padding: 1.25rem 0.85rem;
    box-shadow: 0 8px 0 rgba(196, 75, 47, 0.1), 0 12px 28px rgba(43, 42, 50, 0.06);
  }

  .panel.wait-panel {
    padding: 1.15rem 0.85rem 1.15rem;
  }

  .wait-actions {
    width: min(100%, 100%);
    max-width: none;
    margin-top: 1rem;
    gap: 0.5rem;
  }

  .wait-start.btn {
    min-height: 3.25rem;
    height: 3.25rem;
    font-size: 1.05rem;
  }

  .wait-guides .btn,
  .wait-home {
    min-height: 2.85rem;
    height: 2.85rem;
  }

  .wait-home {
    margin-top: 0.75rem;
  }

  .panel.result-panel {
    max-height: calc(100dvh - 1rem);
    overflow-y: auto;
    margin: 0 auto;
    padding: 1.15rem 0.85rem 1.15rem;
  }

  .panel.finished h2 {
    font-size: 1.45rem;
  }

  .result-sub {
    margin: 0.25rem 0 0.65rem;
    font-size: 0.88rem;
  }

  .result-actions {
    gap: 0.55rem;
    margin-top: 1rem;
  }

  .result-actions .btn {
    min-height: 3.15rem;
    height: 3.15rem;
    padding: 0.7rem 0.75rem;
    font-size: 0.98rem;
  }

  .cook-history {
    margin-top: 1rem;
    padding: 0.7rem 0.75rem;
  }

  .cook-reveal {
    padding: 0.35rem 0.4rem 0.45rem;
    margin-top: 0;
    max-height: 100%;
    overflow: auto;
    width: 100%;
  }

  .cook-reveal-label {
    font-size: 0.58rem;
    flex: 0 0 auto;
    margin: 0;
    position: relative;
    z-index: 3;
  }

  .cook-reveal-chef {
    font-size: 0.9rem;
    margin: 0 0 0.4rem;
    flex: 0 0 auto;
    position: relative;
    z-index: 3;
    line-height: 1.25;
    background: linear-gradient(180deg, #fff 55%, rgba(255, 255, 255, 0.85));
    padding: 0 0.25rem 0.15rem;
  }

  /* Mobile fan sizing — keep shared transform vars so focus-spread still works */
  .cook-reveal-cards {
    --fan-step: 2.85rem;
    --fan-ang: 4deg;
    --fan-push: 1.5rem;
    width: min(100%, 24.5rem);
    height: 8.1rem;
    margin: 0 auto 0.15rem;
  }

  .cook-reveal-card {
    width: min(5.6rem, 30vw);
    max-width: 5.8rem;
    min-width: 4rem;
  }

  .cook-reveal.is-win .cook-reveal-chef {
    margin-bottom: 0.55rem;
  }

  .cook-reveal.is-win .cook-reveal-cards {
    --fan-step: 2.7rem;
    --fan-ang: 3.5deg;
    height: 7.6rem;
    width: min(100%, 23.5rem);
  }

  .cook-reveal.is-win .cook-reveal-card {
    width: min(5.3rem, 28vw);
    max-width: 5.5rem;
    min-width: 3.8rem;
  }

  .cook-reveal-points {
    font-size: 1.08rem;
    margin: 0.1rem 0 0;
    flex: 0 0 auto;
  }

  .cook-reveal-win {
    margin: 0.08rem 0;
    font-size: 0.84rem;
    flex: 0 0 auto;
  }

  .field-mat .cook-reveal .hint {
    font-size: 0.68rem;
    margin: 0.02rem 0;
    flex: 0 0 auto;
  }

  .cook-reveal-action {
    flex: 0 0 auto;
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 0.2rem;
  }

  .cook-reveal-acked {
    margin: 0;
    text-align: center;
  }

  .field-mat .cook-reveal .btn.big {
    padding: 0.4rem 0.7rem;
    font-size: 0.82rem;
    min-height: 2.3rem;
    width: min(100%, 15rem);
    margin: 0;
    flex: 0 0 auto;
  }

  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-art {
    max-width: 160px;
    margin: 0 auto;
  }

  .modal {
    max-height: 92dvh;
    margin: 0.35rem;
  }

  .btn,
  .card,
  .card-info {
    touch-action: manipulation;
  }
}

@media (max-width: 640px) and (max-height: 700px) {
  :root {
    --card-w: 68px;
    --card-h: 94px;
  }

  .turn-banner {
    margin-bottom: 0;
  }

  .seat-row {
    margin: 0;
  }

  .field-mat.center-zone,
  .center-zone {
    padding: 0.25rem 0.3rem;
  }

  .hand-zone-head h3 {
    font-size: 0.78rem;
  }

  .hand-hint {
    display: none;
  }

  .cook-preview-lines {
    grid-template-columns: 1fr 1fr;
    font-size: 0.68rem;
  }

  .cook-reveal-cards {
    --fan-step: 2.5rem;
    --fan-ang: 3.5deg;
    --fan-push: 1.35rem;
    height: 7.2rem;
    width: min(100%, 22rem);
  }

  .cook-reveal-card {
    width: min(5rem, 28vw);
    max-width: 5.2rem;
    min-width: 3.6rem;
  }

  .cook-reveal.is-win .cook-reveal-cards {
    --fan-step: 2.35rem;
    --fan-ang: 3deg;
    height: 6.8rem;
    width: min(100%, 21rem);
  }

  .cook-reveal.is-win .cook-reveal-chef {
    margin-bottom: 0.45rem;
  }

  .cook-reveal-chef {
    font-size: 0.84rem;
  }

  .field-status-phase {
    font-size: 0.92rem;
  }
}

/* —— PC wide play stage —— */
@media (min-width: 641px) {
  .panel.result-panel {
    max-width: min(38rem, 92vw);
    max-height: calc(100dvh - 2.5rem);
    padding: 1.65rem 1.5rem 1.45rem;
    margin: 0 auto;
  }

  .panel.finished h2 {
    font-size: 1.75rem;
  }

  .result-actions {
    gap: 0.65rem;
    margin-top: 1.35rem;
    max-width: 28rem;
    margin-inline: auto;
  }

  .result-actions .btn {
    min-height: 3.15rem;
    height: 3.15rem;
    font-size: 1rem;
  }

  .table-playing.play-stage {
    max-width: min(1280px, 100%);
    gap: 0.4rem;
    height: calc(100dvh - 0.7rem);
    max-height: calc(100dvh - 0.7rem);
  }

  .turn-tools--mobile {
    display: none !important;
  }

  .play-stage .seat-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: stretch;
    gap: 0.4rem;
  }

  .play-stage .seat-chip {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
    padding: 0.4rem 0.65rem 0.4rem 0.7rem;
  }

  .play-stage .seat-chip-name {
    font-size: 0.82rem;
  }

  .play-stage .seat-chip-score strong {
    font-size: 1.35rem;
  }

  .play-stage .field-mat.center-zone {
    min-height: 0;
    padding: 0.55rem 0.75rem;
    flex: 1 1 0;
  }

  .play-stage .field-mat-meta {
    min-height: 0;
    height: 100%;
  }

  .play-stage .pile-stack {
    width: 2.55rem;
    height: 3.4rem;
  }

  .play-stage .hand-dock {
    max-height: 38%;
  }

  .play-stage .hand-stage.hand-zone {
    padding: 0.45rem 0.75rem 0.35rem;
    overflow: hidden;
  }

  .play-stage .hand-zone-head h3 {
    font-size: 1.05rem;
  }

  .play-stage .card-row.hand {
    gap: 0.4rem;
    padding: 1.1rem 0.15rem 0.45rem; /* keep selected card top visible */
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    justify-content: flex-start;
  }

  .play-stage .play-dock.actions {
    height: 3.55rem;
    min-height: 3.55rem;
    max-height: 3.55rem;
  }

  .play-stage .play-dock .action-row,
  .play-stage .play-dock .decl-btns {
    justify-content: center;
    max-width: 42rem;
    margin-inline: auto;
  }

  .play-stage .cook-preview {
    margin-top: 0.35rem;
    padding: 0.4rem 0.65rem;
  }

  /* PC: slightly larger fan */
  .cook-reveal-cards {
    --fan-step: 3.15rem;
    --fan-ang: 4deg;
    --fan-push: 1.7rem;
    width: min(100%, 28rem);
    height: 10rem;
  }

  .cook-reveal-card {
    width: min(6.2rem, 11vw);
    max-width: 6.6rem;
    min-width: 4.8rem;
  }

  .cook-reveal.is-win .cook-reveal-cards {
    --fan-step: 3rem;
    --fan-ang: 3.5deg;
    width: min(100%, 27rem);
    height: 9.4rem;
  }

  /* Keep fan cards; let the field absorb leftover height (no hollow gap under hand) */
  body.match-playing .field-mat.center-zone:has(.field-mat-meta.is-reveal) {
    flex: 1 1 0;
    max-height: none;
    min-height: 0;
  }

  body.match-playing .field-mat-meta.is-reveal {
    justify-content: center;
    align-items: center;
    overflow: auto;
  }

  body.match-playing .field-mat-meta.is-reveal .cook-reveal {
    height: auto;
    max-height: 100%;
    width: min(100%, 36rem);
    overflow: auto;
    justify-content: center;
  }
}

@media (min-width: 900px) {
  :root {
    --card-w: 100px;
    --card-h: 140px;
  }

  body.match-playing {
    padding-inline: clamp(0.75rem, 2.5vw, 1.75rem);
  }

  .field-rail--tools,
  .field-rail--piles {
    width: 6.25rem;
  }

  .play-stage .hand-stage.hand-zone {
    padding: 0.55rem 0.9rem 0.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pile-deck,
  .taste-btn,
  .card-wrap,
  .card-wrap.selected,
  .pending.pop {
    animation: none !important;
    transition: none !important;
  }
}
