/* ============================================================
   KEEZEN OP ZEE — Nautisch thema
   ============================================================ */

:root {
  /* Nautical palette */
  --sea-deep: #0a2540;
  --sea-mid: #154673;
  --sea-light: #2978a0;
  --sea-foam: #b8d8e8;
  --parchment: #f4e7c8;
  --parchment-dark: #d9c490;
  --wood-light: #c89f6b;
  --wood-mid: #8b6f47;
  --wood-dark: #5a4023;
  --rope: #c4a060;
  --brass: #c9a96e;
  --brass-dark: #8a6f3d;
  --ink: #2a1810;
  --sail: #f5ecd9;

  /* Player colors (mapped to nautical) */
  --p0: #e8c547;   /* Zon (yellow) */
  --p0-dark: #b0922c;
  --p1: #c0392b;   /* Vuurtoren (red) */
  --p1-dark: #7a1f15;
  --p2: #2e8b57;   /* Diepzee (green) */
  --p2-dark: #1a5535;
  --p3: #2b6cb0;   /* Oceaan (blue) */
  --p3-dark: #173d66;

  --shadow-soft: 0 4px 14px rgba(10, 25, 47, 0.25);
  --shadow-deep: 0 10px 30px rgba(10, 25, 47, 0.45);
  --inset-deep: inset 0 2px 6px rgba(0, 0, 0, 0.35);

  --font-display: 'Pirata One', 'Cinzel', serif;
  --font-heading: 'Cinzel', serif;
  --font-body: 'EB Garamond', Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 30%, rgba(41, 120, 160, 0.4) 0%, transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(21, 70, 115, 0.6) 0%, transparent 60%),
    linear-gradient(180deg, #0a2540 0%, #061a30 100%);
  overflow-x: hidden;
  min-height: 100vh;
}

/* Wave background pattern */
.waves-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.08;
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 40px,
      rgba(255, 255, 255, 0.25) 40px,
      rgba(255, 255, 255, 0.25) 41px,
      transparent 41px,
      transparent 80px
    );
}

/* ============================================================
   SCREENS
   ============================================================ */

.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
  padding: 24px;
  align-items: center;
  justify-content: center;
}

.screen.active {
  display: flex;
}

#screen-game.active {
  align-items: stretch;
  padding: 0;
}

/* ============================================================
   MENU CARDS (parchment style)
   ============================================================ */

.menu-card {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.3) 0%, transparent 50%),
    linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 3px solid var(--wood-mid);
  border-radius: 16px;
  padding: 36px 40px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-deep), inset 0 0 60px rgba(180, 140, 70, 0.15);
  text-align: center;
  position: relative;
}

.menu-card::before,
.menu-card::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--brass);
  border-radius: 50%;
  background: var(--wood-dark);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
.menu-card::before { top: 12px; left: 12px; }
.menu-card::after { top: 12px; right: 12px; }

.lobby-card {
  max-width: 560px;
}

.emblem {
  font-size: 56px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.title {
  font-family: var(--font-display);
  font-size: 48px;
  margin: 0 0 8px;
  color: var(--ink);
  letter-spacing: 1px;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.subtitle {
  font-style: italic;
  font-size: 18px;
  color: var(--wood-dark);
  margin: 0 0 28px;
}

.hint {
  font-size: 14px;
  font-style: italic;
  color: var(--wood-dark);
  margin-top: 16px;
  opacity: 0.85;
}

.error {
  color: #b03030;
  font-weight: 600;
  margin-top: 12px;
  min-height: 1.2em;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 22px;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  border: 2px solid var(--wood-dark);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-mid) 100%);
  color: var(--sail);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  text-align: left;
  width: 100%;
  margin-bottom: 12px;
  font-family: var(--font-body);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-deep), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #2978a0 0%, #154673 100%);
  border-color: #0a2540;
}

.btn-secondary {
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dark) 100%);
  border-color: var(--wood-dark);
}

.btn-tertiary {
  background: linear-gradient(180deg, var(--wood-light) 0%, var(--wood-dark) 100%);
}

.btn-link {
  background: transparent;
  color: var(--wood-dark);
  border: none;
  box-shadow: none;
  text-shadow: none;
  font-style: italic;
}

.btn-link:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.05);
  transform: none;
  box-shadow: none;
}

.btn-small {
  padding: 8px 14px;
  font-size: 14px;
  width: auto;
  margin: 4px;
}

.btn-icon-only {
  padding: 8px 12px;
  font-size: 18px;
  width: auto;
  margin: 0 4px;
  background: var(--sea-mid);
  border-color: var(--sea-deep);
}

.btn-icon {
  font-size: 28px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.btn-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.btn-text strong {
  font-size: 18px;
  font-family: var(--font-heading);
  letter-spacing: 0.5px;
}

.btn-text small {
  font-size: 13px;
  font-weight: 400;
  opacity: 0.9;
  font-style: italic;
}

/* ============================================================
   FORMS
   ============================================================ */

.join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.join-form input[type="text"] {
  padding: 14px 16px;
  font-size: 18px;
  font-family: var(--font-body);
  border: 2px solid var(--wood-mid);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

.join-form input[type="text"]:focus {
  outline: none;
  border-color: var(--sea-mid);
  background: rgba(255, 255, 255, 0.85);
}

#join-code {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 600;
  font-size: 22px;
}

.local-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.local-row input {
  flex: 1;
}

.color-dot {
  display: inline-block;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--wood-dark);
  box-shadow: inset 0 -3px 6px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Segmented control for picking number of humans */
.seat-picker {
  background: rgba(255, 255, 255, 0.35);
  border: 2px dashed var(--wood-mid);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  text-align: center;
}
.seat-picker label {
  display: block;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--wood-dark);
  margin-bottom: 8px;
}
.segmented {
  display: inline-flex;
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}
.segmented button {
  background: linear-gradient(180deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: none;
  border-right: 1px solid var(--wood-mid);
  padding: 10px 18px;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s;
}
.segmented button:last-child { border-right: none; }
.segmented button:hover { background: linear-gradient(180deg, #fffaf0 0%, var(--parchment) 100%); }
.segmented button.active {
  background: linear-gradient(180deg, var(--sea-light) 0%, var(--sea-deep) 100%);
  color: var(--sail);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.picker-hint {
  display: block;
  margin-top: 8px;
  font-style: italic;
  font-size: 13px;
  color: var(--wood-dark);
  opacity: 0.85;
}
.local-row.bot-seat input {
  display: none;
}
.local-row.bot-seat::after {
  content: '🤖 Bot';
  flex: 1;
  font-style: italic;
  color: var(--wood-dark);
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 8px;
  font-size: 15px;
}

/* Lobby seat actions */
.player-row.empty-seat {
  cursor: pointer;
  transition: background 0.15s;
}
.player-row.empty-seat:hover {
  background: rgba(255, 255, 255, 0.55);
}
.seat-action {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--sea-mid);
  color: var(--sail);
  border: 1px solid var(--sea-deep);
  cursor: pointer;
  font-family: var(--font-body);
  margin-left: 4px;
}
.seat-action:hover { background: var(--sea-deep); }
.color-dot[data-color="yellow"] { background: radial-gradient(circle at 30% 30%, #ffd700, var(--p0-dark)); }
.color-dot[data-color="red"]    { background: radial-gradient(circle at 30% 30%, #e74c3c, var(--p1-dark)); }
.color-dot[data-color="green"]  { background: radial-gradient(circle at 30% 30%, #3eb371, var(--p2-dark)); }
.color-dot[data-color="blue"]   { background: radial-gradient(circle at 30% 30%, #3a8fd6, var(--p3-dark)); }

/* ============================================================
   LOBBY
   ============================================================ */

.room-code-box {
  background: rgba(255, 255, 255, 0.4);
  border: 2px dashed var(--wood-mid);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
}

.room-code-box label {
  display: block;
  font-size: 14px;
  font-style: italic;
  color: var(--wood-dark);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.room-code {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--ink);
  margin: 8px 0;
  text-shadow: 1px 1px 0 rgba(255, 255, 255, 0.5);
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 20px 0;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  border: 2px solid var(--wood-mid);
}

.player-row .player-name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  font-size: 16px;
}

.player-row .player-role {
  font-size: 13px;
  color: var(--wood-dark);
  font-style: italic;
}

.lobby-controls {
  display: none;
}

.lobby-controls.show {
  display: block;
}

#lobby-waiting {
  display: none;
}

#lobby-waiting.show {
  display: block;
}

/* ============================================================
   GAME LAYOUT
   ============================================================ */

.game-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 10px 20px;
  background: linear-gradient(180deg, var(--wood-dark) 0%, var(--ink) 100%);
  color: var(--sail);
  border-bottom: 3px solid var(--brass);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
}

.header-left {
  text-align: left;
}

.header-right {
  text-align: right;
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.logo-mini {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--brass);
  letter-spacing: 1px;
}

.turn-indicator {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 600;
  padding: 8px 18px;
  background: var(--sea-deep);
  border: 2px solid var(--brass);
  border-radius: 20px;
  white-space: nowrap;
}

.round-info {
  font-style: italic;
  font-size: 14px;
  opacity: 0.85;
  margin-right: 8px;
}

.game-main {
  display: grid;
  grid-template-columns: minmax(160px, 200px) 1fr minmax(160px, 200px);
  gap: 8px;
  padding: 8px;
  overflow: hidden;
  min-height: 0;
}

.board-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
  position: relative;
}

#board-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  min-width: 0;
}

#board-container svg {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 1 / 1;
}

#board-container svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Player panels */
.player-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px;
  overflow-y: auto;
}

.opponent-card {
  background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 2px solid var(--wood-dark);
  border-radius: 10px;
  padding: 10px;
  box-shadow: var(--shadow-soft);
  position: relative;
}

.opponent-card.active {
  border-color: var(--brass);
  box-shadow: 0 0 18px var(--brass);
}

.opponent-card .name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 15px;
}

.opponent-card .name-row .color-dot {
  width: 18px;
  height: 18px;
}

.opponent-card .cards-back {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
}

.card-back {
  width: 22px;
  height: 30px;
  background: linear-gradient(135deg, var(--sea-mid) 0%, var(--sea-deep) 100%);
  border: 1px solid var(--brass);
  border-radius: 3px;
  position: relative;
}

.card-back::after {
  content: '⚓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--brass);
}

.opponent-card .status {
  font-size: 12px;
  font-style: italic;
  color: var(--wood-dark);
  margin-top: 6px;
}

.team-badge {
  display: inline-block;
  font-size: 11px;
  background: var(--sea-deep);
  color: var(--sail);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  letter-spacing: 1px;
}

/* ============================================================
   FOOTER — my hand
   ============================================================ */

.game-footer {
  background: linear-gradient(180deg, var(--ink) 0%, var(--wood-dark) 100%);
  border-top: 3px solid var(--brass);
  padding: 10px 16px;
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.5);
}

.my-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.my-hand {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  justify-content: center;
  min-height: 110px;
  flex-wrap: wrap;
}

.card {
  width: 72px;
  height: 100px;
  background: linear-gradient(135deg, #fffaf0 0%, #f4e7c8 100%);
  border: 2px solid var(--wood-dark);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--shadow-soft);
  font-family: var(--font-heading);
  user-select: none;
}

.card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.card.selected {
  transform: translateY(-14px);
  border-color: var(--brass);
  box-shadow: 0 0 18px var(--brass), 0 8px 18px rgba(0,0,0,0.4);
}

.card:hover:not(.disabled):not(.selected) {
  transform: translateY(-6px);
  box-shadow: var(--shadow-deep);
}

.card .rank-top, .card .rank-bottom {
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  width: 100%;
  text-align: left;
  padding-left: 4px;
}

.card .rank-bottom {
  transform: rotate(180deg);
  text-align: left;
}

.card .suit-center {
  font-size: 32px;
}

.card.red {
  color: #b03030;
}

.card.black {
  color: #1a1a1a;
}

.my-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  min-height: 52px;            /* reserve space so layout doesn't jump when buttons appear */
}

.my-actions .btn {
  width: auto;
  margin-bottom: 0;
  padding: 10px 22px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-action-confirm {
  background: linear-gradient(180deg, #2ea760 0%, #155a32 100%);
  border-color: #0c3a20;
}

.btn-action-cancel {
  background: linear-gradient(180deg, var(--wood-mid) 0%, var(--wood-dark) 100%);
  border-color: var(--wood-dark);
}

.btn-action-pass {
  background: linear-gradient(180deg, var(--brass) 0%, var(--brass-dark) 100%);
  border-color: var(--wood-dark);
}

.action-hint {
  font-style: italic;
  color: var(--sail);
  padding: 8px 12px;
  font-size: 14px;
}

/* Preview ghost boat at intended destination */
.piece.preview-ghost {
  opacity: 0.55;
  filter: drop-shadow(0 0 6px gold) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  animation: ghostPulse 1.1s ease-in-out infinite;
}
@keyframes ghostPulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.75; }
}

/* Smooth board rotation when viewing seat changes — applied via CSS transform only */

/* ============================================================
   BOARD SVG
   ============================================================ */

.board-svg {
  background:
    radial-gradient(circle at 50% 50%, var(--parchment) 0%, var(--parchment-dark) 80%, var(--wood-mid) 100%);
  border-radius: 16px;
  box-shadow: var(--shadow-deep), inset 0 0 100px rgba(139, 111, 71, 0.4);
  border: 6px solid var(--wood-dark);
}

.cell-bg {
  fill: var(--sail);
  stroke: var(--wood-dark);
  stroke-width: 1.5;
}

.cell-start-p0 { fill: var(--p0); }
.cell-start-p1 { fill: var(--p1); }
.cell-start-p2 { fill: var(--p2); }
.cell-start-p3 { fill: var(--p3); }

.cell-home-p0 { fill: var(--p0); fill-opacity: 0.30; stroke: var(--p0-dark); stroke-width: 2; }
.cell-home-p1 { fill: var(--p1); fill-opacity: 0.30; stroke: var(--p1-dark); stroke-width: 2; }
.cell-home-p2 { fill: var(--p2); fill-opacity: 0.30; stroke: var(--p2-dark); stroke-width: 2; }
.cell-home-p3 { fill: var(--p3); fill-opacity: 0.30; stroke: var(--p3-dark); stroke-width: 2; }

.cell-kennel-p0 { fill: var(--p0); fill-opacity: 0.30; stroke: var(--p0-dark); stroke-width: 2.5; stroke-dasharray: 3 2; }
.cell-kennel-p1 { fill: var(--p1); fill-opacity: 0.30; stroke: var(--p1-dark); stroke-width: 2.5; stroke-dasharray: 3 2; }
.cell-kennel-p2 { fill: var(--p2); fill-opacity: 0.30; stroke: var(--p2-dark); stroke-width: 2.5; stroke-dasharray: 3 2; }
.cell-kennel-p3 { fill: var(--p3); fill-opacity: 0.30; stroke: var(--p3-dark); stroke-width: 2.5; stroke-dasharray: 3 2; }

.cell-target {
  fill: #fff4a0 !important;
  stroke: var(--brass) !important;
  stroke-width: 3 !important;
  cursor: pointer;
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.cell-selectable {
  cursor: pointer;
  stroke: var(--brass) !important;
  stroke-width: 3 !important;
}

.piece {
  cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.piece.selectable {
  filter: drop-shadow(0 0 6px gold) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
  cursor: pointer;
}

.piece.selectable:hover {
  filter: drop-shadow(0 0 10px gold) drop-shadow(0 2px 3px rgba(0, 0, 0, 0.4));
}

.piece.selected {
  filter: drop-shadow(0 0 12px white) drop-shadow(0 0 6px gold);
}

.piece-body-p0 { fill: radial-gradient(circle at 30% 30%, #ffe770, var(--p0-dark)); }

.board-label {
  font-family: var(--font-display);
  font-size: 16px;
  fill: var(--wood-dark);
  text-anchor: middle;
  font-weight: 700;
  letter-spacing: 2px;
}

.compass-rose {
  opacity: 0.25;
  pointer-events: none;
}

/* ============================================================
   MESSAGE BOX
   ============================================================ */

.message-box {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--sail);
  padding: 12px 24px;
  border: 2px solid var(--brass);
  border-radius: 8px;
  font-size: 16px;
  font-family: var(--font-heading);
  box-shadow: var(--shadow-deep);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  max-width: 80%;
  text-align: center;
}

.message-box.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* ============================================================
   MODALS
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 47, 0.85);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-card {
  background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border: 3px solid var(--wood-dark);
  border-radius: 14px;
  max-width: 560px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 32px;
  position: relative;
  box-shadow: var(--shadow-deep);
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  color: var(--wood-dark);
  line-height: 1;
}

.modal-card h2 {
  font-family: var(--font-display);
  font-size: 32px;
  margin: 0 0 16px;
  text-align: center;
  color: var(--ink);
}

.modal-card h3 {
  font-family: var(--font-heading);
  font-size: 18px;
  margin: 18px 0 6px;
  color: var(--wood-dark);
  border-bottom: 1px solid var(--wood-mid);
  padding-bottom: 4px;
}

.modal-card p, .modal-card li {
  font-size: 16px;
  line-height: 1.5;
}

.modal-card ul {
  padding-left: 22px;
  margin: 6px 0;
}

.win-card {
  text-align: center;
}

.win-emblem {
  font-size: 72px;
  margin-bottom: 8px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Phone-sized: stack opponent panels above the board */
@media (max-width: 760px) {
  .game-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 6px;
    min-height: 0;
  }
  .player-panel {
    flex: 0 0 auto;
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px;
    gap: 6px;
  }
  .player-panel-right { order: 0; }
  .player-panel-left  { order: 1; }
  .board-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    order: 2;
  }
  .opponent-card {
    min-width: 150px;
    flex: 0 0 auto;
    padding: 8px;
  }
  .opponent-card .name-row {
    font-size: 13px;
  }
  .card-back {
    width: 16px;
    height: 22px;
  }
}

/* Phone: compact header, smaller cards and SVG */
@media (max-width: 640px) {
  .game-header {
    grid-template-columns: auto 1fr auto;
    padding: 6px 8px;
    gap: 6px;
  }
  .logo-mini { font-size: 16px; }
  .turn-indicator { font-size: 14px; padding: 6px 12px; }
  .round-info { display: none; }

  .my-hand { gap: 5px; min-height: 88px; }
  .card {
    width: 52px;
    height: 74px;
    padding: 4px 2px;
  }
  .card .rank-top, .card .rank-bottom { font-size: 13px; padding-left: 2px; }
  .card .suit-center { font-size: 22px; }

  .game-footer { padding: 6px 8px; }
  .my-actions .btn { padding: 6px 12px; font-size: 14px; }
  .my-actions .btn .btn-text strong { font-size: 14px; }
  .my-actions .btn .btn-icon { font-size: 20px; }

  .opponent-card { min-width: 130px; padding: 6px; }
  .opponent-card .name-row { font-size: 12px; }
  .opponent-card .name-row .color-dot { width: 14px; height: 14px; }
  .opponent-card .status { font-size: 11px; margin-top: 3px; }

  .title { font-size: 32px; }
  .menu-card { padding: 22px 16px; }
  .room-code { font-size: 32px; letter-spacing: 6px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .card { width: 44px; height: 64px; }
  .card .suit-center { font-size: 18px; }
  .card .rank-top, .card .rank-bottom { font-size: 11px; }
  .opponent-card { min-width: 110px; }
  .turn-indicator { font-size: 12px; padding: 5px 9px; }
}

/* Large screens: keep board centered, cap board size */
@media (min-width: 1400px) {
  #board-container svg {
    max-width: min(75vh, 75vw, 900px);
    max-height: min(75vh, 75vw, 900px);
  }
}
