:root {
  --felt: #10372e;
  --felt-deep: #061411;
  --ink: #101815;
  --surface: #fbf5e8;
  --surface-raised: #fffdf6;
  --surface-muted: #e9deca;
  --line: rgba(31, 38, 34, 0.13);
  --line-strong: rgba(31, 38, 34, 0.28);
  --text: #17211d;
  --muted: #68766e;
  --ruby: #c33a55;
  --ruby-deep: #7f2236;
  --ruby-soft: #f9dfe5;
  --cobalt: #2f62d4;
  --cobalt-deep: #1d3f94;
  --cobalt-soft: #dfe9ff;
  --gold: #c99a3c;
  --gold-soft: #f3dfae;
  --green: #247a51;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(2, 8, 6, 0.32);
  --shadow-soft: 0 12px 28px rgba(18, 27, 23, 0.13);
}

[data-theme="dark"] {
  --felt: #061914;
  --felt-deep: #020b08;
  --ink: #e6edeb;
  --surface: #132721;
  --surface-raised: #1a3129;
  --surface-muted: #0d1f1a;
  --line: rgba(230, 237, 235, 0.12);
  --line-strong: rgba(230, 237, 235, 0.24);
  --text: #e6edeb;
  --muted: #94a69e;
  --ruby: #e8546b;
  --ruby-deep: #f7a2b0;
  --ruby-soft: rgba(232, 84, 107, 0.22);
  --cobalt: #6b8ff0;
  --cobalt-deep: #aec0f6;
  --cobalt-soft: rgba(107, 143, 240, 0.22);
  --gold: #e2b04f;
  --gold-soft: rgba(226, 176, 79, 0.25);
  --green: #4dbd85;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.62);
  --shadow-soft: 0 12px 28px rgba(0, 0, 0, 0.48);
}

* {
  box-sizing: border-box;
}

/* Prevent iOS double-tap-to-zoom on interactive game surfaces so rapid card/chip tapping feels responsive.
   Other gestures (pinch-to-zoom on text, scroll) still work on the rest of the page. */
button,
.card-button,
.pile-button,
.icon-button,
#game-canvas,
#help-close-btn,
.offline-retry,
.offline-offline-fallback,
.update-reload,
.primary-button,
#discard-dead-btn,
#cancel-selection-btn,
#rematch-btn,
#copy-room-btn,
#copy-spectator-link-btn,
#share-room-btn,
#start-test-btn {
  touch-action: manipulation;
  /* Prevent iOS from flashing the blue text-selection highlight on repeated taps. */
  -webkit-tap-highlight-color: transparent;
}

button,
.card-button,
.pile-button,
.icon-button,
#game-canvas,
.board-panel,
.seat-grid {
  -webkit-user-select: none;
  user-select: none;
  /* Suppress iOS long-press callout (copy/share/save image) on game surfaces. */
  -webkit-touch-callout: none;
}

body,
.panel,
.app-topbar,
.stack-card,
.share-status-card,
.invite-card,
.help-dialog,
.card-button,
.score-row,
.pile-button,
.history-item,
.spectator-item {
  transition:
    background-color 240ms ease-out,
    color 240ms ease-out,
    border-color 240ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  body,
  .panel,
  .app-topbar,
  .stack-card,
  .share-status-card,
  .invite-card,
  .help-dialog,
  .card-button,
  .score-row,
  .pile-button,
  .history-item,
  .spectator-item {
    transition: none;
  }
  /* Catch-all: no infinite or decorative keyframe animations for sensitive viewers. */
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

.copy-flash {
  position: relative;
  animation: copyFlashPulse 1.1s cubic-bezier(0.22, 0.7, 0.26, 1);
}

.copy-flash::after {
  content: "복사됨 ✓";
  position: absolute;
  top: -14px;
  right: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2e7f5a, #16593c);
  color: #fff8e9;
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  box-shadow: 0 8px 16px rgba(12, 45, 28, 0.32);
  animation: copyFlashBadge 1.1s cubic-bezier(0.22, 0.7, 0.26, 1);
  pointer-events: none;
}

@keyframes copyFlashPulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 127, 90, 0.48); }
  45% { box-shadow: 0 0 0 10px rgba(46, 127, 90, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 127, 90, 0); }
}

@keyframes copyFlashBadge {
  0% { opacity: 0; transform: translateY(4px) scale(0.86); }
  22% { opacity: 1; transform: translateY(0) scale(1.04); }
  60% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-6px) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .copy-flash,
  .copy-flash::after {
    animation: none;
  }
}

.input-hint {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--muted);
}

/* Inline validation — when JS sets aria-invalid="true" on an input, the hint flips to a
   warning palette so the user's eye stays on the field instead of jumping up to the flash
   message at the top of the page. The .input-hint partner element listens for the parent
   :has selector so we don't have to wire a per-input class. Falls back gracefully on UAs
   without :has (Firefox <121, older Safari): the input keeps its red border and the user
   still sees the hint, just not in error colour. */
input[aria-invalid="true"] {
  border-color: var(--danger, #c84a4a);
  box-shadow: 0 0 0 1px rgba(200, 74, 74, 0.4);
}

label:has(input[aria-invalid="true"]) .input-hint {
  color: var(--danger, #c84a4a);
  font-weight: 700;
}

#join-code {
  font-family: "JetBrains Mono", "Menlo", monospace;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.join-code-control {
  display: grid;
  gap: 7px;
}

.join-code-paste-btn {
  width: fit-content;
  min-height: 34px;
  padding-top: 8px;
  padding-bottom: 8px;
  justify-self: start;
}

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

.noscript-notice {
  max-width: 640px;
  margin: 48px auto;
  padding: 28px 32px;
  border-radius: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), transparent 60%),
    linear-gradient(180deg, #fffdf8, #eadcc3);
  color: #17211d;
  border: 1px solid rgba(50, 34, 14, 0.22);
  box-shadow: 0 22px 48px rgba(4, 14, 11, 0.24);
  font-family: Inter, "Trebuchet MS", "Gill Sans", Arial, sans-serif;
  line-height: 1.6;
}

.noscript-notice h1 {
  margin: 0 0 12px;
  font-size: 1.4rem;
}

.noscript-notice p {
  margin: 8px 0;
}

.noscript-notice a {
  color: #2c6b4a;
  font-weight: 800;
}

@media (prefers-color-scheme: dark) {
  .noscript-notice {
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.04), transparent 60%),
      linear-gradient(180deg, #1a2d26, #0c1713);
    color: #e6edeb;
    border-color: rgba(230, 237, 235, 0.16);
    box-shadow: 0 22px 48px rgba(0, 0, 0, 0.5);
  }
  .noscript-notice a {
    color: #6ec699;
  }
}

@media (forced-colors: active) {
  button,
  .card-button,
  .pile-button,
  .icon-button,
  .seat-card {
    border: 1px solid ButtonBorder;
  }
  :focus-visible {
    outline: 2px solid Highlight !important;
    outline-offset: 2px;
  }
  .offline-banner,
  .update-banner,
  .flash-message {
    border: 1px solid CanvasText;
  }
}

.skip-link {
  position: fixed;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  z-index: 300;
  transform: translate(-50%, -120%);
  padding: 8px 14px;
  background: #10372e;
  color: #fff8e9;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(4, 14, 11, 0.3);
  transition: transform 160ms ease-out;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translate(-50%, 0);
  outline: 3px solid rgba(199, 152, 61, 0.8);
  outline-offset: 2px;
}

#game-canvas:focus-visible {
  outline: 3px solid rgba(199, 152, 61, 0.78);
  outline-offset: 4px;
}

.offline-banner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 180;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(126, 28, 54, 0.94);
  color: #fff8e9;
  font-size: 0.84rem;
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(70, 8, 24, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  animation: offlinePulse 2.4s ease-in-out infinite;
}

.offline-banner[data-reconnect-state="stalled"] {
  background: rgba(95, 60, 20, 0.95);
  animation: none;
}

.offline-banner[data-reconnect-state="offline"] {
  background: rgba(97, 82, 24, 0.95);
  animation: none;
}

.offline-banner[hidden] {
  display: none;
}

.offline-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #fff8e9;
  box-shadow: 0 0 0 4px rgba(255, 248, 233, 0.28);
  animation: offlineDotPulse 1.2s ease-in-out infinite;
}

.offline-banner[data-reconnect-state="stalled"] .offline-dot {
  background: #ffe3af;
  box-shadow: 0 0 0 4px rgba(255, 227, 175, 0.28);
  animation: none;
}

.offline-banner[data-reconnect-state="offline"] .offline-dot {
  background: #ffe9bf;
  box-shadow: 0 0 0 4px rgba(255, 233, 191, 0.3);
  animation: none;
}

.offline-text {
  white-space: nowrap;
}

.offline-retry {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #fff8e9;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition: background 140ms ease-out;
}

.offline-retry:hover,
.offline-retry:focus-visible {
  background: rgba(255, 255, 255, 0.22);
}

.offline-offline-fallback {
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.14);
  color: #fff8e9;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition: background 140ms ease-out;
}

.offline-offline-fallback:hover,
.offline-offline-fallback:focus-visible {
  background: rgba(255, 255, 255, 0.24);
}

@keyframes offlinePulse {
  0%, 100% {
    box-shadow: 0 16px 32px rgba(70, 8, 24, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  }
  50% {
    box-shadow: 0 18px 36px rgba(70, 8, 24, 0.54), inset 0 1px 0 rgba(255, 255, 255, 0.26);
  }
}

@keyframes offlineDotPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.92;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

/* Update banner mirrors offline-banner geometry but uses an informational teal palette
   instead of the warning crimson — a SW update is good news (we shipped a fix), so the
   visual treatment shouldn't read as an error. Sits at the same top safe-area position;
   the offline and update banners are mutually exclusive in practice (offline banner shows
   while disconnected, update banner only after a healthy session has been active long
   enough for a deploy to land), so we don't need to vertically stack them. */
.update-banner {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 180;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(20, 78, 96, 0.94);
  color: #f0faff;
  font-size: 0.84rem;
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(8, 36, 48, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.update-banner[hidden] {
  display: none;
}

.update-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #b8ecff;
  box-shadow: 0 0 0 4px rgba(184, 236, 255, 0.28);
}

.update-text {
  white-space: nowrap;
}

.update-reload {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.14);
  color: #f0faff;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition: background 140ms ease-out;
}

.update-reload:hover,
.update-reload:focus-visible {
  background: rgba(255, 255, 255, 0.22);
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.help-modal[hidden] {
  display: none;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 30%, rgba(16, 55, 46, 0.72), rgba(6, 20, 17, 0.88));
  backdrop-filter: blur(3px);
}

.help-dialog {
  position: relative;
  width: min(640px, 100%);
  max-height: min(86vh, 900px);
  overflow-y: auto;
  border-radius: 8px;
  padding: 20px 22px 22px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.94), transparent 60%),
    linear-gradient(180deg, #fffdf8, #eadcc3);
  border: 1px solid rgba(50, 34, 14, 0.24);
  box-shadow: 0 28px 64px rgba(4, 14, 11, 0.4);
  color: var(--ink);
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(50, 34, 14, 0.18);
}

.help-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.help-body {
  display: grid;
  gap: 16px;
  font-size: 0.92rem;
  line-height: 1.55;
}

.help-control-row {
  display: grid;
  gap: 8px;
  align-items: center;
  grid-template-columns: 1fr;
}

.help-control-row label {
  font-weight: 700;
  color: var(--ink);
}

.help-control-group {
  display: grid;
  gap: 10px;
  align-items: center;
  grid-template-columns: minmax(140px, 1fr) 56px;
}

.help-control-group .range-slider {
  width: 100%;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.26));
  border: 1px solid rgba(80, 54, 18, 0.16);
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, #ffefa8, #cf9b30);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.32);
}

.range-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(180deg, #ffefa8, #cf9b30);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.32);
}

#sound-volume-value,
#haptic-intensity-value {
  justify-self: end;
  min-width: 44px;
  text-align: right;
  font-family: "JetBrains Mono", "Menlo", monospace;
  font-size: 0.82rem;
  color: var(--muted);
}

.help-section h3 {
  margin: 0 0 6px;
  font-size: 0.86rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.help-section p,
.help-section li {
  margin: 0;
  color: var(--ink);
}

.help-section ol,
.help-section ul {
  padding-left: 20px;
  margin: 4px 0 0;
  display: grid;
  gap: 4px;
}

.help-grid {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
  display: grid;
  gap: 10px;
}

.help-grid li {
  display: grid;
  grid-template-columns: minmax(150px, auto) 1fr;
  gap: 10px;
  align-items: start;
}

.help-tag {
  display: inline-flex;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fff8e9;
}

.help-tag.wild {
  background: linear-gradient(135deg, #2f7d5a, #1f5a3f);
}

.help-tag.cut {
  background: linear-gradient(135deg, #b23050, #7e1b31);
}

.help-footer {
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid rgba(50, 34, 14, 0.16);
  font-size: 0.72rem;
  color: var(--muted);
  font-family: "JetBrains Mono", "Menlo", monospace;
  letter-spacing: 0.04em;
  text-align: right;
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid rgba(50, 34, 14, 0.3);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.72);
  font-family: "JetBrains Mono", "Menlo", monospace;
  font-size: 0.82em;
}

body.help-open {
  overflow: hidden;
}

html {
  min-width: 320px;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Block mobile browser pull-to-refresh from triggering mid-game while still allowing local scroll. */
  overscroll-behavior: contain;
  font-family: Inter, "Trebuchet MS", "Gill Sans", Arial, sans-serif;
  color: var(--text);
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 34px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 34px),
    linear-gradient(135deg, #08231f 0%, var(--felt) 40%, #13251f 68%, var(--felt-deep) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.018) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, rgba(255, 247, 226, 0.08), transparent 34%);
  opacity: 0.72;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 10px 14px;
  letter-spacing: 0;
  transition:
    transform 120ms ease,
    opacity 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(199, 152, 61, 0.62);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

a {
  color: inherit;
}

.app-shell {
  width: min(100%, 1760px);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  /* Respect notches and rounded corners on iOS/Android with viewport-fit=cover. */
  padding-top: max(14px, env(safe-area-inset-top));
  padding-right: max(14px, env(safe-area-inset-right));
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  padding-left: max(14px, env(safe-area-inset-left));
  position: relative;
}

.app-topbar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  padding: 10px 0;
  color: #fff8e9;
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-lockup > div {
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 248, 233, 0.3);
  border-radius: var(--radius);
  color: #21170c;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(145deg, #f6d887, #c09132);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 3px;
  color: #d8c99f;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.app-topbar h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.28rem;
  line-height: 1;
  text-shadow: 0 2px 20px rgba(0, 0, 0, 0.28);
}

.team-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.legend-chip {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 13px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-weight: 800;
  font-size: 0.86rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.14);
}

.legend-chip.ruby {
  color: #ffe9ed;
  background: rgba(197, 59, 85, 0.28);
}

.legend-chip.cobalt {
  color: #e8efff;
  background: rgba(49, 95, 209, 0.3);
}

.icon-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 248, 233, 0.24);
  border-radius: 999px;
  color: #fff8e9;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 50%),
    rgba(255, 248, 233, 0.1);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  font-size: 1.18rem;
  font-weight: 900;
}

.icon-button[aria-pressed="true"] {
  color: #17211d;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.42), transparent 44%),
    linear-gradient(145deg, #f6d887, #c09132);
}

.icon-button.help-close {
  color: #3d2b16;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(237, 225, 201, 0.88)),
    #fffdf8;
  border-color: rgba(50, 34, 14, 0.22);
  box-shadow: 0 8px 18px rgba(50, 34, 14, 0.14);
}

.icon-button.help-close:hover,
.icon-button.help-close:focus-visible {
  color: #21160c;
  border-color: rgba(50, 34, 14, 0.38);
  box-shadow:
    0 8px 18px rgba(50, 34, 14, 0.16),
    0 0 0 3px rgba(199, 152, 61, 0.18);
}

.main-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow: visible;
  display: grid;
  grid-template-columns: minmax(260px, 292px) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 254, 249, 0.98), rgba(244, 236, 220, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.88),
    inset 0 -1px 0 rgba(61, 42, 16, 0.08);
}

.gateway-panel,
.room-panel,
.status-panel,
.spectator-panel,
.hand-panel,
.log-panel,
.history-panel {
  padding: 16px;
}

.gateway-panel {
  grid-column: 1;
  grid-row: 1;
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

.room-panel {
  grid-column: 1;
  grid-row: 2;
  max-height: none;
  overflow: visible;
}

.game-layout {
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(282px, 326px);
  gap: 18px;
  align-items: start;
}

.panel-head {
  position: relative;
  margin-bottom: 14px;
  padding-bottom: 10px;
}

/* Slim gold trim line under section headers — distinguishes the HUD card-sections
   ("현재 상태", "내 손패", "채팅", "방 정보") from generic webform panels.
   2px gradient bar that fades on both ends so it reads as a decoration, not a divider. */
.panel-head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(212, 162, 61, 0) 0%,
    rgba(212, 162, 61, 0.5) 18%,
    rgba(166, 122, 38, 0.62) 50%,
    rgba(212, 162, 61, 0.5) 82%,
    rgba(212, 162, 61, 0) 100%
  );
}

.panel-head.compact {
  margin-bottom: 10px;
  padding-bottom: 8px;
}

.panel-head-with-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: start;
}

.panel-head-copy {
  min-width: 0;
}

.panel-head-with-actions .warning-action {
  min-height: 36px;
  min-width: 104px;
  white-space: nowrap;
}

.panel-head h2,
.panel-head h3,
.stack-card h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.panel-head h2 {
  font-size: 1.42rem;
  line-height: 1.05;
  letter-spacing: 0.01em;
}

.panel-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.gateway-mode-hint {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #3c2a14;
  border: 1px solid rgba(80, 54, 18, 0.26);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(255, 255, 255, 0.34)),
    rgba(243, 215, 150, 0.14);
}

.gateway-grid,
.share-grid,
.share-status-card,
.invite-card,
.sidebar {
  display: grid;
  gap: 10px;
}

.welcome-card {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 0 0 14px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(132, 88, 30, 0.55);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), transparent 38%),
    linear-gradient(145deg, rgba(255, 250, 232, 0.94), rgba(244, 218, 158, 0.78) 48%, rgba(220, 184, 110, 0.82));
  box-shadow:
    inset 0 0 0 3px rgba(166, 112, 38, 0.48),
    0 12px 22px rgba(36, 24, 9, 0.18);
  color: #2a1d09;
}

.welcome-card[hidden] {
  display: none;
}

.welcome-title {
  display: block;
  padding-right: 34px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
  line-height: 1.2;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.6);
}

.welcome-body {
  margin: 0;
  font-size: 0.94rem;
  line-height: 1.5;
  color: #3a2812;
}

.welcome-body strong {
  color: #5a3c10;
}

.welcome-mode-banner {
  margin: 0;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0;
  color: #5a3c10;
  text-wrap: balance;
}

.welcome-steps {
  margin: 0;
  padding: 0 0 0 16px;
  color: #3d2a14;
  display: grid;
  gap: 4px;
  font-size: 0.84rem;
  line-height: 1.3;
}

.welcome-steps li {
  margin: 0;
}

.welcome-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.welcome-actions .primary-button,
.welcome-actions .ghost-button {
  min-height: 40px;
  width: 100%;
}

.welcome-dismiss {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 28px;
  width: 28px;
  border: 1px solid rgba(132, 88, 30, 0.42);
  border-radius: 50%;
  background: rgba(255, 250, 232, 0.7);
  color: #5a3c10;
  font-weight: 900;
  font-size: 0.84rem;
  padding: 0;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.welcome-dismiss:hover {
  background: rgba(255, 250, 232, 0.92);
}

@media (max-width: 680px) {
  .welcome-card {
    padding: 14px 14px 12px;
  }
  .panel-head-with-actions {
    grid-template-columns: 1fr;
  }
  .panel-head-with-actions .warning-action {
    justify-self: start;
    min-width: 124px;
  }
}

.sidebar {
  position: sticky;
  top: 88px;
  align-self: start;
  max-height: none;
  overflow: visible;
}

.gateway-grid {
  grid-template-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 246, 0.52);
  overflow: hidden;
  gap: 0;
}

body[data-has-room="true"] .gateway-panel {
  padding-bottom: 14px;
}

body[data-has-room="true"] .gateway-panel .panel-head {
  margin-bottom: 10px;
}

body[data-has-room="true"] .gateway-panel .panel-head h2 {
  font-size: 1.18rem;
}

body[data-has-room="true"] .gateway-panel .panel-head p,
body[data-has-room="true"] .gateway-grid {
  display: none;
}

body[data-has-room="true"] .share-grid {
  margin-top: 0;
}

body[data-has-room="true"] .share-status-card {
  display: none;
}

body[data-has-room="true"] .room-panel {
  display: none;
}

body[data-has-room="true"] .invite-card {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(243, 223, 174, 0.44)),
    var(--surface-raised);
}

body[data-game="playing"] .gateway-panel {
  opacity: 0.94;
}

body[data-game="none"][data-has-room="true"] .hand-panel {
  display: none;
}

body[data-game="playing"] .spectator-panel,
body[data-game="playing"] .log-panel,
body[data-game="playing"] .history-panel {
  display: none;
}

body[data-game="none"][data-has-room="true"] .log-panel,
body[data-game="none"][data-has-room="true"] .history-panel,
body[data-game="finished"] .spectator-panel,
body[data-game="finished"] .hand-panel,
body[data-game="finished"] .log-panel {
  display: none;
}

body[data-game="playing"] .room-panel {
  display: none;
}

.stack-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.stack-card + .stack-card {
  border-top: 1px solid var(--line);
}

.stack-card h3 {
  font-size: 1.03rem;
  color: #2a2116;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(250, 246, 236, 0.9)),
    var(--surface-raised);
  box-shadow: inset 0 1px 2px rgba(19, 25, 21, 0.05);
  text-transform: uppercase;
}

#create-name,
#join-name {
  text-transform: none;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff8e9;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.13), transparent 44%),
    linear-gradient(135deg, #14392f 0%, #28674b 100%);
  box-shadow: 0 12px 22px rgba(15, 48, 36, 0.24);
  font-weight: 800;
}

.primary-button.secondary-tone {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), transparent 46%),
    linear-gradient(135deg, #75501f 0%, #ba8127 100%);
}

#create-room-btn::before {
  content: "+";
}

#join-room-btn::before {
  content: "→";
}

#start-test-btn::before {
  content: "▶";
}

#offline-solo-btn::before {
  content: "♟";
}

body[data-static-host="true"] #offline-solo-btn {
  color: #fff8e9;
  border-color: rgba(15, 48, 36, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 44%),
    linear-gradient(135deg, #14392f 0%, #28674b 100%);
  box-shadow: 0 12px 22px rgba(15, 48, 36, 0.22);
}

body[data-static-host="true"] .create-match-setting,
body[data-static-host="true"] #join-form {
  opacity: 0.56;
}

body[data-static-host="true"] #create-room-btn,
body[data-static-host="true"] #join-room-btn {
  cursor: not-allowed;
  color: #6d604f;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(34, 31, 22, 0.04)),
    rgba(23, 33, 29, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

body[data-static-host="true"][data-has-room="false"] .share-grid {
  grid-template-columns: 1fr;
}

body[data-static-host="true"][data-has-room="false"] .invite-card,
body[data-static-host="true"][data-has-room="false"] .host-settings-card,
body[data-static-host="true"][data-has-room="false"] .share-actions-card,
body[data-static-host="true"][data-has-room="false"] .room-panel,
body[data-static-host="true"][data-has-room="false"] .game-layout {
  display: none;
}

#copy-code-btn::before,
#copy-room-btn::before,
#copy-spectator-link-btn::before {
  content: "⧉";
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

#share-room-btn::before {
  content: "↗";
}

#open-room-link::before {
  content: "↗";
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(34, 31, 22, 0.04)),
    rgba(23, 33, 29, 0.07);
  border: 1px solid rgba(23, 33, 29, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  font-weight: 800;
}

.ghost-button:hover:not(:disabled) {
  background: rgba(23, 33, 29, 0.12);
}

.warning-action {
  border-color: rgba(185, 52, 55, 0.45);
  color: #7a2229;
  background:
    linear-gradient(180deg, rgba(255, 226, 231, 0.58), rgba(255, 236, 239, 0.28)),
    rgba(255, 241, 243, 0.54);
}

.warning-action:hover:not(:disabled) {
  background:
    linear-gradient(180deg, rgba(255, 221, 227, 0.78), rgba(255, 230, 234, 0.42)),
    rgba(255, 230, 234, 0.62);
}

.warning-action[aria-disabled="true"],
.warning-action:disabled {
  opacity: 0.56;
}

.share-grid {
  margin-top: 14px;
}

.share-status-card,
.invite-card,
.ai-mode-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.54), rgba(238, 228, 209, 0.42)),
    rgba(239, 230, 214, 0.42);
  box-shadow: var(--shadow-soft);
}

.share-status-card > div {
  display: grid;
  gap: 3px;
}

.share-status-card strong,
.invite-label,
.mode-card-head span,
.invite-progress-topline span,
.lobby-progress-card span {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.share-status-card strong::before,
.invite-label::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(36, 122, 81, 0.14);
}

.share-status-card span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.ai-mode-card {
  display: grid;
  gap: 10px;
}

.host-settings-card {
  gap: 12px;
}

.mode-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.setting-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
}

.setting-topline span,
.toggle-row span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.setting-topline strong,
.toggle-row strong {
  color: #1d3a31;
  font-size: 0.84rem;
  text-transform: uppercase;
}

.host-setting {
  padding-top: 10px;
  border-top: 1px solid rgba(31, 38, 34, 0.1);
}

.host-setting:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.mode-card-head strong {
  color: #1d3a31;
  font-size: 0.92rem;
  text-transform: uppercase;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(23, 33, 29, 0.1);
  border-radius: var(--radius);
  background: rgba(23, 33, 29, 0.06);
}

.segmented-control button {
  min-width: 0;
  min-height: 36px;
  padding: 7px 6px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  box-shadow: none;
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.segmented-control button[aria-pressed="true"] {
  color: #fff8e9;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 46%),
    linear-gradient(135deg, #14392f, #28674b);
  box-shadow: 0 6px 12px rgba(15, 48, 36, 0.18);
}

.rematch-mode-control {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.toggle-row {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.toggle-row input {
  appearance: none;
  width: 46px;
  min-height: 26px;
  height: 26px;
  position: relative;
  padding: 0;
  border: 1px solid rgba(23, 33, 29, 0.18);
  border-radius: 999px;
  background: rgba(23, 33, 29, 0.16);
  box-shadow: inset 0 1px 3px rgba(17, 24, 20, 0.16);
  cursor: pointer;
  text-transform: none;
}

.toggle-row input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fffdf6;
  box-shadow: 0 2px 6px rgba(17, 24, 20, 0.28);
  transition:
    transform 140ms ease,
    background 140ms ease;
}

.toggle-row input:checked {
  border-color: rgba(36, 122, 81, 0.4);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 48%),
    var(--green);
}

.toggle-row input:checked::before {
  transform: translateX(20px);
}

.toggle-row input:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.room-code-display {
  border: 0;
  background: transparent;
  padding: 0;
  width: max-content;
  text-align: left;
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 2.1rem;
  letter-spacing: 0.1em;
  line-height: 1.05;
  color: #111915;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.68);
  cursor: default;
}

.room-code-display.copyable {
  cursor: pointer;
}

.room-code-display.copyable:hover,
.room-code-display.copyable:focus-visible {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

.room-code-display.copyable:focus-visible {
  outline: 2px solid #3e6f5a;
  outline-offset: 3px;
  border-radius: 6px;
}

.room-code-display:disabled {
  color: var(--muted);
}

.room-link-preview {
  border: 0;
  background: transparent;
  padding: 0;
  width: 100%;
  text-align: left;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.room-link-preview.copyable {
  cursor: copy;
}

.room-link-preview.copyable:hover,
.room-link-preview.copyable:focus-visible {
  color: #2a4b3f;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.room-link-preview.copyable:focus-visible {
  outline: 2px solid #3e6f5a;
  outline-offset: 3px;
  border-radius: 8px;
}

.room-link-preview:disabled {
  cursor: not-allowed;
}

.room-link-hint {
  display: inline-block;
  margin-top: 4px;
  color: var(--muted-strong);
  font-size: 0.76rem;
}

.room-link-hint kbd {
  margin: 0 2px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in oklab, var(--panel) 86%, var(--surface-raised) 14%);
  color: var(--ink);
  font-weight: 700;
}

.invite-progress-card {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 10px;
  border: 1px solid rgba(36, 122, 81, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(232, 243, 235, 0.62)),
    rgba(255, 253, 246, 0.58);
}

.invite-progress-card[hidden],
.lobby-progress-card[hidden] {
  display: none;
}

.invite-progress-topline,
.lobby-progress-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.invite-progress-topline strong,
.lobby-progress-card strong {
  color: #183a30;
  font-size: 1rem;
}

.invite-progress-card small,
.lobby-progress-card small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
}

.share-actions-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.share-actions-card .primary-button,
.share-actions-card .ghost-button {
  width: 100%;
}

#start-test-btn {
  grid-column: 1 / -1;
}

.button-link {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  text-align: center;
  text-decoration: none;
}

.button-link.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.flash-message,
.room-hint,
.status-message,
.selection-hint {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.flash-message {
  padding: 11px 12px;
  border: 1px solid rgba(199, 154, 60, 0.22);
  border-radius: var(--radius);
  background: rgba(243, 223, 174, 0.26);
  color: #5d4820;
  font-weight: 700;
}

.occupancy-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(238, 228, 209, 0.38)),
    rgba(255, 253, 248, 0.62);
}

.occupancy-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.occupancy-meter {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 33, 29, 0.12);
  box-shadow: inset 0 1px 2px rgba(17, 24, 20, 0.18);
}

.occupancy-meter.compact {
  height: 8px;
}

.occupancy-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), transparent 52%),
    linear-gradient(90deg, var(--ruby), var(--gold), var(--cobalt));
  transition: width 160ms ease;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.seat-card {
  min-height: 112px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.seat-card.ruby {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), transparent 44%),
    linear-gradient(180deg, #fff8f9, var(--ruby-soft));
}

.seat-card.cobalt {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), transparent 44%),
    linear-gradient(180deg, #f8fbff, var(--cobalt-soft));
}

.seat-card.you {
  border-color: rgba(199, 152, 61, 0.86);
  box-shadow:
    inset 0 0 0 2px rgba(199, 152, 61, 0.38),
    0 14px 28px rgba(79, 56, 14, 0.16);
}

.seat-card.thinking {
  border-color: rgba(36, 122, 81, 0.56);
  animation: thinkingSeatPulse 1200ms ease-in-out infinite;
}

.seat-title {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.seat-card strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.seat-status {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.seat-status.online {
  color: var(--green);
}

.seat-status.online::before,
.seat-status.bot::before,
.seat-status.thinking::before,
.seat-status.offline::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 999px;
  vertical-align: 1px;
  background: currentColor;
}

.seat-status.offline {
  color: #9d5b18;
}

.seat-status.bot {
  color: #7a5a16;
}

.seat-status.thinking {
  color: var(--green);
}

.board-panel {
  position: sticky;
  top: 88px;
  min-height: 0;
  height: calc(100dvh - 104px);
  display: grid;
  place-items: center;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 20%),
    linear-gradient(180deg, rgba(12, 39, 32, 0.98), rgba(5, 15, 13, 0.98));
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.board-panel::after {
  content: "AI 계산 중";
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 248, 233, 0.3);
  border-radius: 999px;
  color: #fff8e9;
  background: rgba(8, 28, 23, 0.88);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  opacity: 0;
  transform: translate(-50%, calc(-50% - 4px));
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  pointer-events: none;
}

body[data-ai="thinking"] .board-panel::after {
  opacity: 1;
  transform: translate(-50%, -50%);
  animation: thinkingBadge 1200ms ease-in-out infinite;
}

body[data-game="finished"] .board-panel::after {
  content: "게임 종료";
  top: 13%;
  min-height: 46px;
  padding: 11px 18px;
  opacity: 1;
  transform: translate(-50%, 0);
  animation: victoryBadge 1500ms ease-in-out infinite;
}

body[data-game="finished"][data-winner="A"] .board-panel::after {
  content: "루비 승리";
  background: rgba(87, 18, 33, 0.9);
}

body[data-game="finished"][data-winner="B"] .board-panel::after {
  content: "코발트 승리";
  background: rgba(20, 47, 111, 0.9);
}

#game-canvas {
  position: relative;
  z-index: 1;
  width: min(100%, calc(100dvh - 128px));
  max-width: 100%;
  height: auto;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  background: #18382e;
  box-shadow:
    0 16px 46px rgba(0, 0, 0, 0.42),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body[data-game="playing"][data-turn="yours"] #game-canvas {
  border-color: rgba(243, 223, 174, 0.52);
  box-shadow:
    0 18px 54px rgba(0, 0, 0, 0.44),
    0 0 0 4px rgba(36, 122, 81, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.09);
}

body[data-selected="true"] #game-canvas {
  cursor: crosshair;
  border-color: rgba(243, 223, 174, 0.78);
  box-shadow:
    0 22px 62px rgba(0, 0, 0, 0.48),
    0 0 0 5px rgba(36, 122, 81, 0.16),
    0 0 34px rgba(243, 223, 174, 0.18),
    inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.turn-banner {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 13px 14px;
  margin: 10px 0;
  border: 1px solid rgba(132, 96, 32, 0.34);
  border-radius: var(--radius);
  /* Felt-like backdrop matching the board surface so the turn banner reads as a HUD
     element on the same table as the board, not a generic notification card. */
  background:
    linear-gradient(180deg, rgba(255, 252, 240, 0.92), rgba(244, 226, 181, 0.62)),
    var(--surface-raised);
  box-shadow:
    0 0 0 1px rgba(212, 162, 61, 0.18) inset,
    0 8px 16px rgba(36, 24, 9, 0.16);
}

/* Slim gold accent bar on the left edge — "live status indicator" treatment. */
.turn-banner::before {
  content: "";
  position: absolute;
  left: 0;
  top: 18%;
  bottom: 18%;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, rgba(243, 223, 174, 0.9), rgba(166, 122, 38, 0.7));
}

.turn-banner strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 1.06rem;
}

#turn-team {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

#turn-team-name {
  overflow-wrap: anywhere;
}

.turn-thinking {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.turn-thinking-timer {
  display: inline-flex;
  justify-content: end;
  font-size: 0.74rem;
  color: var(--muted);
  margin-left: 2px;
  letter-spacing: 0;
}

.turn-thinking-timer[hidden] {
  display: none;
}

.thinking-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.thinking-dots i {
  width: 5px;
  height: 5px;
  display: block;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.36;
  animation: thinkingDotPulse 900ms ease-in-out infinite;
}

.thinking-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.thinking-dots i:nth-child(3) {
  animation-delay: 240ms;
}

.lobby-progress-card {
  display: grid;
  gap: 8px;
  margin: 8px 0 10px;
  padding: 11px;
  border: 1px solid rgba(36, 122, 81, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(232, 243, 235, 0.62)),
    var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

.victory-card {
  display: grid;
  gap: 8px;
  margin: 12px 0;
  padding: 14px;
  border: 1px solid rgba(199, 152, 61, 0.48);
  border-radius: var(--radius);
  color: #fff8e9;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), transparent 42%),
    linear-gradient(135deg, #183a30, #75501f);
  box-shadow:
    0 18px 34px rgba(37, 25, 10, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.victory-card[hidden] {
  display: none;
}

.victory-kicker {
  color: #f0dba4;
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.victory-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.72rem;
  line-height: 1;
}

.victory-card span:last-of-type {
  font-weight: 800;
}

.rematch-vote-status {
  color: #f0dba4;
  font-size: 0.82rem;
  font-weight: 900;
}

.victory-card .primary-button {
  margin-top: 4px;
  min-height: 44px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), transparent 44%),
    linear-gradient(135deg, #8b6324, #c99a3c);
}

#rematch-btn::before {
  content: "↻";
}

.team-ruby,
.ruby-text,
.score-row.ruby strong,
.score-row.ruby span {
  color: var(--ruby-deep);
}

.team-cobalt,
.cobalt-text,
.score-row.cobalt strong,
.score-row.cobalt span {
  color: var(--cobalt-deep);
}

.score-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0 10px 30px;
  border-bottom: 1px solid var(--line);
}

.score-row:last-child {
  border-bottom: 0;
}

/* Chip-shaped marker before each score line — reinforces the team identity visually
   and matches the chip rendering on the canvas board. Same radial gradient highlight
   from upper-left, white outer ring, dark outer border like a real casino chip. */
.score-row::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(16, 24, 21, 0.32);
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.score-row.ruby::before {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.78), transparent 48%),
    radial-gradient(circle at center, var(--ruby) 0%, var(--ruby-deep) 100%);
}

.score-row.cobalt::before {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.78), transparent 48%),
    radial-gradient(circle at center, var(--cobalt) 0%, var(--cobalt-deep) 100%);
}

.score-row.neutral::before {
  background:
    radial-gradient(circle at 32% 28%, rgba(255, 255, 255, 0.7), transparent 48%),
    radial-gradient(circle at center, var(--muted) 0%, var(--ink) 100%);
}

.score-row span {
  text-align: right;
  font-weight: 800;
}

.score-row.ruby::before,
.score-row.cobalt::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  opacity: 0.5;
}

.score-row.ruby::before {
  background: linear-gradient(90deg, var(--ruby), transparent);
}

.score-row.cobalt::before {
  background: linear-gradient(90deg, var(--cobalt), transparent);
}

.score-row.score-flash {
  animation: scoreFlash 1100ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.score-row.score-flash::after {
  content: "+1 시퀀스";
  position: absolute;
  right: 0;
  top: -14px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: #fff8e9;
  background: linear-gradient(135deg, #caa057, #8f6824);
  box-shadow: 0 6px 14px rgba(84, 52, 11, 0.36);
  animation: scoreBadgePop 1100ms cubic-bezier(0.2, 0.8, 0.2, 1);
  pointer-events: none;
}

@keyframes scoreFlash {
  0% {
    background: transparent;
    box-shadow: none;
  }
  35% {
    background: rgba(226, 180, 88, 0.28);
    box-shadow: inset 0 0 0 1px rgba(226, 180, 88, 0.36);
  }
  100% {
    background: transparent;
    box-shadow: none;
  }
}

@keyframes scoreBadgePop {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.72);
  }
  28% {
    opacity: 1;
    transform: translateY(-2px) scale(1.08);
  }
  70% {
    opacity: 1;
    transform: translateY(-2px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px) scale(0.9);
  }
}

.pile-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.pile-button {
  min-height: 94px;
  position: relative;
  display: grid;
  align-content: space-between;
  justify-items: start;
  isolation: isolate;
  overflow: hidden;
  padding: 12px 10px 12px 76px;
  border: 1px solid rgba(52, 37, 16, 0.16);
  color: #2a2116;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.78), transparent 40%),
    linear-gradient(180deg, #fffdf8, #e9dcc7);
  box-shadow:
    0 10px 22px rgba(36, 24, 9, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
  text-align: left;
}

.pile-button::before,
.pile-button::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* Bottom fake card of the stack — slightly rotated and deeper-toned, with stacked
   drop shadows that suggest 3-4 more cards beneath this one. Same paper-vignette +
   gold border treatment as the real cards so the stack reads as a deck of the same
   cards the player is holding/playing, not a generic UI button. */
.pile-button::before {
  left: 14px;
  top: 24px;
  z-index: 1;
  width: 45px;
  height: 60px;
  border: 1px solid rgba(132, 96, 32, 0.36);
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 253, 240, 0.42), transparent 62%),
    linear-gradient(180deg, #f1ddb8, #c4a378);
  box-shadow:
    inset 0 0 0 3px rgba(132, 96, 32, 0.14),
    3px 3px 0 rgba(84, 61, 29, 0.3),
    6px 6px 0 rgba(84, 61, 29, 0.2),
    9px 9px 0 rgba(84, 61, 29, 0.12),
    0 10px 22px rgba(36, 24, 9, 0.22);
  transform: rotate(-7deg) skewY(-2deg);
}

/* Top fake card — the one the player sees as "the top of the deck/discard". Brighter,
   straighter, with the same double-border decoration as a played card. */
.pile-button::after {
  left: 21px;
  top: 13px;
  z-index: 2;
  width: 45px;
  height: 60px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(132, 96, 32, 0.38);
  border-radius: 6px;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 253, 240, 0.46), transparent 62%),
    linear-gradient(180deg, #fffdf8, #ecdcc7);
  box-shadow:
    inset 0 0 0 3px rgba(132, 96, 32, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 12px 20px rgba(36, 24, 9, 0.22);
  transform: rotate(5deg);
}

.pile-button span {
  position: relative;
  z-index: 3;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pile-button strong {
  position: relative;
  z-index: 3;
  font-size: 1.12rem;
}

.pile-button small {
  position: relative;
  z-index: 3;
  color: var(--muted);
  font-weight: 800;
}

.pile-button.deck {
  color: #fff8e9;
  background:
    radial-gradient(circle at 88% 10%, rgba(255, 255, 255, 0.16), transparent 30%),
    linear-gradient(145deg, #234f41, #0a241e);
}

.pile-button.deck::before {
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 4px, transparent 4px 8px),
    linear-gradient(145deg, #386a58, #0d2a23);
}

.pile-button.deck::after {
  border-color: rgba(255, 248, 233, 0.18);
  background:
    radial-gradient(circle at 50% 48%, rgba(243, 223, 174, 0.26), transparent 22%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 3px, transparent 3px 7px),
    linear-gradient(145deg, #315b4c, #0a241e);
  box-shadow:
    inset 0 0 0 4px rgba(255, 248, 233, 0.08),
    0 12px 18px rgba(6, 20, 17, 0.28);
}

.pile-button.deck small {
  color: #d7c99e;
}

.pile-button.discard::after {
  content: attr(data-card-rank) "\A" attr(data-card-suit);
  white-space: pre;
  color: #252525;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  font-weight: 900;
  line-height: 0.9;
  text-align: center;
}

.pile-button.discard.red-card::after {
  color: #ad263e;
}

.pile-button.discard:not(.has-card)::after {
  content: "";
  border-style: dashed;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.38), transparent 42%),
    rgba(255, 253, 246, 0.48);
}

.pile-button.active {
  border-color: rgba(199, 152, 61, 0.9);
  box-shadow:
    0 0 0 3px rgba(199, 152, 61, 0.2),
    0 16px 30px rgba(79, 56, 14, 0.18);
  animation: pilePulse 1200ms ease-in-out infinite;
}

body[data-pending-step="draw"] .pile-button.deck.active,
body[data-pending-step="discard"] .pile-button.discard.active {
  transform: translateY(-3px);
  box-shadow:
    0 0 0 3px rgba(243, 223, 174, 0.24),
    0 20px 36px rgba(79, 56, 14, 0.26),
    0 0 22px rgba(243, 223, 174, 0.24);
}

body[data-pending-step="draw"] .pile-button.deck.active::after,
body[data-pending-step="discard"] .pile-button.discard.active::after {
  animation: pileTopCardDeal 720ms cubic-bezier(0.2, 0.8, 0.2, 1) infinite alternate;
}

.pile-button.stack-motion::after {
  animation: pileTopCardDeal 480ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hand-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.card-button {
  --fan-rotate: 0deg;
  --fan-y: 0px;
  position: relative;
  min-height: 134px;
  aspect-ratio: 0.72;
  isolation: isolate;
  overflow: hidden;
  padding: 10px;
  border: 1px solid rgba(68, 48, 21, 0.24);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 50% 52%, rgba(199, 154, 60, 0.1), transparent 34%),
    repeating-linear-gradient(0deg, rgba(69, 47, 18, 0.026) 0 1px, transparent 1px 7px),
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), transparent 42%),
    linear-gradient(180deg, #fffdf7 0%, #fbf1e2 58%, #ead8bf 100%);
  box-shadow:
    0 12px 22px rgba(48, 34, 15, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.96),
    inset 0 -1px 0 rgba(71, 50, 23, 0.08);
  text-align: left;
  transform: translateY(var(--fan-y)) rotate(var(--fan-rotate));
  transform-origin: 50% 96%;
  transition:
    transform 180ms cubic-bezier(0.2, 0.75, 0.2, 1),
    box-shadow 180ms ease,
    border-color 180ms ease,
    filter 180ms ease;
}

.card-button::before {
  content: "";
  position: absolute;
  inset: 6%;
  border: 1px solid rgba(132, 96, 32, 0.34);
  /* Second hairline border just inside the first — the "double-frame" decoration
     that Bicycle-style cards have. Matches the board-canvas card visual. */
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0), inset 0 0 0 3px rgba(132, 96, 32, 0.16);
  border-radius: 6px;
  pointer-events: none;
  z-index: 4;
}

.card-button::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  /* Paper-grain vignette: center brighter, corners slightly aged — matches the radial
     paper vignette the board-canvas cards use. Replaces the prior top-only sheen
     which read as "glossy plastic" instead of "card stock". */
  background:
    radial-gradient(ellipse at 50% 38%, rgba(255, 253, 240, 0.42), transparent 62%),
    radial-gradient(circle at 50% 50%, transparent 55%, rgba(165, 130, 70, 0.18) 100%);
  opacity: 0.78;
  pointer-events: none;
  z-index: 1;
}

.card-hidden {
  min-height: 118px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 11px;
  border: 1px solid rgba(68, 48, 21, 0.2);
  border-radius: var(--radius);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.84), transparent 46%),
    linear-gradient(180deg, #fffefb, #efe3cf);
  box-shadow:
    0 8px 16px rgba(48, 34, 15, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  text-align: left;
}

.card-button:hover:not(:disabled) {
  transform: translateY(calc(var(--fan-y) - 9px)) rotate(var(--fan-rotate)) scale(1.035);
  box-shadow:
    0 20px 30px rgba(48, 34, 15, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
  filter: saturate(1.05);
}

.card-button.selected {
  transform: translateY(-16px) rotate(calc(var(--fan-rotate) - 1.5deg)) scale(1.055);
  animation: cardSelectLift 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  border-color: rgba(40, 127, 86, 0.84);
  box-shadow:
    0 0 0 3px rgba(40, 127, 86, 0.18),
    0 22px 34px rgba(40, 127, 86, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

body[data-game="playing"] .hand-container {
  align-items: end;
  perspective: 760px;
  padding-top: 8px;
}

body[data-game="playing"] .card-button:nth-child(1) {
  --fan-rotate: -4deg;
  --fan-y: 8px;
}

body[data-game="playing"] .card-button:nth-child(2) {
  --fan-rotate: -2deg;
  --fan-y: 3px;
}

body[data-game="playing"] .card-button:nth-child(4) {
  --fan-rotate: 2deg;
  --fan-y: 3px;
}

body[data-game="playing"] .card-button:nth-child(5) {
  --fan-rotate: 4deg;
  --fan-y: 8px;
}

body[data-turn="yours"] .card-button:not(:disabled) {
  cursor: grab;
}

body[data-selected="true"] .card-button.selected {
  cursor: crosshair;
}

body[data-selected="true"] .selection-hint {
  color: #2b6d4c;
  font-weight: 900;
}

.card-button.focused:not(.selected) {
  border-color: rgba(199, 152, 61, 0.88);
  box-shadow:
    0 0 0 3px rgba(199, 152, 61, 0.16),
    0 12px 24px rgba(88, 64, 20, 0.13);
}

.card-corner {
  position: absolute;
  z-index: 5;
  display: grid;
  justify-items: center;
  gap: 0;
  line-height: 0.92;
  font-weight: 900;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.64);
}

.card-corner.top {
  top: 10px;
  left: 10px;
}

.card-corner.bottom {
  right: 10px;
  bottom: 10px;
  transform: rotate(180deg);
}

.card-corner strong {
  font-size: 1.04rem;
}

.card-corner small {
  font-size: 0.9rem;
}

.card-corner.red,
.card-face.red {
  color: #ad263e;
}

.card-corner.black,
.card-face.black {
  color: #252525;
}

.card-face {
  position: absolute;
  inset: 24% 19% 19%;
  z-index: 2;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 900;
  line-height: 1;
  pointer-events: none;
}

.face-pip {
  position: absolute;
  left: var(--pip-x);
  top: var(--pip-y);
  display: inline-block;
  color: currentColor;
  font-size: 1.08rem;
  transform: translate(-50%, -50%) rotate(var(--pip-rotate)) scale(var(--pip-scale));
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.58);
}

.card-face.court {
  inset: 25% 23% 18%;
  display: grid;
  place-items: center;
}

.court-frame {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 0.9fr 1.4fr 0.9fr;
  place-items: center;
  /* Aged-gold heraldic shield matching the canvas court face. Double border + inner
     glow + slightly desaturated gold gradient = real face-card frame look. */
  border: 1px solid rgba(132, 88, 30, 0.55);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent 35%),
    linear-gradient(145deg, rgba(255, 250, 232, 0.9), rgba(244, 218, 158, 0.75) 48%, rgba(220, 184, 110, 0.78));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0),
    inset 0 0 0 3px rgba(166, 112, 38, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.court-frame strong {
  font-size: 1.42rem;
  line-height: 1;
  /* Soft inner shadow on the rank letter — depth like an illuminated initial. */
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.66),
    0 2px 4px rgba(36, 24, 9, 0.32);
}

.court-band {
  font-size: 0.86rem;
  opacity: 0.92;
  font-weight: 900;
}

/* Iconic chess-piece glyph at the top of court cards (K=♔, Q=♕, J=♘). Renders in the
   ink color from the card-face inheritance so red-suit court cards show a red icon.
   Slight drop shadow for the same illuminated-initial depth the rank letter has. */
.court-icon {
  font-size: 1.18rem;
  line-height: 1;
  letter-spacing: 0;
  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6),
    0 1px 2px rgba(36, 24, 9, 0.22);
}

.court-band.bottom {
  transform: rotate(180deg);
}

.card-face.jack {
  inset: 22% 18% 17%;
  display: grid;
  place-items: center;
}

.jack-frame {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: 0.8fr 1fr 0.8fr 0.6fr;
  place-items: center;
  /* Heraldic gold frame matching .court-frame so J/Q/K read as one card family. */
  border: 1px solid rgba(132, 88, 30, 0.6);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.86), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 38%),
    linear-gradient(145deg, rgba(255, 250, 232, 0.92), rgba(244, 218, 158, 0.78) 48%, rgba(220, 184, 110, 0.82));
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0),
    inset 0 0 0 3px rgba(166, 112, 38, 0.52),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.card-button[data-action="placeWild"] .jack-frame {
  border-color: rgba(199, 152, 61, 0.42);
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.88), transparent 25%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.72), transparent 42%),
    linear-gradient(180deg, rgba(246, 216, 135, 0.78), rgba(236, 248, 232, 0.54));
}

.card-button[data-action="remove"] .jack-frame {
  border-color: rgba(173, 38, 62, 0.34);
  background:
    radial-gradient(circle at 50% 34%, rgba(255, 255, 255, 0.84), transparent 25%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), transparent 42%),
    linear-gradient(180deg, rgba(252, 225, 230, 0.74), rgba(237, 232, 219, 0.54));
}

.jack-crown,
.jack-sigil,
.jack-frame small {
  line-height: 1;
}

.jack-crown {
  font-size: 0.86rem;
}

.jack-frame strong {
  font-size: 1.4rem;
  line-height: 0.9;
}

.jack-sigil {
  min-width: 21px;
  min-height: 21px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #fff8e9;
  background: #8b6324;
  box-shadow: 0 4px 8px rgba(36, 24, 9, 0.14);
}

.card-button[data-action="placeWild"] .jack-sigil {
  background: #2d7554;
}

.card-button[data-action="remove"] .jack-sigil {
  background: #9d2941;
}

.jack-frame small {
  font-size: 0.52rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.card-targets {
  position: absolute;
  z-index: 6;
  top: 10px;
  right: 10px;
  min-width: 24px;
  min-height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  color: #344039;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(52, 64, 57, 0.12);
  font-size: 0.78rem;
  font-weight: 900;
}

.card-button[data-action="placeWild"] .card-targets,
.card-button[data-action="remove"] .card-targets {
  color: #fff8e9;
  background: var(--gold);
}

.card-flight {
  position: fixed;
  z-index: 999;
  pointer-events: none;
  margin: 0;
  animation: cardFlightToTarget 760ms cubic-bezier(0.16, 0.78, 0.18, 1) forwards;
  will-change: transform, opacity, filter;
}

.card-flight[data-action="placeWild"],
.card-flight[data-action="remove"] {
  filter:
    drop-shadow(0 18px 22px rgba(36, 24, 9, 0.24))
    drop-shadow(0 0 18px rgba(199, 152, 61, 0.28));
}

.card-flight .card-targets,
.card-flight .card-action,
.card-flight .card-note {
  display: none;
}

.card-flight.to-discard {
  animation-name: cardFlightToPile;
}

.card-note {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 28px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
  text-align: center;
}

.card-action {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 52px;
  color: #5d4820;
  font-size: 0.72rem;
  font-weight: 900;
  text-align: center;
}

body[data-game="playing"] .hand-container {
  /* 2026-05-23 — was repeat(5, ...) which on a 326px-cap sidebar gave each card
     ~58px wide (with min-height 128 and aspect-ratio 0.72 the cards looked
     squished vertical strips). Cutting to 3 columns gives each card ~95px wide,
     wraps the standard 6-card hand to 2 rows of 3 — much more readable. */
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

body[data-game="playing"] .card-button {
  min-height: 152px;
  padding: 10px;
}

body[data-game="playing"] .card-corner.top {
  top: 8px;
  left: 8px;
}

body[data-game="playing"] .card-corner.bottom {
  right: 8px;
  bottom: 8px;
}

body[data-game="playing"] .card-corner strong {
  font-size: 1.16rem;
}

body[data-game="playing"] .card-corner small {
  font-size: 1rem;
}

body[data-game="playing"] .card-face {
  inset: 25% 18% 18%;
}

body[data-game="playing"] .face-pip {
  font-size: 1.18rem;
}

body[data-game="playing"] .court-frame strong {
  font-size: 1.18rem;
}

body[data-game="playing"] .court-band {
  font-size: 0.78rem;
}

body[data-game="playing"] .card-face.jack {
  inset: 24% 18% 17%;
}

body[data-game="playing"] .jack-frame strong {
  font-size: 1.16rem;
}

body[data-game="playing"] .jack-crown {
  font-size: 0.78rem;
}

body[data-game="playing"] .jack-sigil {
  min-width: 16px;
  min-height: 16px;
  font-size: 0.64rem;
}

body[data-game="playing"] .jack-frame small {
  font-size: 0.42rem;
}

body[data-game="playing"] .card-targets {
  top: 8px;
  right: 8px;
  min-width: 20px;
  min-height: 20px;
  font-size: 0.68rem;
}

body[data-game="playing"] .card-action,
body[data-game="playing"] .card-note {
  display: none;
}

.card-hidden {
  place-items: center;
  text-align: center;
  color: var(--muted);
  background:
    repeating-linear-gradient(135deg, rgba(23, 33, 29, 0.035) 0 6px, transparent 6px 12px),
    rgba(23, 33, 29, 0.05);
}

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

.spectator-panel,
.log-panel,
.history-panel {
  max-height: 360px;
  overflow: auto;
}

.log-list,
.history-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 0;
  list-style-position: inside;
}

.log-list li,
.history-list li {
  padding: 9px 10px;
  border-radius: var(--radius);
  background: rgba(255, 253, 246, 0.55);
  border: 1px solid rgba(31, 38, 34, 0.08);
  line-height: 1.4;
}

.empty-state {
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  list-style: none;
  color: #4b3a1a;
  background:
    radial-gradient(circle at 16% 24%, rgba(255, 255, 255, 0.76), transparent 38%),
    linear-gradient(135deg, rgba(255, 253, 246, 0.72), rgba(243, 223, 174, 0.26)),
    rgba(255, 253, 246, 0.58);
}

.empty-state-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid rgba(132, 96, 32, 0.28);
  border-radius: 50%;
  color: #6a4a10;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.68), rgba(226, 176, 79, 0.22)),
    rgba(243, 223, 174, 0.38);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    0 4px 10px rgba(36, 24, 9, 0.1);
  font-size: 0.9rem;
  font-weight: 900;
}

.empty-state-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.empty-state-actions {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.empty-state-title {
  min-width: 0;
  color: #3f2d0f;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.empty-state-body {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.empty-state-action {
  justify-self: start;
  min-height: 32px;
  padding: 6px 10px;
  width: fit-content;
}

.empty-state-action:disabled {
  opacity: 0.55;
}

.history-list {
  list-style: none;
}

.history-trim-notice {
  margin: 0;
  padding: 7px 10px;
  list-style: none;
  border: 1px dashed rgba(132, 96, 32, 0.28);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 253, 246, 0.38);
  font-size: 0.74rem;
  line-height: 1.35;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  min-height: 34px;
  margin-bottom: 9px;
  padding: 8px;
  border: 1px solid rgba(199, 152, 61, 0.22);
  border-radius: var(--radius);
  color: #5d4820;
  background:
    linear-gradient(180deg, rgba(255, 253, 246, 0.7), rgba(243, 223, 174, 0.2)),
    rgba(243, 223, 174, 0.2);
}

.history-stat {
  min-width: 0;
  display: grid;
  gap: 1px;
  padding: 7px 8px;
  border: 1px solid rgba(132, 96, 32, 0.2);
  border-radius: 7px;
  background: rgba(255, 253, 246, 0.54);
}

.history-stat span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.history-stat strong {
  overflow: hidden;
  color: #4a3512;
  font-size: 0.86rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-policy {
  margin-bottom: 8px;
  padding: 6px 8px;
  border: 1px dashed rgba(132, 96, 32, 0.3);
  border-radius: 7px;
  background: rgba(255, 253, 246, 0.45);
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.history-stat.ruby strong {
  color: var(--ruby-deep);
}

.history-stat.cobalt strong {
  color: var(--cobalt-deep);
}

.history-item {
  display: grid;
  gap: 7px;
}

.history-item-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.history-item-head strong {
  min-width: 0;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-score {
  padding: 3px 8px;
  border: 1px solid rgba(132, 96, 32, 0.2);
  border-radius: 999px;
  color: #4a3512;
  background: rgba(255, 253, 246, 0.68);
  font-size: 0.74rem;
  font-weight: 900;
}

.history-item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.history-meta-chip,
.history-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.history-meta-chip {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 253, 246, 0.55);
  font-weight: 800;
}

.history-meta-chip.latest {
  color: #5a3c10;
  background: rgba(226, 176, 79, 0.24);
}

.history-meta-chip.duration {
  color: #31503f;
  background: rgba(77, 189, 133, 0.14);
}

.history-item.ruby {
  border-color: rgba(195, 58, 85, 0.2);
  background:
    linear-gradient(90deg, rgba(249, 223, 229, 0.72), rgba(255, 253, 246, 0.54)),
    rgba(255, 253, 246, 0.55);
}

.history-item.cobalt {
  border-color: rgba(47, 98, 212, 0.2);
  background:
    linear-gradient(90deg, rgba(223, 233, 255, 0.76), rgba(255, 253, 246, 0.54)),
    rgba(255, 253, 246, 0.55);
}

.history-item.latest {
  box-shadow:
    inset 3px 0 0 rgba(199, 152, 61, 0.72),
    0 8px 16px rgba(36, 24, 9, 0.1);
}

.spectator-list {
  display: grid;
  gap: 8px;
}

.spectator-item,
.spectator-empty {
  min-height: 50px;
  display: grid;
  gap: 4px;
  align-content: center;
  padding: 10px 11px;
  border: 1px solid rgba(31, 38, 34, 0.08);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(238, 228, 209, 0.3)),
    rgba(255, 253, 246, 0.58);
}

.spectator-empty.empty-state,
.chat-empty.empty-state,
.log-empty.empty-state,
.history-empty.empty-state {
  border-color: rgba(132, 96, 32, 0.16);
  color: #4b3a1a;
}

.spectator-item {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.spectator-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.spectator-meta,
.spectator-empty {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.spectator-item.online .spectator-meta {
  color: var(--green);
}

.spectator-item.online .spectator-meta::before {
  content: "";
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 6px;
  border-radius: 999px;
  background: currentColor;
  vertical-align: 1px;
}

.spectator-hand {
  grid-column: 1 / -1;
}

.chat-panel {
  display: grid;
  gap: 8px;
}

.chat-log {
  min-height: 92px;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 253, 246, 0.6);
  font-size: 0.88rem;
}

.chat-line {
  margin: 0 0 6px;
  line-height: 1.35;
}

.chat-line strong {
  margin-right: 6px;
}

.chat-emoji-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.emoji-btn {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 1rem;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.chat-form input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 10px;
}

.chat-char-count {
  min-height: 16px;
  text-align: right;
  color: var(--muted);
  font-size: 0.78rem;
}

.chat-feedback {
  min-height: 18px;
  color: var(--ink);
  font-size: 0.78rem;
}

.chat-feedback[data-status="hidden"] {
  opacity: 0;
}

.chat-feedback[data-status="info"] {
  opacity: 0.9;
  color: var(--ruby);
}

.chat-feedback[data-status="error"] {
  opacity: 0.95;
  color: #7b2a2a;
}

body[data-turn="yours"] .turn-banner {
  border-color: rgba(36, 122, 81, 0.32);
  box-shadow:
    0 0 0 3px rgba(36, 122, 81, 0.1),
    var(--shadow-soft);
}

body[data-selected="true"] .hand-panel {
  border-color: rgba(36, 122, 81, 0.34);
}

body[data-ai="thinking"] .status-panel,
body[data-ai="thinking"] .hand-panel {
  border-color: rgba(36, 122, 81, 0.26);
}

body[data-role="spectator"] .hand-panel {
  border-color: rgba(199, 152, 61, 0.28);
}

body[data-team="A"] .brand-mark {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(145deg, #f5bdc9, var(--ruby));
  color: #3a111b;
}

body[data-team="B"] .brand-mark {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.35), transparent 42%),
    linear-gradient(145deg, #b9cbff, var(--cobalt));
  color: #0c1b42;
}

/* Turn handoff: when JS sets data-turn-just-arrived=true on body, the turn banner and
   board panel each run a brief one-shot pulse so the player sees their turn arriving
   without staring at the screen. JS clears the attribute after ~850ms. The keyframes
   resolve back to the steady-state shadows so the post-animation render matches the
   existing data-turn=yours decoration. */
body[data-turn-just-arrived="true"] .turn-banner {
  animation: turnArriveBannerPulse 800ms ease-out 1;
}

body[data-turn-just-arrived="true"] .board-panel {
  animation: turnArriveBoardGlow 800ms ease-out 1;
}

@keyframes turnArriveBannerPulse {
  0% {
    box-shadow:
      0 0 0 3px rgba(36, 122, 81, 0.1),
      var(--shadow-soft);
  }
  35% {
    box-shadow:
      0 0 0 14px rgba(36, 122, 81, 0.22),
      0 0 28px rgba(36, 122, 81, 0.42),
      var(--shadow-soft);
  }
  100% {
    box-shadow:
      0 0 0 3px rgba(36, 122, 81, 0.1),
      var(--shadow-soft);
  }
}

@keyframes turnArriveBoardGlow {
  0%,
  100% {
    box-shadow:
      0 28px 80px rgba(0, 0, 0, 0.34),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  40% {
    box-shadow:
      0 28px 80px rgba(0, 0, 0, 0.34),
      inset 0 0 0 3px rgba(36, 122, 81, 0.55),
      0 0 44px rgba(36, 122, 81, 0.32);
  }
}

@media (prefers-reduced-motion: reduce) {
  body[data-turn-just-arrived="true"] .turn-banner,
  body[data-turn-just-arrived="true"] .board-panel {
    animation: none;
  }
}

@keyframes thinkingSeatPulse {
  0%,
  100% {
    box-shadow:
      inset 0 0 0 2px rgba(36, 122, 81, 0.16),
      0 10px 22px rgba(36, 122, 81, 0.08);
  }

  50% {
    box-shadow:
      inset 0 0 0 2px rgba(36, 122, 81, 0.36),
      0 18px 34px rgba(36, 122, 81, 0.2);
  }
}

@keyframes thinkingBadge {
  0%,
  100% {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
  }

  50% {
    box-shadow:
      0 12px 30px rgba(0, 0, 0, 0.28),
      0 0 0 4px rgba(36, 122, 81, 0.18);
  }
}

@keyframes thinkingDotPulse {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }

  50% {
    opacity: 0.9;
    transform: translateY(-2px);
  }
}

@keyframes victoryBadge {
  0%,
  100% {
    box-shadow:
      0 12px 30px rgba(0, 0, 0, 0.28),
      0 0 0 0 rgba(243, 223, 174, 0.2);
  }

  50% {
    box-shadow:
      0 16px 42px rgba(0, 0, 0, 0.34),
      0 0 0 6px rgba(243, 223, 174, 0.18);
  }
}

@keyframes pilePulse {
  0%,
  100% {
    filter: brightness(1);
  }

  50% {
    filter: brightness(1.08);
  }
}

@keyframes pileTopCardDeal {
  0% {
    transform: translateY(-7px) rotate(9deg) scale(0.96);
  }

  58% {
    transform: translateY(-13px) rotate(2deg) scale(1.05);
  }

  100% {
    transform: translateY(0) rotate(5deg) scale(1);
  }
}

@keyframes cardSelectLift {
  0% {
    transform: translateY(var(--fan-y)) rotate(var(--fan-rotate)) scale(1);
  }

  70% {
    transform: translateY(-20px) rotate(calc(var(--fan-rotate) - 2deg)) scale(1.075);
  }

  100% {
    transform: translateY(-16px) rotate(calc(var(--fan-rotate) - 1.5deg)) scale(1.055);
  }
}

@keyframes cardFlightToTarget {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(-2deg) scale(1);
    filter: drop-shadow(0 16px 18px rgba(36, 24, 9, 0.22));
  }

  46% {
    opacity: 0.98;
    transform: translate3d(var(--flight-mid-x), var(--flight-mid-y), 0) rotate(-11deg) scale(0.97);
    filter: drop-shadow(0 24px 28px rgba(36, 24, 9, 0.2));
  }

  82% {
    opacity: 0.9;
    transform: translate3d(var(--flight-touch-x), var(--flight-touch-y), 0) rotate(4deg) scale(0.62);
    filter: drop-shadow(0 8px 12px rgba(36, 24, 9, 0.16));
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--flight-x), var(--flight-y), 0) rotate(5deg) scale(0.42);
    filter: drop-shadow(0 2px 4px rgba(36, 24, 9, 0.12));
  }
}

@keyframes cardFlightToPile {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) rotate(-2deg) scale(1);
  }

  44% {
    opacity: 0.96;
    transform: translate3d(var(--flight-mid-x), var(--flight-mid-y), 0) rotate(10deg) scale(0.94);
  }

  82% {
    opacity: 0.82;
    transform: translate3d(var(--flight-touch-x), var(--flight-touch-y), 0) rotate(-6deg) scale(0.58);
  }

  100% {
    opacity: 0;
    transform: translate3d(var(--flight-x), var(--flight-y), 0) rotate(-8deg) scale(0.48);
  }
}

[data-theme="dark"] .panel {
  border-color: rgba(230, 237, 235, 0.14);
  background:
    linear-gradient(180deg, rgba(22, 43, 36, 0.98), rgba(11, 27, 22, 0.96)),
    var(--surface);
  box-shadow: var(--shadow);
}

[data-theme="dark"] .panel::before {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.28);
}

[data-theme="dark"] .gateway-grid,
[data-theme="dark"] .share-status-card,
[data-theme="dark"] .invite-card,
[data-theme="dark"] .ai-mode-card,
[data-theme="dark"] .turn-banner,
[data-theme="dark"] .lobby-progress-card {
  border-color: var(--line);
  background:
    linear-gradient(180deg, rgba(30, 54, 46, 0.92), rgba(15, 34, 28, 0.9)),
    var(--surface-raised);
  box-shadow: var(--shadow-soft);
}

[data-theme="dark"] body[data-has-room="true"] .invite-card {
  background:
    linear-gradient(135deg, rgba(31, 58, 48, 0.96), rgba(49, 43, 25, 0.72)),
    var(--surface-raised);
}

[data-theme="dark"] input {
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(26, 49, 41, 0.95), rgba(15, 34, 28, 0.95)),
    var(--surface-raised);
  border-color: var(--line-strong);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.32);
}

[data-theme="dark"] input::placeholder {
  color: rgba(230, 237, 235, 0.42);
}

[data-theme="dark"] .stack-card h3,
[data-theme="dark"] .setting-topline strong,
[data-theme="dark"] .toggle-row strong,
[data-theme="dark"] .mode-card-head strong,
[data-theme="dark"] .room-code-display {
  color: var(--text);
  text-shadow: none;
}

[data-theme="dark"] .ghost-button {
  color: var(--text);
  border-color: var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.16)),
    rgba(230, 237, 235, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .ghost-button:hover:not(:disabled) {
  background: rgba(230, 237, 235, 0.12);
}

[data-theme="dark"] .segmented-control {
  border-color: var(--line);
  background: rgba(230, 237, 235, 0.07);
}

[data-theme="dark"] .host-setting {
  border-top-color: var(--line);
}

[data-theme="dark"] .toggle-row input {
  border-color: var(--line-strong);
  background: rgba(230, 237, 235, 0.12);
}

[data-theme="dark"] .pile-button:not(.deck) {
  color: var(--text);
  border-color: var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), transparent 42%),
    linear-gradient(180deg, rgba(35, 58, 49, 0.94), rgba(18, 39, 32, 0.94));
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .pile-button:not(.deck) small {
  color: var(--muted);
}

[data-theme="dark"] .pile-button:not(.deck)::before {
  border-color: rgba(230, 237, 235, 0.18);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.2), transparent 42%),
    linear-gradient(180deg, #c9b38f, #7e6d50);
}

[data-theme="dark"] .pile-button:not(.deck)::after {
  border-color: rgba(230, 237, 235, 0.22);
}

@media (max-width: 1320px) {
  .main-grid {
    grid-template-columns: 1fr;
  }

  .gateway-panel,
  .room-panel,
  .game-layout {
    grid-column: 1;
    grid-row: auto;
  }

  .game-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  }

  .gateway-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .share-grid {
    grid-template-columns: minmax(220px, 0.85fr) minmax(260px, 1.15fr) minmax(260px, 1fr);
    align-items: stretch;
  }

  .seat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .main-grid {
    grid-template-rows: auto auto auto;
    overflow: visible;
  }

  .game-layout,
  .gateway-grid,
  .share-grid {
    grid-template-columns: 1fr;
  }

  .gateway-panel {
    order: 1;
  }

  .game-layout {
    order: 2;
    min-height: 0;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .room-panel {
    order: 3;
  }

  .app-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .team-legend {
    justify-content: flex-start;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .board-panel {
    position: relative;
    top: auto;
    height: min(54dvh, 620px);
  }

  .sidebar {
    position: relative;
    top: auto;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 680px) {
  body[data-game="playing"][data-has-room="true"] {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  .app-shell {
    min-height: auto;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  body[data-game="playing"][data-has-room="true"] .app-shell {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  }

  body[data-has-room="true"] .main-grid {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .app-topbar {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding: 0;
  }

  .brand-lockup {
    flex: 1 1 auto;
    gap: 8px;
  }

  .brand-mark {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .eyebrow {
    font-size: 0.62rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-topbar h1 {
    max-width: 156px;
    overflow: hidden;
    font-size: 1.18rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .team-legend {
    display: none;
  }

  .topbar-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 6px;
  }

  .notification-toggle {
    display: none;
  }

  body[data-game="playing"][data-has-room="true"] .app-topbar {
    display: none;
  }

  .install-toggle[hidden] {
    display: none;
  }

  .icon-button {
    /* Keep touch targets at 44px even on smaller breakpoints for WCAG 2.5.5 AA. */
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
    font-size: 1rem;
  }

  .gateway-panel,
  .room-panel,
  .status-panel,
  .spectator-panel,
  .hand-panel,
  .log-panel,
  .history-panel {
    padding: 12px;
  }

  .share-actions-card,
  .seat-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .room-code-display {
    font-size: 1.62rem;
  }

  .turn-banner {
    grid-template-columns: 1fr;
  }

  body[data-has-room="true"] .main-grid {
    min-height: 0;
    grid-template-rows: auto auto;
    gap: 8px;
    align-items: stretch;
  }

  body[data-game="playing"][data-has-room="true"] .main-grid {
    height: 100%;
    overflow: hidden;
    padding-bottom: 0;
    grid-template-rows: minmax(0, 1fr);
    gap: 0;
  }

  body[data-has-room="true"] .gateway-panel {
    max-height: none;
    padding: 8px;
  }

  body[data-has-room="true"] .gateway-panel .panel-head,
  body[data-has-room="true"] .share-status-card,
  body[data-has-room="true"] .room-link-preview,
  body[data-has-room="true"] .flash-message {
    display: none;
  }

  body[data-has-room="true"] .share-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 5px;
  }

  body[data-has-room="true"] .invite-card {
    min-height: 46px;
    padding: 7px 10px;
  }

  body[data-has-room="true"] .room-code-display {
    font-size: 1.2rem;
    letter-spacing: 0.08em;
  }

  body[data-has-room="true"] .share-actions-card {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body[data-has-room="true"] .share-actions-card .primary-button,
  body[data-has-room="true"] .share-actions-card .ghost-button {
    min-height: 38px;
    padding: 7px 6px;
    font-size: 0.84rem;
  }

  body[data-has-room="true"] #start-test-btn {
    grid-column: auto;
  }

  body[data-has-room="true"] #copy-room-btn,
  body[data-has-room="true"] #copy-spectator-link-btn,
  body[data-has-room="true"] #share-room-btn,
  body[data-has-room="true"] #open-room-link {
    display: none;
  }

  body[data-game="playing"] .gateway-panel {
    display: none;
  }

  body[data-has-room="true"] .room-panel {
    display: none;
  }

  body[data-has-room="true"] .game-layout {
    grid-template-rows: clamp(236px, 34dvh, 304px) auto;
    gap: 8px;
    overflow: visible;
    align-items: stretch;
    min-width: 0;
  }

  body[data-game="playing"][data-has-room="true"] .game-layout {
    height: 100%;
    grid-template-rows: minmax(0, 1fr) auto;
    gap: 6px;
    overflow: hidden;
  }

  body[data-game="finished"][data-has-room="true"] .game-layout {
    grid-template-rows: clamp(258px, 36dvh, 320px) minmax(0, 1fr);
  }

  body[data-has-room="true"] .board-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: 100%;
    min-height: 0;
    padding: 7px;
    overflow: hidden;
    align-self: stretch;
  }

  body[data-game="playing"][data-has-room="true"] .board-panel {
    height: min(47dvh, calc(100vw - 16px));
    min-height: min(292px, calc(100vw - 16px));
    padding: 6px;
  }

  body[data-has-room="true"] #game-canvas {
    width: auto;
    height: min(100%, calc(100vw - 30px));
    max-height: 100%;
  }

  body[data-has-room="true"] .sidebar {
    display: grid;
    grid-template-rows: auto auto;
    gap: 6px;
    min-width: 0;
    min-height: 0;
  }

  body[data-game="playing"][data-has-room="true"] .sidebar {
    overflow: hidden;
  }

  body[data-has-room="true"] .spectator-panel,
  body[data-game="playing"][data-has-room="true"] .chat-panel,
  body[data-has-room="true"] .log-panel,
  body[data-has-room="true"] .history-panel {
    display: none;
  }

  .status-panel {
    padding: 10px;
  }

  body[data-game="playing"][data-has-room="true"] .status-panel {
    padding: 7px;
    border-radius: 14px;
  }

  body[data-has-room="true"] .status-panel .panel-head {
    display: none;
  }

  body[data-has-room="true"] .turn-banner {
    grid-template-columns: minmax(0, 1fr) auto;
    margin: 0 0 8px;
    padding: 9px;
  }

  body[data-game="playing"][data-has-room="true"] .turn-banner {
    min-height: 42px;
    margin: 0 0 5px;
    padding: 6px 8px;
    border-radius: 12px;
  }

  body[data-has-room="true"] .turn-banner strong {
    font-size: 0.98rem;
  }

  body[data-game="playing"][data-has-room="true"] .turn-banner strong {
    font-size: 0.9rem;
  }

  .status-message {
    margin-top: 8px;
    font-size: 0.9rem;
    line-height: 1.38;
  }

  body[data-game="playing"][data-has-room="true"] .status-message {
    display: none;
  }

  .score-row {
    padding: 7px 0;
  }

  body[data-game="playing"][data-has-room="true"] .score-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 3px 0;
    min-height: 24px;
    font-size: 0.82rem;
  }

  body[data-game="playing"][data-has-room="true"] .score-row.neutral {
    display: none;
  }

  .pile-actions {
    margin-top: 8px;
  }

  body[data-game="playing"][data-has-room="true"][data-pending-step="none"] .pile-actions {
    display: none;
  }

  body[data-game="playing"][data-has-room="true"] .pile-actions {
    margin-top: 5px;
    gap: 6px;
  }

  .pile-button {
    min-height: 70px;
    padding: 9px 8px 9px 64px;
  }

  body[data-game="playing"][data-has-room="true"] .pile-button {
    min-height: 46px;
    padding: 6px 7px 6px 43px;
    border-radius: 13px;
    font-size: 0.78rem;
  }

  .pile-button::before {
    left: 11px;
    top: 20px;
    width: 38px;
    height: 49px;
  }

  body[data-game="playing"][data-has-room="true"] .pile-button::before {
    left: 8px;
    top: 12px;
    width: 26px;
    height: 34px;
  }

  .pile-button::after {
    left: 16px;
    top: 10px;
    width: 38px;
    height: 49px;
    font-size: 0.84rem;
  }

  body[data-game="playing"][data-has-room="true"] .pile-button::after {
    left: 12px;
    top: 6px;
    width: 26px;
    height: 34px;
    font-size: 0.62rem;
  }

  body[data-game="playing"][data-has-room="true"] .pile-button small {
    display: none;
  }

  .hand-panel {
    max-width: 100%;
    min-width: 0;
    padding: 10px;
    overflow: visible;
  }

  body[data-game="playing"][data-has-room="true"] .hand-panel {
    /* anchored by .game-layout grid-template-rows: minmax(0,1fr) auto */
    position: relative;
    bottom: auto;
    z-index: 8;
    padding: 6px 6px 7px;
    overflow: hidden;
    border-color: rgba(243, 223, 174, 0.34);
    background:
      linear-gradient(180deg, rgba(255, 253, 246, 0.9), rgba(238, 226, 201, 0.88)),
      rgba(255, 253, 246, 0.82);
    box-shadow:
      0 -12px 34px rgba(40, 28, 12, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(16px);
  }

  [data-theme="dark"] body[data-game="playing"][data-has-room="true"] .hand-panel {
    border-color: rgba(230, 237, 235, 0.18);
    background:
      linear-gradient(180deg, rgba(23, 48, 39, 0.92), rgba(10, 30, 25, 0.9)),
      rgba(10, 30, 25, 0.86);
    box-shadow:
      0 -12px 34px rgba(0, 0, 0, 0.3),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }

  body[data-game="playing"][data-has-room="true"] .hand-panel .panel-head,
  body[data-game="playing"][data-has-room="true"] .selection-hint {
    display: none;
  }

  .hand-container {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
  }

  body[data-game="playing"][data-has-room="true"] .hand-container {
    display: flex;
    align-items: flex-end;
    gap: 0;
    overflow-x: auto;
    overflow-y: visible;
    padding: 8px 4px 8px;
    margin-bottom: 4px;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
  }

  body[data-game="playing"][data-has-room="true"] .hand-container::-webkit-scrollbar {
    display: none;
  }

  .card-button {
    min-height: 108px;
    padding: 8px;
  }

  body[data-game="playing"][data-has-room="true"] .card-button {
    /* 2026-05-23 — bumped from clamp(62px, 20vw, 78px) × 96px tall. Users reported
       gameplay-hand cards were too small to read on mobile. 26vw cap gives ~3.5 cards
       visible on a 390px phone (was ~5), but each is now clearly readable. */
    flex: 0 0 clamp(78px, 26vw, 110px);
    min-height: 124px;
    margin-right: -8px;
    scroll-snap-align: center;
  }

  body[data-game="playing"][data-has-room="true"] .card-button:last-child {
    margin-right: 0;
  }

  body[data-game="playing"][data-has-room="true"] .card-button.selected {
    z-index: 3;
  }

  body[data-game="playing"][data-has-room="true"] .button-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  body[data-game="playing"][data-has-room="true"] .button-row button {
    min-height: 34px;
    padding: 6px;
    font-size: 0.8rem;
  }

  .card-corner.top {
    top: 7px;
    left: 7px;
  }

  .card-corner.bottom {
    right: 7px;
    bottom: 7px;
  }

  .card-corner strong {
    font-size: 0.94rem;
  }

  .card-corner small {
    font-size: 0.82rem;
  }

  .card-face {
    inset: 25% 17% 18%;
  }

  .face-pip {
    font-size: 0.86rem;
  }

  .court-frame strong {
    font-size: 0.98rem;
  }

  .court-band {
    font-size: 0.66rem;
  }

  .card-face.jack {
    inset: 25% 18% 17%;
  }

  .jack-frame strong {
    font-size: 0.92rem;
  }

  .jack-crown {
    font-size: 0.58rem;
  }

  .jack-sigil {
    min-width: 14px;
    min-height: 14px;
    font-size: 0.56rem;
  }

  .jack-frame small {
    font-size: 0.38rem;
  }

  .card-targets {
    top: 7px;
    right: 7px;
    min-width: 20px;
    min-height: 20px;
    font-size: 0.68rem;
  }

  .card-action,
  .card-note {
    display: none;
  }
}
