:root {
  --ink: #f8edcf;
  --muted: #c8b995;
  --night: #0b1713;
  --forest: #142a21;
  --felt: #1d5d45;
  --stone: #58615b;
  --stone-dark: #2f3834;
  --gold: #e9bd55;
  --gold-light: #ffe7a1;
  --red: #b6333f;
  --blue: #315f96;
  --shadow: rgba(0, 0, 0, 0.36);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--night); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(233, 189, 85, 0.17), transparent 26rem),
    radial-gradient(circle at 88% 12%, rgba(49, 95, 150, 0.21), transparent 30rem),
    linear-gradient(145deg, #0a1612, #18382b 55%, #1d1714);
  font-family: Georgia, "Times New Roman", serif;
}

button, input, select { font: inherit; }
button { touch-action: manipulation; }
button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid #82ccff;
  outline-offset: 3px;
}

.quit-link {
  position: fixed;
  z-index: 30;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  border: 1px solid rgba(255, 231, 161, 0.45);
  border-radius: 999px;
  padding: 0.62rem 0.85rem;
  color: var(--gold-light);
  background: rgba(11, 23, 19, 0.91);
  box-shadow: 0 0.7rem 1.5rem var(--shadow);
  font: 800 0.72rem/1 Arial, sans-serif;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.game-shell {
  width: min(100%, 92rem);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0 1rem;
}

.eyebrow {
  color: var(--gold);
  font: 900 0.67rem/1.2 Arial, sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.title-lockup h1 {
  margin: 0.08rem 0 0;
  color: #fff8e6;
  font-size: clamp(2.6rem, 7vw, 5.4rem);
  line-height: 0.86;
  letter-spacing: -0.06em;
  text-shadow: 0 0.12em 0 #3b2118, 0 0.2em 0.3em var(--shadow);
}

.title-lockup h1 span { color: var(--gold); }
.title-lockup p { margin: 0.55rem 0 0; color: var(--muted); font-style: italic; }

.round-standard {
  display: grid;
  place-items: center;
  min-width: 5.5rem;
  border: 1px solid rgba(255, 231, 161, 0.38);
  border-radius: 0.4rem;
  padding: 0.55rem 0.8rem;
  background: rgba(10, 24, 19, 0.75);
  box-shadow: inset 0 0 0 0.25rem rgba(233, 189, 85, 0.06);
}

.round-standard span { color: var(--muted); font: 800 0.62rem Arial, sans-serif; text-transform: uppercase; }
.round-standard strong { color: var(--gold-light); font-size: 1.75rem; }

.opponent-court {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 18rem), 1fr));
  gap: 0.65rem;
  margin-bottom: 0.75rem;
}

.opponent-keep, .player-keep {
  position: relative;
  border: 1px solid rgba(255, 231, 161, 0.28);
  border-top: 0.45rem solid var(--stone);
  border-radius: 0.35rem;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255,255,255,0.03) 1px, transparent 1px),
    rgba(15, 33, 27, 0.86);
  background-size: 2.2rem 1.1rem;
  box-shadow: 0 0.8rem 1.6rem var(--shadow);
}

.opponent-keep::before, .player-keep::before {
  position: absolute;
  top: -0.75rem;
  left: 0.5rem;
  width: 0.9rem;
  height: 0.55rem;
  background: var(--stone);
  box-shadow: 1.45rem 0 var(--stone), 2.9rem 0 var(--stone), 4.35rem 0 var(--stone);
  content: "";
}

.opponent-keep { padding: 0.48rem; }
.opponent-keep.active { border-color: var(--gold); box-shadow: 0 0 0 0.2rem rgba(233, 189, 85, 0.14), 0 0.8rem 1.6rem var(--shadow); }

.opponent-keep header, .player-keep header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.opponent-keep header { margin-bottom: 0.35rem; }
.opponent-keep h3, .player-keep h2 { margin: 0; color: #fff8e6; }
.opponent-keep h3 { font-size: 0.9rem; }
.opponent-keep header span, .player-keep header strong { color: var(--gold); font: 800 0.68rem Arial, sans-serif; }

.mini-board, .board-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mini-board { gap: 0.2rem; }
.mini-card { aspect-ratio: 0.72; min-width: 0; }

.castle-table {
  position: relative;
  display: grid;
  gap: clamp(0.6rem, 1.5vw, 1rem);
  border: 0.7rem solid #70472b;
  border-radius: 0.65rem;
  padding: clamp(0.75rem, 2vw, 1.2rem);
  background:
    linear-gradient(115deg, transparent 0 38%, rgba(255,255,255,0.055) 43%, transparent 48%),
    radial-gradient(circle at center, #267154 0%, #123a2c 76%);
  background-size: 230% 100%, 100% 100%;
  box-shadow: inset 0 0 0 0.18rem rgba(255, 231, 161, 0.18), 0 1.6rem 3rem var(--shadow);
  animation: torchlight 14s linear infinite;
}

.turn-banner {
  justify-self: center;
  border: 1px solid rgba(255, 231, 161, 0.44);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  color: #291a0e;
  background: var(--gold);
  box-shadow: 0 0.45rem 1rem var(--shadow);
  font: 900 0.72rem Arial, sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.draw-court {
  display: grid;
  grid-template-columns: minmax(5.2rem, 8rem) minmax(10rem, 1fr) minmax(5.2rem, 8rem);
  gap: clamp(0.55rem, 2vw, 1.2rem);
  align-items: center;
  width: min(100%, 40rem);
  margin: 0 auto;
}

.pile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.pile:disabled { cursor: not-allowed; filter: grayscale(0.4); opacity: 0.55; }
.pile:not(:disabled):hover { transform: translateY(-0.2rem); }
.pile small { margin-top: 0.3rem; color: var(--muted); font: 800 0.62rem Arial, sans-serif; text-transform: uppercase; }
.pile strong { position: absolute; right: 0.1rem; bottom: 1.25rem; display: grid; place-items: center; min-width: 1.55rem; height: 1.55rem; border-radius: 50%; color: #291a0e; background: var(--gold); font: 900 0.72rem Arial, sans-serif; }

.castle-card-back, .card-face, .covered-card {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 0.72;
  overflow: hidden;
  border: 0.2rem solid #f8edcf;
  border-radius: 0.42rem;
  box-shadow: 0 0.45rem 0.8rem rgba(0,0,0,0.3);
}

.castle-card-back, .covered-card {
  background:
    linear-gradient(90deg, transparent 13%, rgba(255,255,255,0.18) 14% 21%, transparent 22% 78%, rgba(255,255,255,0.18) 79% 86%, transparent 87%),
    linear-gradient(0deg, #243d6f 0 38%, #38588d 39% 62%, #172d56 63% 100%);
}

.castle-card-back::after, .covered-card::after {
  position: absolute;
  inset: 0.38rem;
  border: 1px solid rgba(255, 231, 161, 0.5);
  border-radius: 0.24rem;
  content: "";
}

.castle-card-back b, .covered-card b { z-index: 1; color: var(--gold-light); font-size: clamp(1.35rem, 4vw, 2.4rem); text-shadow: 0 0.12rem 0 #182341; }

.active-card-well {
  display: grid;
  justify-items: center;
  min-width: 0;
  border: 1px dashed rgba(255, 231, 161, 0.38);
  border-radius: 0.5rem;
  padding: 0.45rem;
  background: rgba(8, 28, 21, 0.5);
}

.active-card-well > span { color: var(--gold); font: 900 0.63rem Arial, sans-serif; text-transform: uppercase; }
.active-card-well small { margin-top: 0.35rem; color: var(--ink); font: 700 0.68rem/1.25 Arial, sans-serif; text-align: center; }
.active-card { display: grid; place-items: center; width: min(4.7rem, 100%); min-height: 5.2rem; margin-top: 0.3rem; }
.active-card em { color: var(--muted); font-size: 0.8rem; text-align: center; }

.discard-pile > span { display: block; width: 100%; min-height: 5.2rem; }

.card-face {
  color: #1d1714;
  background: #fff9e8;
}

.card-face.just-revealed { animation: reveal-card 220ms ease both; }

.card-face.red { color: var(--red); }
.card-face.wild { color: #fff8e6; background: linear-gradient(145deg, #8c293e, #243d6f 52%, #1c593e); }
.card-face.dead { background: #d8d2c0; }
.card-face::after { position: absolute; right: -0.4rem; bottom: -0.55rem; color: currentColor; font-size: 2.8rem; opacity: 0.08; content: "♜"; }
.card-face .corner { position: absolute; z-index: 1; top: 0.22rem; left: 0.26rem; font: 900 clamp(0.55rem, 1.7vw, 0.8rem) Arial, sans-serif; }
.card-face .corner.bottom { top: auto; right: 0.26rem; bottom: 0.22rem; left: auto; transform: rotate(180deg); }
.card-face .rank { z-index: 1; font: 900 clamp(1.05rem, 4vw, 2rem) Arial, sans-serif; }
.card-face .suit { position: absolute; z-index: 1; bottom: 0.25rem; left: 0.28rem; font-size: 0.7rem; }

.player-keep { padding: clamp(0.55rem, 1.8vw, 1rem); }
.player-keep header { margin-bottom: 0.55rem; }
.player-keep header span { color: var(--muted); font: 800 0.61rem Arial, sans-serif; text-transform: uppercase; }
.player-keep h2 { font-size: 1.15rem; }

.board-grid { gap: clamp(0.28rem, 1.1vw, 0.7rem); width: min(100%, 48rem); margin: 0 auto; }
.board-slot { position: relative; min-width: 0; border: 0; padding: 0; color: inherit; background: transparent; }
.board-slot::before { position: absolute; z-index: 3; top: 0.24rem; left: 0.28rem; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; color: #2a1b0e; background: var(--gold); content: attr(data-position); font: 900 0.62rem Arial, sans-serif; box-shadow: 0 0.15rem 0.35rem var(--shadow); }
.board-slot.playable { cursor: pointer; animation: playable-pulse 1.25s ease-in-out infinite; }
.board-slot.playable .covered-card, .board-slot.playable .card-face { box-shadow: 0 0 0 0.22rem var(--gold), 0 0.65rem 1rem var(--shadow); }
.board-slot.inactive { visibility: hidden; }

.event-scroll {
  border-left: 0.22rem solid var(--gold);
  padding: 0.5rem 0.7rem;
  color: var(--ink);
  background: rgba(8, 28, 21, 0.58);
  font-size: 0.82rem;
  font-style: italic;
}

.event-scroll.error { border-color: #ff8585; color: #ffd4d4; background: rgba(91, 20, 27, 0.72); font-style: normal; font-weight: 800; }

body.game-running {
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.game-running .game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 7.5rem) minmax(0, 1fr);
  gap: 0.45rem;
  width: min(100%, 88rem);
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: 0.45rem;
}

.game-running .game-header { min-height: 0; padding: 0 6rem 0 0; }
.game-running .title-lockup { display: flex; align-items: baseline; gap: 0.7rem; }
.game-running .title-lockup .eyebrow, .game-running .title-lockup p { display: none; }
.game-running .title-lockup h1 { font-size: clamp(1.9rem, 4vh, 3rem); letter-spacing: -0.04em; }
.game-running .round-standard { min-width: 4rem; padding: 0.28rem 0.5rem; }
.game-running .round-standard strong { font-size: 1.15rem; }

.game-running .opponent-court {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  gap: 0.45rem;
  min-width: 0;
  min-height: 0;
  margin: 0;
  overflow: hidden;
}

.game-running[data-players="2"] .opponent-court { grid-template-columns: minmax(0, 28rem); justify-content: center; }
.game-running[data-players="3"] .opponent-court { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.game-running[data-players="4"] .opponent-court { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.game-running[data-players="5"] .opponent-court { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.game-running[data-players="6"] .opponent-court { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.game-running .opponent-keep { min-width: 0; min-height: 0; overflow: hidden; padding: 0.3rem; }
.game-running[data-players="5"] .game-shell,
.game-running[data-players="6"] .game-shell,
.game-running[data-players="7"] .game-shell,
.game-running[data-players="8"] .game-shell { grid-template-rows: auto minmax(0, 10rem) minmax(0, 1fr); }
.game-running .opponent-keep header { height: 1rem; margin-bottom: 0.18rem; }
.game-running .mini-board { grid-template-rows: repeat(2, minmax(0, 1fr)); height: calc(100% - 1.2rem); gap: 0.12rem; }
.game-running .mini-card { display: grid; place-items: center; height: 100%; min-height: 0; aspect-ratio: auto; overflow: hidden; }
.game-running .mini-card > .covered-card, .game-running .mini-card > .card-face { width: auto; height: 100%; max-width: 100%; border-width: 0.1rem; }
.game-running .mini-card .rank { font-size: clamp(0.42rem, 1.25vh, 0.72rem); }
.game-running .mini-card .corner { top: 0.08rem; left: 0.1rem; font-size: clamp(0.3rem, 0.85vh, 0.5rem); }
.game-running .mini-card .corner.bottom { right: 0.1rem; bottom: 0.08rem; left: auto; }
.game-running .mini-card .covered-card b { font-size: clamp(0.5rem, 1.5vh, 0.85rem); }

.game-running .castle-table {
  grid-template-rows: auto minmax(5.7rem, 0.75fr) minmax(0, 1.65fr) auto;
  gap: 0.3rem;
  min-height: 0;
  overflow: hidden;
  border-width: 0.35rem;
  padding: 0.4rem;
}

.game-running .turn-banner { padding: 0.28rem 0.65rem; font-size: 0.62rem; }
.game-running .draw-court { grid-template-columns: 5rem minmax(8rem, 1fr) 5rem; gap: 0.35rem; width: min(100%, 28rem); height: 100%; min-height: 0; }
.game-running .pile { height: 100%; min-height: 0; }
.game-running .pile > .castle-card-back, .game-running .discard-pile > #discardCard { width: auto; height: calc(100% - 1.1rem); min-height: 0; aspect-ratio: 0.72; }
.game-running .discard-pile > #discardCard { display: grid; place-items: center; }
.game-running .discard-pile > #discardCard .card-face { width: auto; height: 100%; }
.game-running .pile small { margin-top: 0.12rem; font-size: 0.52rem; }
.game-running .pile strong { right: -0.05rem; bottom: 0.85rem; min-width: 1.25rem; height: 1.25rem; font-size: 0.58rem; }
.game-running .active-card-well { height: 100%; min-height: 0; padding: 0.25rem; }
.game-running .active-card { width: auto; height: calc(100% - 2rem); min-height: 0; aspect-ratio: 0.72; margin-top: 0.12rem; }
.game-running .active-card .card-face { height: 100%; }
.game-running .active-card-well small { margin-top: 0.12rem; font-size: 0.57rem; }

.game-running .player-keep { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; padding: 0.35rem; }
.game-running .player-keep header { min-height: 1.35rem; margin-bottom: 0.22rem; }
.game-running .player-keep h2 { font-size: 0.9rem; }
.game-running .board-grid { grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 0.22rem; width: min(100%, 44rem); height: 100%; min-height: 0; }
.game-running .board-slot { display: grid; place-items: center; height: 100%; min-height: 0; overflow: hidden; }
.game-running .board-slot > .covered-card, .game-running .board-slot > .card-face { width: auto; height: 100%; max-width: 100%; border-width: 0.14rem; }
.game-running .board-slot::before { top: 0.12rem; left: max(0.12rem, calc(50% - 2.6rem)); width: 1rem; height: 1rem; font-size: 0.5rem; }
.game-running .event-scroll { overflow: hidden; padding: 0.3rem 0.5rem; font-size: 0.68rem; line-height: 1.2; text-overflow: ellipsis; white-space: nowrap; }

.modal-backdrop {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  overflow: auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1rem, env(safe-area-inset-bottom));
  background: rgba(5, 12, 10, 0.78);
  backdrop-filter: blur(10px);
}

.modal-backdrop.open { display: grid; }
.setup-panel, .result-panel { display: grid; gap: 0.8rem; width: min(100%, 34rem); border: 1px solid rgba(255,231,161,0.4); border-top: 0.55rem solid var(--stone); border-radius: 0.45rem; padding: clamp(1rem, 3vw, 1.5rem); background: #13271f; box-shadow: 0 2rem 5rem rgba(0,0,0,0.5); }
.crest { justify-self: center; display: grid; place-items: center; width: 3.5rem; aspect-ratio: 1; border: 0.18rem solid var(--gold); border-radius: 50%; color: var(--gold-light); background: #243d6f; font-size: 2rem; box-shadow: 0 0 0 0.3rem rgba(233,189,85,0.1); }
.setup-panel h2, .result-panel h2 { margin: 0; color: #fff8e6; font-size: clamp(2rem, 7vw, 3.2rem); line-height: 0.95; text-align: center; }
.setup-panel > p, .result-panel p { margin: 0; color: var(--muted); line-height: 1.45; text-align: center; }
.setup-panel > .eyebrow, .result-panel > .eyebrow { text-align: center; }
.field { display: grid; gap: 0.3rem; }
.account-identity { display: grid; gap: 0.2rem; border: 1px solid rgba(233,189,85,0.3); border-radius: 0.4rem; padding: 0.7rem; background: rgba(233,189,85,0.07); text-align: center; }
.account-identity span { color: var(--muted); font: 800 0.62rem Arial, sans-serif; text-transform: uppercase; }
.account-identity strong { color: var(--gold-light); }
.account-identity a { color: #9ed8ff; font: 800 0.75rem Arial, sans-serif; }
.multiplayer-lobby { display: grid; gap: 0.65rem; border: 1px solid rgba(126,199,255,0.26); border-radius: 0.45rem; padding: 0.75rem; background: rgba(36,61,111,0.16); }
.multiplayer-lobby > header { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; }
.multiplayer-lobby h3 { margin: 0.15rem 0 0; color: #fff8e6; font-size: 1rem; }
.multiplayer-lobby output { border-radius: 999px; padding: 0.28rem 0.5rem; color: var(--muted); background: rgba(255,255,255,0.08); font: 800 0.62rem Arial, sans-serif; text-transform: uppercase; }
.multiplayer-lobby output.connected { color: #92e8b3; }
.lobby-entry { display: grid; grid-template-columns: minmax(8rem,1fr) auto; gap: 0.45rem; align-items: end; }
.lobby-button, .room-actions button { min-height: 2.65rem; border: 1px solid rgba(255,231,161,0.32); border-radius: 0.35rem; padding: 0.55rem 0.75rem; color: var(--ink); background: rgba(255,255,255,0.1); font-weight: 800; cursor: pointer; }
.lobby-button:disabled, .room-actions button:disabled { cursor: not-allowed; opacity: 0.45; }
.lobby-code input { text-transform: uppercase; }
.lobby-room { display: grid; gap: 0.55rem; }
.lobby-room[hidden] { display: none; }
.room-code { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.room-code span { color: var(--muted); font: 800 0.62rem Arial, sans-serif; text-transform: uppercase; }
.room-code strong { color: var(--gold-light); font-size: 1.4rem; letter-spacing: 0.12em; }
.lobby-room ul { display: grid; gap: 0.3rem; margin: 0; padding: 0; list-style: none; }
.lobby-room li { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; border: 1px solid rgba(255,255,255,0.09); border-radius: 0.3rem; padding: 0.4rem 0.5rem; font: 700 0.75rem Arial, sans-serif; }
.lobby-room li span { color: var(--muted); }
.room-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.lobby-message { min-height: 1em; margin: 0; color: #ffb8b8; font: 700 0.7rem Arial, sans-serif; }
.setup-divider { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font: 700 0.62rem Arial, sans-serif; text-transform: uppercase; }
.setup-divider::before, .setup-divider::after { flex: 1; height: 1px; background: rgba(255,231,161,0.18); content: ""; }
.field > span, fieldset legend { color: var(--gold); font: 900 0.66rem Arial, sans-serif; letter-spacing: 0.08em; text-transform: uppercase; }
.field input, .field select { width: 100%; border: 1px solid rgba(255,231,161,0.27); border-radius: 0.35rem; padding: 0.72rem; color: var(--ink); background: #0b1b15; }
fieldset { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.4rem; margin: 0; border: 1px solid rgba(255,231,161,0.18); border-radius: 0.4rem; padding: 0.7rem; }
fieldset legend { padding: 0 0.35rem; }
.toggle { display: flex; gap: 0.45rem; align-items: center; min-width: 0; border: 1px solid rgba(255,255,255,0.08); border-radius: 0.35rem; padding: 0.55rem; background: rgba(255,255,255,0.035); font: 700 0.78rem Arial, sans-serif; }
.toggle.featured { grid-column: 1 / -1; border-color: rgba(233,189,85,0.36); background: rgba(233,189,85,0.08); }
.toggle input { width: 1.1rem; height: 1.1rem; accent-color: var(--gold); }
.toggle span { display: grid; gap: 0.15rem; min-width: 0; }
.toggle small { color: var(--muted); font-weight: 500; line-height: 1.3; }
.royal-button { min-height: 3.2rem; border: 1px solid var(--gold-light); border-radius: 0.4rem; color: #2a1b0e; background: var(--gold); box-shadow: 0 0.35rem 0 #8d6328, 0 0.8rem 1.5rem rgba(0,0,0,0.28); font-weight: 900; cursor: pointer; }
.royal-button:hover { filter: brightness(1.08); transform: translateY(-0.08rem); }
.text-button { border: 0; padding: 0.5rem; color: var(--muted); background: transparent; text-decoration: underline; cursor: pointer; }

@keyframes reveal-card { from { opacity: 0; transform: rotateY(70deg) scale(0.92); } to { opacity: 1; transform: rotateY(0) scale(1); } }
@keyframes playable-pulse { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-0.22rem); } }
@keyframes torchlight { from { background-position: 180% 0, 0 0; } to { background-position: -80% 0, 0 0; } }

@media (max-width: 680px) {
  .game-shell { padding: 0.5rem; }
  .game-header { padding-right: 5rem; }
  .title-lockup p { display: none; }
  .castle-table { border-width: 0.35rem; padding: 0.5rem; }
  .draw-court { grid-template-columns: 4.5rem minmax(7rem, 1fr) 4.5rem; gap: 0.35rem; }
  .active-card-well small { font-size: 0.58rem; }
  .board-grid { gap: 0.25rem; }
  .board-slot::before { top: 0.12rem; left: 0.14rem; width: 1rem; height: 1rem; font-size: 0.5rem; }
  .opponent-court { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .opponent-keep h3 { max-width: 5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .opponent-keep header span { font-size: 0.52rem; }
  fieldset { grid-template-columns: 1fr; }
  .toggle.featured { grid-column: auto; }
  .lobby-entry { grid-template-columns: 1fr; }
}

@media (max-width: 430px) {
  .quit-link { top: 0.35rem; right: 0.35rem; padding: 0.45rem 0.55rem; font-size: 0.56rem; }
  .round-standard { min-width: 3.6rem; padding: 0.35rem; }
  .round-standard strong { font-size: 1.25rem; }
  .opponent-keep { padding: 0.3rem; }
  .mini-board { gap: 0.1rem; }
  .player-keep { padding: 0.4rem; }
  .card-face .suit { display: none; }
}

@media (max-height: 600px) {
  .game-running .game-shell { grid-template-rows: auto minmax(0, 5rem) minmax(0, 1fr); }
  .game-running[data-players="5"] .game-shell,
  .game-running[data-players="6"] .game-shell,
  .game-running[data-players="7"] .game-shell,
  .game-running[data-players="8"] .game-shell { grid-template-rows: auto minmax(0, 6.5rem) minmax(0, 1fr); }
  .game-running .game-header { min-height: 1.8rem; }
  .game-running .title-lockup h1 { font-size: 1.55rem; }
  .game-running .castle-table { grid-template-rows: auto minmax(4.4rem, 0.7fr) minmax(0, 1.7fr) auto; }
  .game-running .active-card-well small { display: none; }
  .game-running .active-card { height: calc(100% - 1.1rem); }
  .game-running .opponent-keep h3 { font-size: 0.68rem; }
  .game-running .opponent-keep header span { font-size: 0.48rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
 .admin-debug-button{position:fixed;right:.7rem;bottom:.7rem;z-index:90;background:#7b2626;color:#fff3c4;border:1px solid #e6ba58;border-radius:999px;padding:.55rem .8rem;font-weight:900}.admin-debug-panel{z-index:100;width:min(25rem,calc(100% - 1rem));color:#f7e8bd;background:#17291f;border:1px solid #e6ba58;border-radius:.7rem}.admin-debug-panel::backdrop{background:#000a}.admin-debug-panel form{display:grid;gap:.65rem}.admin-debug-panel header{display:flex;justify-content:space-between;align-items:center}.admin-debug-panel label{display:grid;gap:.2rem}.admin-debug-panel input,.admin-debug-panel select{padding:.5rem;background:#09130e;color:#fff;border:1px solid #71805e}.admin-debug-panel div{display:flex;gap:.4rem;flex-wrap:wrap}.admin-debug-panel small{color:#f2c96b}
