:root {
  color-scheme: light;
  --ink: #19201d;
  --muted: #5c6862;
  --page: #f6f1e7;
  --panel: #fffdf8;
  --card: #fffaf0;
  --line: #d9d2c4;
  --accent: #0f766e;
  --accent-dark: #0a5751;
  --accent-soft: #d9f1ec;
  --danger: #a33b56;
  --gold: #f4b942;
  --shadow: 0 14px 40px rgba(25, 32, 29, 0.14);
  --card-area-width: 75%;
}

body[data-theme="midnight"] {
  color-scheme: dark;
  --ink: #f5f7fb;
  --muted: #b6bfcc;
  --page: #10141f;
  --panel: #171d2a;
  --card: #202838;
  --line: #364054;
  --accent: #65d6ad;
  --accent-dark: #8ee7c7;
  --accent-soft: #183a33;
  --danger: #ff8fab;
  --gold: #ffd166;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

body[data-theme="arcade-dark"] {
  color-scheme: dark;
  --ink: #f8fbff;
  --muted: #b8c1d9;
  --page: #11111f;
  --panel: #1b1b2f;
  --card: #24233f;
  --line: #45456b;
  --accent: #37d5ff;
  --accent-dark: #a5f3ff;
  --accent-soft: #14384a;
  --danger: #ff6b9d;
  --gold: #f9d65c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.38);
}

body[data-theme="sakura"] {
  --ink: #2f2027;
  --muted: #765d67;
  --page: #fff5f7;
  --panel: #fffefe;
  --card: #fff8fb;
  --line: #ead1d9;
  --accent: #c2415d;
  --accent-dark: #8f2e43;
  --accent-soft: #ffe4eb;
  --danger: #9f1239;
  --gold: #d99a20;
  --shadow: 0 14px 40px rgba(95, 38, 57, 0.16);
}

body[data-theme="poolside"] {
  --ink: #15333a;
  --muted: #55737a;
  --page: #eaf7f6;
  --panel: #ffffff;
  --card: #f7ffff;
  --line: #afd7d3;
  --accent: #087f8c;
  --accent-dark: #075b64;
  --accent-soft: #d3f0ed;
  --danger: #c4455a;
  --gold: #ffca58;
  --shadow: 0 14px 40px rgba(21, 73, 78, 0.16);
}

body[data-theme="confetti"] {
  --ink: #1b2440;
  --muted: #596582;
  --page: #f3f5ff;
  --panel: #ffffff;
  --card: #fffefe;
  --line: #ccd3ee;
  --accent: #3f51b5;
  --accent-dark: #283593;
  --accent-soft: #e3e8ff;
  --danger: #d83a5f;
  --gold: #f2c14e;
  --shadow: 0 14px 40px rgba(45, 61, 128, 0.16);
}

body[data-theme="newsprint"] {
  --ink: #171717;
  --muted: #60605c;
  --page: #f1f1ee;
  --panel: #ffffff;
  --card: #fafaf8;
  --line: #c9c9c4;
  --accent: #c62828;
  --accent-dark: #8e1b1b;
  --accent-soft: #f8dddd;
  --danger: #8b1e3f;
  --gold: #d4a017;
  --shadow: 0 14px 36px rgba(23, 23, 23, 0.14);
}

body[data-theme="after-hours"] {
  color-scheme: dark;
  --ink: #f7f4f2;
  --muted: #c2b8b3;
  --page: #141414;
  --panel: #1f1f1f;
  --card: #292929;
  --line: #48423f;
  --accent: #ff8066;
  --accent-dark: #ffad9c;
  --accent-soft: #3b2522;
  --danger: #ff6f91;
  --gold: #ffd166;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
}

body[data-theme="electric"] {
  color-scheme: dark;
  --ink: #f4f9f6;
  --muted: #b8c6be;
  --page: #0d1110;
  --panel: #171b19;
  --card: #222725;
  --line: #3d4742;
  --accent: #b8f34a;
  --accent-dark: #d6ff8b;
  --accent-soft: #29371c;
  --danger: #ff5c8a;
  --gold: #64d8ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

body[data-theme="evergreen"] {
  color-scheme: dark;
  --ink: #f2f8f5;
  --muted: #b2c8bf;
  --page: #10201b;
  --panel: #173029;
  --card: #1e3a31;
  --line: #3c6255;
  --accent: #63d49a;
  --accent-dark: #95e8b9;
  --accent-soft: #1e4937;
  --danger: #ff8294;
  --gold: #f4c95d;
  --shadow: 0 18px 50px rgba(2, 12, 9, 0.4);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent-soft), transparent 35%), transparent 34rem),
    linear-gradient(180deg, var(--page) 0%, color-mix(in srgb, var(--page), var(--accent-soft) 24%) 100%);
  color: var(--ink);
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

button,
select {
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.7rem 0.95rem;
  cursor: pointer;
  font-weight: 700;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 68%);
  outline-offset: 2px;
}

input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--panel);
  color: var(--ink);
}

.app-shell {
  width: 100%;
  margin: 0;
  padding: clamp(1rem, 2vw, 2rem);
}

.home {
  display: grid;
  grid-template-columns: minmax(260px, 0.85fr) minmax(240px, 0.5fr) minmax(240px, 0.5fr);
  gap: 1rem;
  align-items: start;
  max-width: 1180px;
  margin: 0 auto;
  padding-top: clamp(1rem, 6vh, 4rem);
}

.home-hub {
  display: grid;
  gap: 1.25rem;
  max-width: 1480px;
  margin: 0 auto;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: end;
  min-height: 220px;
  padding: clamp(1rem, 4vw, 2rem);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.identity-block h1 {
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 0.95;
}

.identity-block p:last-child {
  max-width: 52rem;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.55;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 0.75rem;
}

.hero-action {
  min-height: 64px;
  font-size: 1.05rem;
}

.rooms-section {
  display: grid;
  gap: 1rem;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.85rem;
}

.room-card,
.empty-rooms {
  display: grid;
  gap: 0.85rem;
  min-height: 220px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.room-card h3 {
  margin: 0;
  font-size: 1.7rem;
  letter-spacing: 0.08em;
}

.room-card dl {
  display: grid;
  gap: 0.5rem;
  margin: 0;
}

.room-card dl div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.room-card dt {
  color: var(--muted);
  font-weight: 700;
}

.room-card dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}

.empty-rooms {
  grid-column: 1 / -1;
  min-height: 160px;
  align-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-rooms h3 {
  margin: 0;
  color: var(--ink);
}

.load-more {
  justify-self: center;
  min-width: 220px;
}

.rooms-sentinel {
  min-height: 1px;
}

.home-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.36);
}

.home-modal {
  width: min(560px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.modal-form {
  display: grid;
  gap: 0.8rem;
}

.modal-form input[type="range"] {
  min-height: 28px;
  accent-color: var(--accent);
}

.deck-builder {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.deck-builder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid var(--line);
}

.deck-builder-title {
  font-weight: 800;
}

.deck-builder-actions {
  display: flex;
  gap: 0.4rem;
}

.deck-builder-actions button {
  min-height: 34px;
  padding: 0.35rem 0.55rem;
  font-size: 0.82rem;
}

.deck-badges {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.75rem;
}

.deck-badge {
  display: grid;
  align-content: center;
  min-width: 0;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.55rem 0.65rem;
  background: var(--page);
  cursor: pointer;
}

.deck-badge:hover {
  border-color: var(--accent);
}

.deck-badge:has(input:focus-visible) {
  outline: 3px solid color-mix(in srgb, var(--accent), transparent 68%);
  outline-offset: 2px;
}

.deck-badge:has(input:checked) {
  border-color: var(--accent-dark);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.deck-badge span {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.deck-badge small {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.deck-summary {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 0.6rem 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
}

.intro {
  padding: clamp(1rem, 4vw, 2rem) 0;
}

.intro h1,
.topbar h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

.compact-title h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.6rem);
}

.intro p {
  max-width: 42rem;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 800;
}

.panel,
.scoreboard,
.result,
.modal,
.theme-sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.stack,
.theme-sidebar {
  display: grid;
  gap: 0.7rem;
}

.stack h2,
.panel h2,
.scoreboard h2 {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

body[data-theme="midnight"] .primary,
body[data-theme="arcade-dark"] .primary,
body[data-theme="after-hours"] .primary,
body[data-theme="electric"] .primary,
body[data-theme="evergreen"] .primary {
  color: #06110f;
}

.primary:not(:disabled):hover {
  background: var(--accent-dark);
}

.code-input,
.room-code {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.room-code {
  margin: 0;
  display: inline-flex;
  min-width: 10ch;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  background: var(--accent-soft);
  font-size: clamp(1.15rem, 2vw, 1.7rem);
  font-weight: 900;
  line-height: 1;
}

.room-code.masked {
  letter-spacing: 0.2em;
  align-items: center;
  padding-top: 0.42rem;
  padding-bottom: 0.08rem;
}

.screen {
  display: grid;
  gap: 1rem;
}

.site-footer {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 1.25rem 1rem 5rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.site-footer a {
  color: var(--accent-dark);
  font-weight: 800;
}

.license-page {
  width: min(820px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.license-page > header {
  margin-bottom: 1rem;
}

.license-page > header h1 {
  margin: 0;
}

.license-content {
  padding: clamp(1rem, 4vw, 2rem);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.license-content h2 {
  margin: 1.8rem 0 0.5rem;
  font-size: 1.2rem;
}

.license-content h2:first-child {
  margin-top: 0;
}

.license-content p,
.license-content li {
  line-height: 1.65;
}

.license-content a,
.license-back {
  color: var(--accent-dark);
  font-weight: 800;
}

.license-back {
  display: inline-block;
  margin-top: 1rem;
}

.play-layout {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  align-items: start;
}

.play-layout.scoreboard-right {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
}

.play-layout.scoreboard-right .scoreboard {
  order: 2;
}

.play-main {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.scoreboard-collapsed {
  grid-template-columns: minmax(0, 1fr);
}

.scoreboard-collapsed .scoreboard ol {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.lobby-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.code-cluster {
  display: contents;
}

.game-code-label {
  color: var(--muted);
  font-weight: 900;
}

.compact-actions {
  justify-content: flex-end;
}

.compact-actions button {
  min-height: 38px;
  padding: 0.5rem 0.7rem;
}

.actions,
.section-title,
.score-head {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}

.score-head {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 0.25rem;
}

.score-head h2 {
  margin: 0;
}

.score-head button {
  align-self: center;
}

.hand-title {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.hand-title h2 {
  margin: 0;
}

.hand-panel {
  width: var(--card-area-width);
  margin-inline: auto;
}

.pick-badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  background: var(--gold);
  color: #241a05;
  font-weight: 900;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold), transparent 72%);
}

.player-list,
.scoreboard ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.player-list li,
.scoreboard li {
  min-height: 46px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.scoreboard li:first-child {
  border-top: 0;
}

.scoreboard li {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr);
  justify-content: stretch;
  align-items: stretch;
  gap: 0.45rem;
}

.player-score-line,
.player-meta-line {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-width: 0;
}

.player-score-line > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.player-score-line > strong,
.player-status {
  margin-left: auto;
  flex: 0 0 auto;
}

.player-meta-line {
  min-height: 30px;
}

.score-action {
  min-height: 30px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.player-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.status-submitted {
  background: color-mix(in srgb, var(--gold), var(--panel) 70%);
  color: var(--ink);
}

.status-judge {
  background: var(--ink);
  color: var(--panel);
}

.status-away {
  background: var(--line);
  color: var(--muted);
}

.scoreboard li.inactive {
  opacity: 0.7;
}

.scoreboard {
  position: sticky;
  top: 1rem;
}

.scoreboard li.leader {
  color: var(--accent-dark);
  font-weight: 900;
}

.crown {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.1rem;
  margin-right: 0.45rem;
  color: transparent;
  background: var(--gold);
  clip-path: polygon(0 100%, 0 40%, 18% 62%, 32% 12%, 50% 58%, 68% 12%, 82% 62%, 100% 40%, 100% 100%);
  vertical-align: -0.12rem;
}

.badge {
  display: inline-block;
  margin-left: 0.35rem;
  color: var(--danger);
  font-size: 0.8rem;
}

.muted {
  color: var(--muted);
}

.prompt-card {
  min-height: 210px;
  display: grid;
  align-content: space-between;
  padding: clamp(1rem, 4vw, 2rem);
  background: var(--ink);
  color: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.prompt-card.judge {
  background: color-mix(in srgb, var(--ink), var(--accent) 22%);
}

.prompt-card .eyebrow {
  color: var(--gold);
}

.prompt-card h2 {
  margin: 0.75rem 0;
  font-size: clamp(1.7rem, 5vw, 3.6rem);
  line-height: 1.05;
}

.round-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.round-tools span {
  margin-right: auto;
  color: var(--muted);
  font-weight: 700;
}

.round-tools strong {
  min-width: 3rem;
  text-align: center;
  color: var(--accent-dark);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 1rem;
  margin: 1.15rem 0;
}

.answer-card {
  position: relative;
  aspect-ratio: 3 / 2.1;
  min-height: 148px;
  text-align: left;
  align-items: start;
  padding: 1rem;
  background: var(--card);
  border: 2px solid var(--line);
  box-shadow: 0 8px 18px rgba(23, 32, 28, 0.08);
}

.answer-card.selected {
  border-color: var(--accent);
  transform: translateY(-4px);
}

.answer-card b {
  position: absolute;
  right: 0.6rem;
  bottom: 0.5rem;
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
}

.submission-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.submission {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.85rem;
  background: var(--card);
}

.answers-in-play {
  border-color: color-mix(in srgb, var(--accent), var(--line) 55%);
}

.answers-in-play .section-title {
  margin-bottom: 1rem;
}

.answers-in-play .section-title h2 {
  margin: 0;
}

.answer-count,
.own-answer-badge {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  min-height: 1.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.8rem;
  font-weight: 900;
}

.player-submissions .submission {
  min-height: 112px;
  padding: 1rem;
}

.player-submissions .submission.mine {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent), transparent 76%);
}

.own-answer-badge {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
}

.player-submissions .submission.mine p {
  padding-right: 3.5rem;
}

.submission.winner {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold), transparent 70%);
}

.status,
.notice {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
}

.notice {
  margin-bottom: 1rem;
}

.notice.error {
  background: color-mix(in srgb, var(--danger), white 86%);
  color: var(--danger);
}

.theme-tab {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 45;
  width: 54px;
  height: 54px;
  min-height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.theme-tab::before {
  content: "\2699";
  font-family: "Segoe UI Symbol", "Arial Unicode MS", system-ui, sans-serif;
  font-size: 1.75rem;
  line-height: 1;
}

.leave-fab {
  position: fixed;
  bottom: 1rem;
  right: 5rem;
  z-index: 45;
  width: 54px;
  height: 54px;
  min-height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  padding: 0;
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  box-shadow: var(--shadow);
}

.leave-fab svg {
  width: 1.8rem;
  height: 1.8rem;
  fill: currentColor;
}

body[data-theme="midnight"] .theme-tab,
body[data-theme="arcade-dark"] .theme-tab,
body[data-theme="after-hours"] .theme-tab,
body[data-theme="electric"] .theme-tab,
body[data-theme="evergreen"] .theme-tab {
  color: #06110f;
}

.theme-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 40;
  width: min(340px, 92vw);
  height: 100vh;
  border-radius: 8px 0 0 8px;
  transform: translateX(105%);
  transition: transform 180ms ease;
  align-content: start;
  overflow-y: auto;
}

.controls-open .theme-sidebar {
  transform: translateX(0);
}

.scrim,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.36);
  display: none;
}

.controls-open .scrim,
.modal-backdrop {
  display: block;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.control-range {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem 0;
}

.control-range label {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 800;
}

.control-range output {
  color: var(--accent-dark);
}

.control-range input[type="range"] {
  width: 100%;
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
}

.control-range small {
  color: var(--muted);
}

.palette-field {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  border: 0;
}

.palette-field legend {
  margin-bottom: 0.2rem;
  color: var(--ink);
  font-weight: 800;
}

.palette-choice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem;
  cursor: pointer;
}

.palette-choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent), transparent 76%);
}

.palette-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.palette-swatch {
  display: grid;
  grid-template-columns: 2.6rem 1.25rem;
  grid-template-rows: repeat(2, 1.25rem);
  gap: 0.24rem;
  width: 4.1rem;
}

.palette-swatch span,
.palette-swatch i,
.palette-swatch b {
  display: block;
  border: 1px solid color-mix(in srgb, #000, transparent 82%);
}

.palette-swatch span {
  grid-row: 1 / 3;
  border-radius: 6px 2px 2px 6px;
}

.palette-swatch i {
  border-radius: 2px 6px 2px 2px;
}

.palette-swatch b {
  border-radius: 2px 2px 6px 2px;
}

.palette-dojo-light .palette-swatch span { background: #0f766e; }
.palette-dojo-light .palette-swatch i { background: #fffdf8; }
.palette-dojo-light .palette-swatch b { background: #f4b942; }
.palette-midnight .palette-swatch span { background: #10141f; }
.palette-midnight .palette-swatch i { background: #65d6ad; }
.palette-midnight .palette-swatch b { background: #ffd166; }
.palette-arcade-dark .palette-swatch span { background: #11111f; }
.palette-arcade-dark .palette-swatch i { background: #37d5ff; }
.palette-arcade-dark .palette-swatch b { background: #ff6b9d; }
.palette-sakura .palette-swatch span { background: #c2415d; }
.palette-sakura .palette-swatch i { background: #fff8fb; }
.palette-sakura .palette-swatch b { background: #d99a20; }
.palette-poolside .palette-swatch span { background: #087f8c; }
.palette-poolside .palette-swatch i { background: #ffffff; }
.palette-poolside .palette-swatch b { background: #ffca58; }
.palette-confetti .palette-swatch span { background: #3f51b5; }
.palette-confetti .palette-swatch i { background: #fffefe; }
.palette-confetti .palette-swatch b { background: #d83a5f; }
.palette-newsprint .palette-swatch span { background: #c62828; }
.palette-newsprint .palette-swatch i { background: #fafaf8; }
.palette-newsprint .palette-swatch b { background: #171717; }
.palette-after-hours .palette-swatch span { background: #141414; }
.palette-after-hours .palette-swatch i { background: #ff8066; }
.palette-after-hours .palette-swatch b { background: #ffd166; }
.palette-electric .palette-swatch span { background: #0d1110; }
.palette-electric .palette-swatch i { background: #b8f34a; }
.palette-electric .palette-swatch b { background: #ff5c8a; }
.palette-evergreen .palette-swatch span { background: #10201b; }
.palette-evergreen .palette-swatch i { background: #63d49a; }
.palette-evergreen .palette-swatch b { background: #f4c95d; }

.modal-backdrop {
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal {
  width: min(440px, 100%);
}

.modal h2 {
  margin: 0 0 1rem;
}

.modal-prompt {
  margin: 1.1rem 0 1.35rem;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  font-size: 1.16rem;
  line-height: 1.7;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent), transparent 88%);
}

.modal-prompt mark {
  display: inline;
  padding: 0.16rem 0.42rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent), transparent 78%);
  color: var(--ink);
  font-weight: 900;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.modal .actions {
  padding-top: 0.35rem;
}

.winner-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.winner-splash section {
  position: relative;
  z-index: 2;
  min-width: min(520px, 88vw);
  padding: 2rem;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  animation: winner-pop 700ms ease both;
}

.winner-splash h2 {
  margin: 0;
  font-size: clamp(2rem, 8vw, 5rem);
  line-height: 1;
}

.victory-screen {
  position: relative;
  display: grid;
  min-height: calc(100vh - 7rem);
  place-items: center;
  overflow: hidden;
  isolation: isolate;
}

.victory-effects {
  position: absolute;
  z-index: 0;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.victory-card {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  padding: clamp(1.5rem, 4vw, 3rem);
  text-align: center;
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--panel), var(--gold) 8%), var(--panel));
  border: 1px solid color-mix(in srgb, var(--line), var(--gold) 35%);
  border-radius: 12px;
  box-shadow: var(--shadow);
  animation: winner-pop 700ms ease both;
}

.victory-card h1 {
  margin: 0;
  font-size: clamp(3rem, 10vw, 7rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.victory-score {
  margin: 1rem 0 1.5rem;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 800;
}

.victory-card .scoreboard {
  margin: 1.5rem auto;
  text-align: left;
}

.victory-card > .primary {
  min-width: min(240px, 100%);
}

.confetti {
  position: absolute;
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 45%, var(--gold) 46% 54%, transparent 55%),
    linear-gradient(0deg, transparent 45%, var(--accent) 46% 54%, transparent 55%),
    radial-gradient(circle, var(--danger) 0 10%, transparent 11% 100%);
  animation: confetti-burst 1200ms ease-out infinite;
}

.c1 { left: 20%; top: 32%; }
.c2 { right: 18%; top: 28%; animation-delay: 120ms; }
.c3 { left: 30%; bottom: 24%; animation-delay: 220ms; }
.c4 { right: 28%; bottom: 20%; animation-delay: 320ms; }

.victory-confetti {
  position: absolute;
  top: -12%;
  width: 0.7rem;
  height: 1.4rem;
  background: var(--accent);
  opacity: 0;
  animation: victory-confetti-fall 3.8s linear infinite;
}

.vc1 { left: 4%; background: var(--gold); animation-delay: -0.2s; }
.vc2 { left: 10%; background: var(--danger); animation-delay: -2.7s; }
.vc3 { left: 17%; animation-delay: -1.1s; }
.vc4 { left: 24%; background: var(--gold); animation-delay: -3.2s; }
.vc5 { left: 31%; background: var(--danger); animation-delay: -1.8s; }
.vc6 { left: 38%; animation-delay: -0.7s; }
.vc7 { left: 44%; background: var(--gold); animation-delay: -2.2s; }
.vc8 { left: 50%; background: var(--danger); animation-delay: -3.6s; }
.vc9 { left: 57%; animation-delay: -1.4s; }
.vc10 { left: 63%; background: var(--gold); animation-delay: -2.9s; }
.vc11 { left: 70%; background: var(--danger); animation-delay: -0.4s; }
.vc12 { left: 76%; animation-delay: -2s; }
.vc13 { left: 82%; background: var(--gold); animation-delay: -3.4s; }
.vc14 { left: 88%; background: var(--danger); animation-delay: -1.6s; }
.vc15 { left: 93%; animation-delay: -2.5s; }
.vc16 { left: 97%; background: var(--gold); animation-delay: -0.9s; }

@keyframes winner-pop {
  from { opacity: 0; transform: scale(0.82) translateY(24px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes confetti-burst {
  0% { opacity: 0; transform: scale(0.2) rotate(0deg); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: scale(1.6) rotate(180deg); }
}

@keyframes victory-confetti-fall {
  0% { opacity: 0; transform: translate3d(0, -10vh, 0) rotate(0deg); }
  10% { opacity: 1; }
  100% { opacity: 0.95; transform: translate3d(5vw, 115vh, 0) rotate(760deg); }
}

@media (prefers-reduced-motion: reduce) {
  .winner-splash section,
  .victory-card,
  .confetti,
  .victory-confetti {
    animation: none;
  }

  .victory-confetti {
    display: none;
  }
}

@media (max-width: 850px) {
  .home {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 1rem;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .home-actions {
    grid-template-columns: 1fr;
  }

  .play-layout,
  .play-layout.scoreboard-right {
    grid-template-columns: 1fr;
  }

  .play-layout .scoreboard {
    order: 2;
    position: static;
  }

  .scoreboard-collapsed .scoreboard {
    display: block;
  }

  .scoreboard-collapsed .scoreboard ol {
    display: none;
  }

  .topbar {
    display: grid;
  }

  .lobby-controls {
    justify-content: stretch;
  }

  .in-game-controls {
    justify-content: flex-start;
  }

  .room-code {
    flex: 1;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }

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

  .hand-panel {
    width: 100%;
  }
}

@media (max-width: 440px) {
  .app-shell {
    padding: 0.75rem;
  }

  .deck-builder-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .deck-builder-actions {
    width: 100%;
  }

  .deck-builder-actions button {
    flex: 1;
  }

  .deck-badges {
    grid-template-columns: 1fr;
  }

  .card-grid,
  .submission-list {
    grid-template-columns: 1fr;
  }

  .intro h1,
  .topbar h1 {
    font-size: 2rem;
  }
}
