:root {
  color-scheme: light;
  --page: #eef3fb;
  --page-pattern: rgba(11, 16, 32, 0.026);
  --surface: #ffffff;
  --surface-2: #e8eef8;
  --surface-strong: #d8e2f2;
  --text: #0b1020;
  --muted: #3c4861;
  --border: #697792;
  --accent: #006a75;
  --accent-ink: #ffffff;
  --accent-soft: #d7f4f7;
  --secondary: #98125e;
  --secondary-ink: #ffffff;
  --purple: #5e3abb;
  --warning: #765c00;
  --warning-bg: #fff4b8;
  --danger: #a81033;
  --danger-bg: #ffe4eb;
  --success: #176b3a;
  --success-bg: #dcf9e8;
  --focus: #b84900;
  --panel-border: rgba(70, 84, 112, 0.34);
  --panel-highlight: rgba(255, 255, 255, 0.92);
  --surface-translucent: rgba(255, 255, 255, 0.86);
  --header-bg: rgba(247, 249, 254, 0.9);
  --ambient-cyan: rgba(0, 166, 182, 0.13);
  --ambient-magenta: rgba(152, 18, 94, 0.09);
  --ambient-purple: rgba(94, 58, 187, 0.1);
  --shadow: 0 12px 30px rgba(11, 16, 32, 0.1), 0 2px 6px rgba(11, 16, 32, 0.08);
  --shadow-lift: 0 18px 44px rgba(11, 16, 32, 0.14), 0 4px 12px rgba(11, 16, 32, 0.09);
  --timer-bg: #111a31;
  --timer-text: #f4f7ff;
  --radius-large: 1.4rem;
  --radius: 1rem;
  --radius-small: 0.7rem;
  --max-width: 74rem;
  font-family: "Atkinson Hyperlegible", "Atkinson Hyperlegible Next", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 100%;
  line-height: 1.55;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1020;
  --page-pattern: rgba(61, 245, 255, 0.035);
  --surface: #151d32;
  --surface-2: #1c2742;
  --surface-strong: #293653;
  --text: #f4f7ff;
  --muted: #c5cee3;
  --border: #8491b0;
  --accent: #3df5ff;
  --accent-ink: #07111d;
  --accent-soft: #123c4b;
  --secondary: #ff78c5;
  --secondary-ink: #101225;
  --purple: #ad90ff;
  --warning: #ffe164;
  --warning-bg: #443900;
  --danger: #ff8ca7;
  --danger-bg: #4d1426;
  --success: #7ee2a7;
  --success-bg: #123d2a;
  --focus: #ffe45e;
  --panel-border: rgba(151, 169, 207, 0.25);
  --panel-highlight: rgba(255, 255, 255, 0.055);
  --surface-translucent: rgba(21, 29, 50, 0.88);
  --header-bg: rgba(11, 16, 32, 0.9);
  --ambient-cyan: rgba(61, 245, 255, 0.1);
  --ambient-magenta: rgba(255, 60, 172, 0.07);
  --ambient-purple: rgba(139, 92, 246, 0.1);
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.27), 0 3px 8px rgba(0, 0, 0, 0.22);
  --shadow-lift: 0 20px 52px rgba(0, 0, 0, 0.38), 0 5px 14px rgba(0, 0, 0, 0.25);
  --timer-bg: #090f20;
  --timer-text: #f4f7ff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 0;
  scroll-behavior: smooth;
}

body {
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  color: var(--text);
  background-color: var(--page);
  background-image:
    radial-gradient(circle at 8% -8%, var(--ambient-cyan), transparent 28rem),
    radial-gradient(circle at 96% 5%, var(--ambient-magenta), transparent 27rem),
    radial-gradient(circle at 70% 95%, var(--ambient-purple), transparent 34rem);
  font-size: 1.0625rem;
  isolation: isolate;
  overflow-wrap: anywhere;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background-image:
    linear-gradient(var(--page-pattern) 1px, transparent 1px),
    linear-gradient(90deg, var(--page-pattern) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, 0.55) 24rem, transparent 72rem);
  mask-image: linear-gradient(to bottom, #000 0, rgba(0, 0, 0, 0.55) 24rem, transparent 72rem);
  pointer-events: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input[type="range"],
input[type="radio"],
input[type="checkbox"] {
  cursor: pointer;
}

button:disabled,
select:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

a {
  color: var(--accent);
  font-weight: 720;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 0.18em;
}

:focus-visible {
  outline: 4px solid var(--focus) !important;
  outline-offset: 4px !important;
  box-shadow: none !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  top: max(0.75rem, env(safe-area-inset-top));
  left: 0.75rem;
  left: max(0.75rem, env(safe-area-inset-left));
  z-index: 1000;
  padding: 0.75rem 1rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 2px solid currentColor;
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-lift);
  font-weight: 800;
  transform: translateY(-180%);
}

.skip-link:focus {
  transform: translateY(0);
}

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

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--panel-border);
  background: var(--header-bg);
  box-shadow: 0 5px 24px rgba(11, 16, 32, 0.08);
  -webkit-backdrop-filter: blur(14px) saturate(125%);
  backdrop-filter: blur(14px) saturate(125%);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 2rem;
  width: min(100% - 2rem, var(--max-width));
  min-height: 4.7rem;
  margin-inline: auto;
  padding-block: 0.7rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  gap: 0.65rem;
  color: var(--text);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  background: linear-gradient(135deg, var(--accent), var(--purple) 56%, var(--secondary));
  border: 1px solid var(--panel-highlight);
  border-radius: 0.55rem 0.55rem 0.1rem 0.55rem;
  box-shadow: 0 5px 14px var(--ambient-purple);
  transform: rotate(-3deg);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  position: absolute;
  width: 0.38rem;
  height: 0.38rem;
  content: "";
  background: var(--accent-ink);
  border-radius: 1px;
}

.brand-mark::before {
  left: 0.55rem;
  top: 0.55rem;
}

.brand-mark::after {
  right: 0.55rem;
  top: 0.55rem;
}

.brand-mark span {
  bottom: 0.5rem;
  left: calc(50% - 0.19rem);
}

.brand-name {
  background: linear-gradient(100deg, var(--text) 25%, var(--accent) 125%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.6rem;
  min-width: 0;
}

.language-control {
  display: grid;
  grid-template-columns: auto minmax(8.75rem, 1fr);
  align-items: center;
  gap: 0.35rem 0.5rem;
  min-height: 44px;
  padding: 0.3rem 0.45rem;
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: 0.9rem;
}

.language-control label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.language-control select {
  width: auto;
  min-width: 0;
  min-height: 44px;
  padding-block: 0.45rem;
  background: var(--surface);
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  padding: 0.3rem;
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: 0.9rem;
  box-shadow: 0 3px 12px rgba(11, 16, 32, 0.07);
}

.control-group-label {
  padding-inline: 0.35rem 0.2rem;
  color: var(--muted);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.69rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding: 0.45rem 0.72rem;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0.65rem;
  font-size: 0.9rem;
  font-weight: 750;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.tool-button:hover:not(:disabled),
.tool-button:focus-visible:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.tool-button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.volume-control {
  display: grid;
  grid-template-columns: auto minmax(5rem, 8rem) auto;
  align-items: center;
  gap: 0.4rem;
  min-height: 44px;
  padding-inline: 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
}

.volume-control input {
  min-width: 0;
  height: 44px;
  accent-color: var(--accent);
}

.volume-control input::-webkit-slider-runnable-track {
  height: 0.35rem;
  background: var(--surface-strong);
  border-radius: 999px;
}

.volume-control input::-moz-range-track {
  height: 0.35rem;
  background: var(--surface-strong);
  border-radius: 999px;
}

.volume-control output {
  min-width: 3ch;
  font-variant-numeric: tabular-nums;
}

main {
  width: min(100% - 2rem, var(--max-width));
  min-height: calc(100vh - 10rem);
  min-height: calc(100dvh - 10rem);
  margin-inline: auto;
  padding-block: clamp(1.35rem, 3.5vw, 3rem);
}

main[data-screen="home"] {
  width: min(100% - 2rem, 78rem);
  padding-top: clamp(1rem, 2.8vw, 2rem);
}

main[data-screen="game"] {
  padding-top: clamp(1.25rem, 3vw, 2.4rem);
}

.site-footer {
  width: min(100% - 2rem, var(--max-width));
  margin-inline: auto;
  padding: 1.25rem 0 calc(1.25rem + env(safe-area-inset-bottom));
  color: var(--muted);
  border-top: 1px solid var(--panel-border);
  font-size: 0.96rem;
  text-align: center;
}

.site-footer p {
  margin-inline: auto;
}

.site-footer .copyright {
  margin-top: 0.4rem;
  margin-bottom: 0;
  font-size: 0.9rem;
}

h1,
h2,
h3 {
  line-height: 1.18;
  text-wrap: balance;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 7vw, 4.2rem);
  letter-spacing: -0.04em;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.4rem, 4vw, 2rem);
}

h3 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.15rem, 3.5vw, 1.4rem);
}

p {
  max-width: 70ch;
}

.eyebrow,
.hud-label {
  margin: 0 0 0.5rem;
  color: var(--secondary);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.105em;
  line-height: 1.3;
  text-transform: uppercase;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.eyebrow::before {
  width: 0.6rem;
  height: 0.6rem;
  content: "";
  background: currentColor;
  border-radius: 1px;
  box-shadow: 0.3rem -0.3rem 0 var(--purple);
}

.hud-label {
  color: var(--purple);
}

.lead {
  max-width: 62ch;
  margin-top: 0;
  color: var(--muted);
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
}

.home-hero {
  position: relative;
  isolation: isolate;
  padding: clamp(2.2rem, 6vw, 4.8rem) clamp(1rem, 4vw, 3rem) clamp(3.4rem, 8vw, 6rem);
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 18%, var(--ambient-cyan), transparent 18rem),
    radial-gradient(circle at 84% 28%, var(--ambient-magenta), transparent 19rem),
    linear-gradient(145deg, var(--surface-translucent), var(--surface));
  border: 1px solid var(--panel-border);
  border-radius: clamp(1.25rem, 3vw, 2rem);
  box-shadow: var(--shadow-lift);
  text-align: center;
}

.home-hero::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(135deg, var(--panel-highlight), transparent 27%),
    linear-gradient(315deg, var(--ambient-purple), transparent 38%);
  pointer-events: none;
}

.home-hero::after {
  position: absolute;
  right: -4rem;
  bottom: -7rem;
  z-index: -1;
  width: 18rem;
  height: 18rem;
  content: "";
  border: 1px solid var(--panel-border);
  border-radius: 50%;
  box-shadow: 0 0 0 2rem var(--ambient-purple), 0 0 0 4rem transparent, 0 0 0 4.1rem var(--panel-border);
  opacity: 0.62;
}

.hero-pixels {
  position: absolute;
  top: 1.3rem;
  right: clamp(1rem, 4vw, 3rem);
  width: 0.5rem;
  height: 0.5rem;
  background: var(--accent);
  border-radius: 1px;
  box-shadow:
    -1.3rem 0 var(--purple),
    -2.6rem 0 var(--secondary),
    0 1.3rem var(--secondary),
    -2.6rem 1.3rem var(--accent);
  opacity: 0.8;
}

.home-hero .lead {
  position: relative;
  z-index: 1;
  max-width: 48rem;
  margin-inline: auto;
}

.logo-line {
  position: relative;
  z-index: 1;
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  font-size: clamp(3rem, 10vw, 6.7rem);
  font-weight: 950;
  letter-spacing: -0.07em;
  line-height: 0.95;
  text-shadow: 0 8px 30px var(--ambient-purple);
}

.logo-line .spark {
  color: var(--secondary);
  font-size: 0.45em;
  text-shadow: none;
}

.hero-features {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem;
  padding: 0;
  margin: 1.5rem 0 0;
  list-style: none;
}

.hero-features li {
  padding: 0.38rem 0.75rem;
  color: var(--text);
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
}

.choice-grid,
.two-column,
.dashboard-grid,
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 1.5rem);
}

.choice-grid {
  position: relative;
  z-index: 2;
  width: min(100% - clamp(0rem, 3vw, 3rem), 68rem);
  margin: clamp(-2.5rem, -4vw, -1.5rem) auto 0;
}

.game-switch-nav {
  display: flex;
  justify-content: center;
  width: min(100%, 68rem);
  margin: clamp(2rem, 5vw, 3.5rem) auto 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--panel-border);
}

.game-switch-nav .quiet-link {
  margin-top: 0;
  padding-inline: 1rem;
  color: var(--muted);
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
  font-weight: 800;
  text-decoration-thickness: 0.12em;
  text-underline-offset: 0.2em;
}

.game-switch-nav .quiet-link:hover,
.game-switch-nav .quiet-link:focus-visible {
  color: var(--text);
  border-color: var(--accent);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(17rem, 0.75fr);
  align-items: start;
}

.card,
.hud-panel,
.status-banner,
.assignment-card,
.loading-panel,
.callout {
  position: relative;
  min-width: 0;
  padding: clamp(1rem, 3vw, 1.65rem);
  background: linear-gradient(145deg, var(--panel-highlight), transparent 38%), var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card::before,
.hud-panel::before,
.assignment-card::before {
  position: absolute;
  top: -1px;
  left: 1.35rem;
  width: 3rem;
  height: 0.25rem;
  content: "";
  background: var(--accent);
  border-radius: 0 0 4px 4px;
  box-shadow: 0.55rem 0.38rem 0 -0.13rem var(--purple);
}

.card-accent-magenta::before {
  background: var(--secondary);
  box-shadow: 0.55rem 0.38rem 0 -0.13rem var(--purple);
}

.card p:first-of-type,
.hud-panel p:first-of-type {
  margin-top: 0;
}

.adult-deck-warning {
  border-color: color-mix(in srgb, var(--warning) 62%, var(--panel-border));
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--warning) 10%, transparent), transparent 42%),
    var(--surface);
}

.adult-deck-warning::before {
  background: var(--warning);
  box-shadow: 0.55rem 0.38rem 0 -0.13rem var(--secondary);
}

.game-choice {
  display: flex;
  flex-direction: column;
  padding: clamp(1.25rem, 3vw, 2rem);
  border-top: 3px solid var(--accent);
  box-shadow: var(--shadow-lift);
}

.game-choice-join {
  border-top-color: var(--secondary);
}

.game-choice::after {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  width: 2.8rem;
  height: 2.8rem;
  content: "";
  background:
    linear-gradient(90deg, transparent 42%, var(--ambient-cyan) 42% 58%, transparent 58%),
    linear-gradient(transparent 42%, var(--ambient-cyan) 42% 58%, transparent 58%);
  pointer-events: none;
}

.game-choice-join::after {
  background:
    linear-gradient(90deg, transparent 42%, var(--ambient-magenta) 42% 58%, transparent 58%),
    linear-gradient(transparent 42%, var(--ambient-magenta) 42% 58%, transparent 58%);
}

.choice-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.35rem;
}

.choice-heading h2,
.choice-heading .eyebrow {
  margin-bottom: 0.25rem;
}

.choice-icon {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--panel-border);
  border-radius: 0.85rem 0.85rem 0.2rem 0.85rem;
  box-shadow: 0.28rem 0.28rem 0 var(--ambient-cyan);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 1.7rem;
  font-weight: 900;
}

.game-choice-join .choice-icon {
  color: var(--secondary-ink);
  background: var(--secondary);
  box-shadow: 0.28rem 0.28rem 0 var(--ambient-magenta);
}

.game-choice > p {
  color: var(--muted);
}

.game-choice form {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.game-choice .choice-action {
  margin-top: auto;
}

.section-stack > * + * {
  margin-top: 1rem;
}

.page-heading {
  position: relative;
  max-width: 60rem;
  margin-bottom: clamp(1.2rem, 3vw, 1.8rem);
  padding-bottom: clamp(0.8rem, 2vw, 1.2rem);
  border-bottom: 1px solid var(--panel-border);
}

.page-heading::after {
  position: absolute;
  bottom: -1px;
  left: 0;
  width: min(7rem, 28vw);
  height: 3px;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--purple), transparent);
}

.page-heading h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(2rem, 5.5vw, 3.45rem);
}

.status-banner {
  margin-bottom: 1.25rem;
  padding: 0.9rem 1.05rem;
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-left: 0.38rem solid var(--accent);
  border-radius: var(--radius-small);
  box-shadow: none;
}

.status-banner.warning {
  background: var(--warning-bg);
  border-left-color: var(--warning);
}

.status-banner.error {
  background: var(--danger-bg);
  border-left-color: var(--danger);
}

.status-banner.success {
  background: var(--success-bg);
  border-left-color: var(--success);
}

.status-banner p {
  margin: 0;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 2rem;
  color: var(--muted);
  font-weight: 700;
}

.connection-status::before {
  width: 0.7rem;
  height: 0.7rem;
  content: "";
  background: var(--success);
  border: 2px solid currentColor;
  border-radius: 50%;
  box-shadow: 0 0 0 3px var(--surface-strong);
}

.connection-status[data-state="reconnecting"]::before {
  background: var(--warning);
}

.connection-status[data-state="offline"]::before {
  background: var(--danger);
}

form {
  min-width: 0;
}

.field {
  margin-block: 1.1rem;
}

.field label,
.field legend {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.field-hint {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.field-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-weight: 800;
}

input[type="text"],
input[type="url"],
select {
  width: 100%;
  min-height: 48px;
  padding: 0.68rem 0.82rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  box-shadow: inset 0 1px 2px rgba(11, 16, 32, 0.08);
  transition: background-color 160ms ease, border-color 160ms ease;
}

input[type="text"]:hover,
input[type="url"]:hover,
select:hover {
  background: var(--surface);
  border-color: var(--accent);
}

input[aria-invalid="true"],
select[aria-invalid="true"] {
  border: 3px solid var(--danger);
  background: var(--danger-bg);
}

fieldset {
  min-width: 0;
  margin: 1rem 0;
  padding: 0;
  border: 0;
}

fieldset > legend {
  margin-bottom: 0.35rem;
  font-weight: 850;
}

.button,
.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 44px;
  min-height: 48px;
  padding: 0.68rem 1.08rem;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid rgba(0, 0, 0, 0.36);
  border-color: var(--border);
  border-color: color-mix(in srgb, var(--accent) 68%, var(--text));
  border-radius: 0.72rem 0.72rem 0.3rem 0.72rem;
  box-shadow: 0 4px 0 var(--border), 0 8px 18px var(--ambient-cyan);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 38%, var(--text)), 0 8px 18px var(--ambient-cyan);
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  transition: filter 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.button:hover:not(:disabled),
.button:focus-visible:not(:disabled),
.link-button:hover,
.link-button:focus-visible {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.button:active:not(:disabled),
.link-button:active {
  box-shadow: 0 1px 0 var(--border);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--accent) 35%, var(--text));
  transform: translateY(3px);
}

.button.alternate,
.link-button.alternate {
  color: var(--secondary-ink);
  background: var(--secondary);
  border-color: var(--border);
  border-color: color-mix(in srgb, var(--secondary) 68%, var(--text));
  box-shadow: 0 4px 0 var(--purple), 0 8px 18px var(--ambient-magenta);
  box-shadow: 0 4px 0 color-mix(in srgb, var(--secondary) 45%, var(--text)), 0 8px 18px var(--ambient-magenta);
}

.button.secondary,
.link-button.secondary {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--panel-border);
  box-shadow: 0 3px 0 var(--border), 0 7px 16px rgba(11, 16, 32, 0.08);
}

.button.tertiary {
  color: var(--accent);
  background: transparent;
  border-color: var(--accent);
  box-shadow: none;
}

.button.danger {
  color: #fff;
  background: #a81033;
  border-color: #760824;
  box-shadow: 0 4px 0 #62051c, 0 8px 18px rgba(168, 16, 51, 0.15);
}

:root[data-theme="dark"] .button.danger {
  color: #16030a;
  background: #ff8ca7;
  border-color: #ffb6c7;
  box-shadow: 0 4px 0 #7d1731, 0 8px 18px rgba(255, 140, 167, 0.12);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  margin-top: 1.25rem;
}

.button-row > * {
  flex: 0 1 auto;
}

.full-width {
  width: 100%;
}

.room-code {
  display: inline-block;
  margin: 0.2rem 0 0.75rem;
  padding: 0.55rem 0.85rem 0.6rem 1rem;
  color: var(--text);
  background: linear-gradient(145deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--accent);
  border-radius: var(--radius-small);
  box-shadow: inset 0 0 0 3px var(--surface), 0 7px 18px var(--ambient-cyan);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2rem, 11vw, 4.25rem);
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1;
}

.share-link {
  display: block;
  max-width: 100%;
  margin-block: 0.45rem;
  padding: 0.72rem 0.8rem;
  overflow-wrap: anywhere;
  user-select: all;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
}

.qr-figure {
  margin: 1.25rem 0 0;
  text-align: center;
}

.qr-figure canvas {
  display: block;
  width: min(100%, 240px);
  height: auto;
  margin-inline: auto;
  background: #fff;
  border: 8px solid #fff;
  border-radius: 0.65rem;
  box-shadow: 0 10px 26px rgba(11, 16, 32, 0.18);
  image-rendering: pixelated;
}

.qr-figure figcaption {
  margin-top: 0.6rem;
  color: var(--muted);
}

.player-list,
.plain-list,
.tally-list {
  padding: 0;
  margin: 1rem 0;
  list-style: none;
}

.player-list,
.tally-list {
  display: grid;
  gap: 0.55rem;
}

.player-list > li,
.tally-list > li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
}

.player-list > li:last-child,
.tally-list > li:last-child {
  border-bottom-width: 1px;
}

.player-name {
  min-width: 0;
  font-weight: 850;
}

.player-meta {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.22rem 0.55rem;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: normal;
}

.status-chip.current {
  background: var(--accent-soft);
  border: 2px solid var(--accent);
}

.plain-list {
  display: grid;
  gap: 0.5rem;
}

.plain-list .status-chip {
  display: flex;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-small);
  white-space: normal;
}

.status-chip.disconnected {
  background: var(--warning-bg);
  border-color: var(--warning);
}

.status-chip.connecting {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.status-chip.reconnecting {
  background: var(--warning-bg);
  border-color: var(--warning);
}

.status-chip.left {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.settings-grid,
.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.settings-grid > div {
  min-width: 0;
  padding: 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
}

form .settings-grid > .field {
  margin-block: 0;
}

.settings-grid dd {
  margin: 0;
}

.status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.1rem;
}

.status-item {
  position: relative;
  min-width: 0;
  padding: 1rem 1rem 1rem 1.15rem;
  background: linear-gradient(135deg, var(--panel-highlight), transparent 44%), var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
  box-shadow: 0 6px 18px rgba(11, 16, 32, 0.07);
}

.status-item::before {
  position: absolute;
  top: 0.9rem;
  bottom: 0.9rem;
  left: 0;
  width: 3px;
  content: "";
  background: linear-gradient(var(--accent), var(--purple));
  border-radius: 0 3px 3px 0;
}

.status-item strong {
  display: block;
  font-size: clamp(1.2rem, 4vw, 1.65rem);
  line-height: 1.25;
}

.timer {
  display: inline-block;
  min-width: 6ch;
  padding: 0.42rem 0.65rem 0.52rem;
  color: var(--timer-text);
  background:
    linear-gradient(rgba(255, 255, 255, 0.045), transparent 55%),
    var(--timer-bg);
  border: 1px solid var(--accent);
  border-radius: 0.85rem;
  box-shadow: inset 0 0 0 3px rgba(61, 245, 255, 0.055), 0 9px 22px var(--ambient-cyan);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2.1rem, 9vw, 4.5rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  text-align: center;
}

.timer.expired {
  border: 3px solid var(--danger);
  box-shadow: inset 0 0 0 2px rgba(255, 140, 167, 0.08);
}

.assignment-wrap {
  max-width: 52rem;
  margin: clamp(1rem, 3vw, 2rem) auto;
}

.assignment-card {
  padding: clamp(1.25rem, 5vw, 3rem);
  background:
    radial-gradient(circle at 15% 0, var(--ambient-cyan), transparent 20rem),
    radial-gradient(circle at 90% 100%, var(--ambient-magenta), transparent 22rem),
    var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-lift), inset 0 0 0 4px var(--panel-highlight);
  text-align: center;
}

.assignment-card h2 {
  font-size: clamp(1.8rem, 7vw, 3.4rem);
}

.assignment-value {
  margin: 0.35rem auto 1.2rem;
  color: var(--text);
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 900;
  line-height: 1.1;
  text-wrap: balance;
  text-shadow: 0 5px 22px var(--ambient-cyan);
}

.assignment-role {
  color: var(--secondary);
  font-size: clamp(1.45rem, 5vw, 2.35rem);
  font-weight: 900;
}

.concealed-card {
  position: relative;
  padding: clamp(2rem, 8vw, 5rem) 1rem;
  background:
    linear-gradient(135deg, var(--panel-highlight), transparent 46%),
    var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  text-align: center;
}

.concealed-card::before {
  display: block;
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 1rem;
  content: "?";
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 0.9rem 0.9rem 0.2rem 0.9rem;
  box-shadow: 0.32rem 0.32rem 0 var(--ambient-magenta);
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 2rem;
  font-weight: 900;
  line-height: 3.4rem;
}

.location-options,
.vote-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
  margin-block: 0.8rem;
}

.location-guess {
  margin-top: clamp(1.25rem, 4vw, 2rem);
  padding: clamp(1rem, 3vw, 1.5rem);
  background:
    linear-gradient(145deg, var(--panel-highlight), transparent 44%),
    var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 var(--panel-highlight);
  text-align: start;
}

.location-guess h3 {
  margin-bottom: 0.35rem;
  color: var(--text);
}

.location-guess fieldset {
  margin-bottom: 0;
}

.round-reset-controls {
  margin-top: clamp(1.25rem, 3vw, 2rem);
  background:
    linear-gradient(145deg, var(--ambient-purple), transparent 38%),
    var(--surface);
  border-color: color-mix(in srgb, var(--purple) 45%, var(--panel-border));
}

.round-reset-controls::before {
  background: var(--purple);
  box-shadow: 0.55rem 0.38rem 0 -0.13rem var(--secondary);
}

.radio-card {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 48px;
  padding: 0.65rem 0.75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  font-weight: 750;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.radio-card:hover {
  background: var(--surface);
  border-color: var(--accent);
}

.radio-card:has(input:checked) {
  background: var(--accent-soft);
  border: 3px solid var(--accent);
  box-shadow: 0 6px 16px var(--ambient-cyan);
}

.radio-card:has(input:focus-visible) {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.radio-card:has(input:focus-visible) input {
  outline: 0 !important;
}

.radio-card input {
  flex: 0 0 auto;
  width: 1.35rem;
  height: 1.35rem;
  margin: 0 0.65rem 0 0;
  accent-color: var(--accent);
}

.turn-callout {
  position: relative;
  padding: clamp(1rem, 4vw, 2rem);
  background:
    linear-gradient(135deg, var(--accent-soft), var(--surface) 72%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.turn-callout::after {
  position: absolute;
  top: 0;
  right: 1.2rem;
  width: 3.5rem;
  height: 0.28rem;
  content: "";
  background: linear-gradient(90deg, var(--accent), var(--secondary));
  border-radius: 0 0 4px 4px;
}

.turn-callout h2 {
  margin-bottom: 0.35rem;
  font-size: clamp(1.7rem, 6vw, 2.8rem);
}

.progress-wrap {
  margin-block: 1rem;
}

progress {
  width: 100%;
  height: 1.35rem;
  accent-color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--accent);
  background: repeating-linear-gradient(90deg, var(--accent) 0 0.9rem, color-mix(in srgb, var(--accent) 75%, var(--text)) 0.9rem 1rem);
}

.result-hero {
  position: relative;
  padding: clamp(1.4rem, 6vw, 3.5rem);
  margin-bottom: 1.25rem;
  background:
    radial-gradient(circle at 12% 0, var(--ambient-cyan), transparent 22rem),
    radial-gradient(circle at 90% 100%, var(--ambient-magenta), transparent 24rem),
    var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-lift);
  text-align: center;
}

.result-hero::after {
  position: absolute;
  inset: 0.55rem;
  content: "";
  border: 1px solid var(--panel-border);
  border-radius: calc(var(--radius-large) - 0.35rem);
  pointer-events: none;
}

.result-hero h1 {
  font-size: clamp(2rem, 9vw, 4.6rem);
}

.result-summary {
  margin-inline: auto;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
}

.results-grid {
  align-items: start;
}

.results-grid + .hud-panel,
main[data-phase="voting"] > .dashboard-grid,
main[data-phase="voting"] > .hud-panel + .hud-panel {
  margin-top: 1rem;
}

main[data-screen="join"] {
  max-width: 66rem;
}

main[data-phase="lobby"] .dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.8fr);
}

main[data-phase="questioning"] .assignment-wrap,
main[data-phase="voting"] .assignment-wrap {
  max-width: 48rem;
}

main[data-phase="questioning"] .assignment-wrap .concealed-card,
main[data-phase="voting"] .assignment-wrap .concealed-card {
  padding-block: clamp(1.4rem, 4vw, 2.5rem);
}

table {
  width: 100%;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
  border-collapse: collapse;
}

th,
td {
  padding: 0.7rem;
  border-bottom: 1px solid var(--panel-border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
}

.rules-list {
  padding-left: 1.65rem;
  counter-reset: rules;
}

.rules-list li {
  padding-left: 0.2rem;
}

.rules-list li::marker {
  color: var(--secondary);
  font-weight: 900;
}

.rules-list li + li {
  margin-top: 0.55rem;
}

.game-dialog {
  width: min(calc(100% - 2rem), 34rem);
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: clamp(1rem, 4vw, 1.75rem);
  color: var(--text);
  background:
    linear-gradient(145deg, var(--panel-highlight), transparent 38%),
    var(--surface);
  border: 2px solid var(--accent);
  border-radius: var(--radius-large);
  box-shadow: 0 24px 70px rgba(3, 7, 18, 0.52);
  overflow: auto;
}

.game-dialog::backdrop {
  background: rgba(3, 7, 18, 0.8);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.loading-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  max-width: 30rem;
  margin: 8vh auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 800;
}

.pixel-loader {
  width: 1rem;
  height: 1rem;
  background: var(--accent);
  box-shadow: 1.4rem 0 var(--secondary), 2.8rem 0 var(--purple);
  animation: loader-step 0.9s steps(2, end) infinite alternate;
  margin-right: 2.8rem;
}

.noscript-message {
  position: fixed;
  inset: 1rem;
  z-index: 1000;
  padding: 1rem;
  color: #0b1020;
  background: #ffe45e;
  border: 4px solid #0b1020;
  border-radius: var(--radius-small);
  box-shadow: var(--shadow-lift);
  font-weight: 900;
}

@keyframes loader-step {
  to { transform: translateY(-0.35rem); }
}

@media (max-width: 780px) {
  .header-inner {
    align-items: center;
    flex-wrap: wrap;
  }

  .header-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .header-tools > .tool-button {
    justify-content: center;
  }

  .audio-controls {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .choice-grid,
  .two-column,
  .dashboard-grid,
  .results-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .choice-grid {
    width: min(100% - 1rem, 38rem);
    margin-top: -2rem;
  }

  main[data-phase="lobby"] .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .status-grid {
    gap: 0.65rem;
  }
}

@media (max-width: 520px) {
  .header-inner {
    align-items: stretch;
  }

  .brand {
    align-self: flex-start;
  }

  .header-tools {
    grid-template-columns: 1fr;
  }

  .header-tools > .tool-button {
    justify-content: flex-start;
    width: 100%;
    background: var(--surface-translucent);
    border-color: var(--panel-border);
  }

  .audio-controls {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .control-group-label,
  .volume-control {
    grid-column: 1;
  }

  .audio-controls .tool-button {
    justify-content: center;
    width: 100%;
  }

  .language-control {
    grid-template-columns: auto minmax(0, 1fr);
    width: 100%;
  }

  .tool-button {
    padding-inline: 0.55rem;
  }

  .volume-control {
    grid-template-columns: auto minmax(0, 1fr) auto;
    width: 100%;
    padding-inline: 0.35rem;
  }

  .location-options,
  .vote-options,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .button-row > * {
    flex: 1 1 100%;
  }

  .player-list > li {
    align-items: flex-start;
    flex-direction: column;
  }

  .home-hero {
    padding-top: 2.35rem;
    padding-bottom: 4rem;
  }

  .home-hero::after {
    right: -8rem;
    bottom: -10rem;
  }

  .hero-features {
    align-items: stretch;
    flex-direction: column;
  }

  .hero-features li {
    border-radius: var(--radius-small);
  }

  .choice-heading {
    align-items: start;
  }
}

/* A 320px device at 200% zoom exposes roughly a 160px CSS viewport. Keep the
   layout useful there without hiding overflow or requiring horizontal panning. */
@media (max-width: 360px) {
  .header-inner,
  main,
  .site-footer {
    width: calc(100% - 0.75rem);
  }

  main[data-screen] {
    width: calc(100% - 0.75rem);
  }

  main {
    padding-block: 1rem;
  }

  .header-inner {
    gap: 0.6rem;
  }

  .header-tools {
    align-items: stretch;
    gap: 0.35rem;
  }

  .language-control {
    grid-template-columns: 1fr;
  }

  .language-control select {
    width: 100%;
  }

  .tool-button {
    max-width: 100%;
    padding-inline: 0.4rem;
    white-space: normal;
  }

  .volume-control {
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    padding-inline: 0.2rem;
  }

  .volume-control label {
    grid-column: 1 / -1;
  }

  .volume-control input {
    grid-column: 1;
    width: 100%;
    min-width: 0;
  }

  .volume-control output {
    grid-column: 2;
  }

  .card,
  .hud-panel,
  .status-banner,
  .assignment-card,
  .loading-panel,
  .callout,
  .turn-callout,
  .result-hero,
  .status-item,
  .game-dialog {
    padding: 0.7rem;
  }

  .home-hero {
    padding: 1.8rem 0.65rem 3.3rem;
  }

  .choice-grid {
    width: calc(100% - 0.35rem);
    margin-top: -1.4rem;
  }

  .choice-heading {
    grid-template-columns: 1fr;
  }

  .choice-icon {
    width: 2.8rem;
    height: 2.8rem;
    font-size: 1.45rem;
  }

  .hero-pixels {
    right: 0.8rem;
  }

  .button,
  .link-button {
    max-width: 100%;
    padding-inline: 0.6rem;
    white-space: normal;
  }

  .room-code {
    display: block;
    max-width: 100%;
    padding-inline: 0.35rem;
    font-size: clamp(1.25rem, 14vw, 2rem);
    letter-spacing: 0.08em;
  }

  .timer {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-inline: 0.2rem;
    font-size: clamp(1.45rem, 16vw, 2.3rem);
  }

  .assignment-value,
  .assignment-card h2,
  .result-hero h1,
  .turn-callout h2,
  h1 {
    font-size: clamp(1.45rem, 12vw, 2rem);
    overflow-wrap: anywhere;
  }

  .radio-card,
  input[type="text"],
  input[type="url"],
  select {
    min-width: 0;
    max-width: 100%;
  }

  .game-dialog {
    width: calc(100% - 0.75rem);
  }
}

@supports not selector(:focus-visible) {
  :focus {
    outline: 4px solid var(--focus) !important;
    outline-offset: 4px !important;
    box-shadow: none !important;
  }
}

@media (forced-colors: active) {
  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  :focus,
  :focus-visible {
    outline-color: Highlight !important;
  }

  .card::before,
  .hud-panel::before,
  .assignment-card::before,
  .home-hero::before,
  .home-hero::after,
  .game-choice::after,
  .turn-callout::after,
  .result-hero::after,
  .status-item::before,
  .eyebrow::before,
  .hero-pixels,
  body::before {
    display: none;
  }

  .brand-name {
    color: CanvasText;
    background: none;
  }

  .brand-mark,
  .choice-icon,
  .concealed-card::before {
    color: ButtonText;
    background: ButtonFace;
    border: 2px solid ButtonText;
  }

  .button,
  .link-button,
  .tool-button,
  input,
  select,
  .radio-card {
    border: 2px solid ButtonText;
  }

  .status-chip.current,
  .radio-card:has(input:checked),
  .radio-card:has(input:focus-visible),
  .turn-callout,
  .result-hero {
    border-width: 4px;
  }
}

:root[lang^="zh"] {
  font-family: "Atkinson Hyperlegible", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

:root[lang="ar"] {
  font-family: "Atkinson Hyperlegible", "Noto Sans Arabic", Tahoma, Arial, system-ui, sans-serif;
}

:root[dir="rtl"] .card::before,
:root[dir="rtl"] .hud-panel::before,
:root[dir="rtl"] .assignment-card::before {
  right: 1.35rem;
  left: auto;
}

:root[dir="rtl"] .page-heading::after,
:root[dir="rtl"] .status-item::before {
  right: 0;
  left: auto;
}

:root[dir="rtl"] .status-banner {
  border-right: 0.38rem solid var(--accent);
  border-left: 1px solid var(--panel-border);
}

:root[dir="rtl"] .status-banner.warning {
  border-right-color: var(--warning);
}

:root[dir="rtl"] .status-banner.error {
  border-right-color: var(--danger);
}

:root[dir="rtl"] .status-banner.success {
  border-right-color: var(--success);
}

:root[dir="rtl"] .radio-card input {
  margin-right: 0;
  margin-left: 0.65rem;
}

.room-code,
.share-link,
.timer {
  direction: ltr;
  unicode-bidi: isolate;
}

.player-name {
  unicode-bidi: plaintext;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .pixel-loader {
    animation: none;
  }

  .button:hover,
  .button:focus-visible,
  .link-button:hover,
  .link-button:focus-visible,
  .tool-button:hover,
  .tool-button:focus-visible {
    transform: none;
  }
}

/* Multiplayer platform and Werewolf --------------------------------------- */

main[data-screen="platform"] {
  width: min(100% - 2rem, 78rem);
  padding-top: clamp(1rem, 2.8vw, 2rem);
}

.platform-hero {
  padding-bottom: clamp(2rem, 5vw, 3.7rem);
}

.platform-hero .logo-line {
  display: block;
  font-size: clamp(2.5rem, 8vw, 5.4rem);
}

.welcome-copy {
  display: grid;
  max-width: 57rem;
  gap: 0.65rem;
  margin: 1.5rem auto 0;
  padding: clamp(1rem, 3vw, 1.6rem);
  text-align: start;
  background: var(--surface-translucent);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(11, 16, 32, 0.08);
}

.welcome-copy p {
  max-width: none;
  margin: 0;
}

.welcome-copy .welcome-signoff {
  color: var(--purple);
  font-size: 1.15rem;
  font-weight: 850;
}

.platform-game-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(1rem, 3vw, 1.6rem);
  width: min(100% - clamp(0rem, 3vw, 3rem), 68rem);
  margin: clamp(-1.2rem, -2vw, -0.6rem) auto 0;
}

.game-tile {
  position: relative;
  isolation: isolate;
  display: flex;
  min-width: 0;
  min-height: 23rem;
  flex-direction: column;
  padding: clamp(1.25rem, 3vw, 2rem);
  overflow: hidden;
  background:
    linear-gradient(150deg, var(--panel-highlight), transparent 42%),
    var(--surface);
  border: 1px solid var(--panel-border);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow-lift);
}

.game-tile::after {
  position: absolute;
  right: -4rem;
  bottom: -5rem;
  z-index: -1;
  width: 15rem;
  height: 15rem;
  content: "";
  background: radial-gradient(circle, var(--ambient-cyan), transparent 68%);
  border: 1px solid var(--panel-border);
  border-radius: 50%;
}

.game-tile h2 {
  font-size: clamp(2rem, 6vw, 3.5rem);
}

.game-tile > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 1.08rem;
}

.game-tile .link-button {
  align-self: flex-start;
  margin-top: auto;
}

.werewolf-tile {
  background:
    radial-gradient(circle at 82% 12%, rgba(173, 144, 255, 0.19), transparent 11rem),
    linear-gradient(150deg, var(--panel-highlight), transparent 42%),
    var(--surface);
  border-top-color: var(--purple);
}

.werewolf-tile::after {
  background:
    radial-gradient(circle at 35% 35%, var(--ambient-purple), transparent 44%),
    repeating-linear-gradient(135deg, transparent 0 13px, var(--ambient-magenta) 14px 15px, transparent 16px 27px);
  border-radius: 46% 54% 50% 50%;
  opacity: 0.8;
}

.quiet-link {
  position: relative;
  z-index: 2;
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
}

main[data-game="werewolf"] {
  --game-accent: #6541c1;
  --game-accent-ink: #ffffff;
  --game-soft: rgba(94, 58, 187, 0.13);
}

:root[data-theme="dark"] main[data-game="werewolf"] {
  --game-accent: #ad90ff;
  --game-accent-ink: #0b1020;
  --game-soft: rgba(139, 92, 246, 0.16);
}

main[data-game="werewolf"]::before {
  position: fixed;
  inset: 4.7rem 0 0;
  z-index: -1;
  content: "";
  background:
    radial-gradient(circle at 87% 11%, rgba(173, 144, 255, 0.13), transparent 14rem),
    linear-gradient(155deg, transparent 50%, rgba(60, 31, 104, 0.055));
  pointer-events: none;
}

.werewolf-action {
  color: var(--game-accent-ink, var(--accent-ink));
  background: var(--game-accent, var(--purple));
  border-color: color-mix(in srgb, var(--game-accent, var(--purple)) 62%, var(--text));
  box-shadow: 0 4px 0 color-mix(in srgb, var(--game-accent, var(--purple)) 42%, var(--text)), 0 8px 18px var(--ambient-purple);
}

.werewolf-setup > .button-row:first-of-type {
  margin-top: 0;
}

.role-library {
  margin-block: 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.role-library > summary,
.private-action-disclosure > summary {
  min-height: 48px;
  padding: 0.8rem 1rem;
  color: var(--text);
  font-weight: 850;
  cursor: pointer;
}

.role-library > :not(summary),
.private-action-disclosure > :not(summary) {
  margin-inline: 1rem;
}

.role-library > :last-child,
.private-action-disclosure > :last-child {
  margin-bottom: 1rem;
}

.role-setup-list {
  display: grid;
  gap: 0.75rem;
  margin-block: 1rem;
}

.role-setup-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  min-width: 0;
  padding: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
}

.role-setup-row.selected {
  border-left: 0.35rem solid var(--game-accent, var(--purple));
}

.role-setup-copy h3,
.role-setup-copy p {
  margin-block: 0 0.25rem;
}

.role-requirement {
  color: var(--warning);
  font-size: 0.9rem;
  font-weight: 750;
}

.role-quantity {
  display: grid;
  justify-items: center;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 800;
}

input[type="number"] {
  width: 5rem;
  min-height: 48px;
  padding: 0.55rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  text-align: center;
}

.role-count {
  min-width: 3rem;
  font-size: 1.25rem;
  text-align: center;
}

.option-stack {
  display: grid;
  gap: 0.75rem;
  margin-block: 1rem;
}

.check-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.8rem;
  align-items: start;
  min-height: 48px;
  padding: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
  cursor: pointer;
}

.check-option input {
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.1rem;
  accent-color: var(--game-accent, var(--accent));
}

.check-option span span {
  display: block;
}

.progress-panel progress {
  width: 100%;
  height: 1rem;
  accent-color: var(--game-accent, var(--accent));
}

.werewolf-concealed {
  background:
    radial-gradient(circle at 50% 12%, var(--game-soft, var(--ambient-purple)), transparent 13rem),
    var(--surface);
}

.werewolf-role-card {
  background:
    radial-gradient(circle at 50% -10%, var(--game-soft, var(--ambient-purple)), transparent 17rem),
    linear-gradient(150deg, var(--panel-highlight), transparent 45%),
    var(--surface);
  border-color: var(--game-accent, var(--purple));
  text-align: center;
}

.werewolf-role-card h2 {
  font-size: clamp(2.2rem, 8vw, 4.8rem);
}

.werewolf-role-card section,
.werewolf-role-card .plain-list {
  text-align: start;
}

.role-team,
.private-status {
  font-weight: 850;
}

.private-status {
  max-width: 42rem;
  margin-inline: auto;
  padding: 0.65rem 0.8rem;
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-small);
}

.private-action-disclosure {
  min-width: 0;
  overflow: hidden;
  background: linear-gradient(145deg, var(--panel-highlight), transparent 38%), var(--surface);
  border: 1px solid var(--game-accent, var(--purple));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.phase-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(17rem, 0.75fr);
  gap: clamp(1rem, 3vw, 1.5rem);
  align-items: start;
}

.calm-wait,
.private-result,
.night-action-form {
  min-width: 0;
  margin-block: 1rem;
  padding: clamp(1rem, 3vw, 1.4rem);
  background: var(--surface-2);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
}

.private-result {
  border: 2px solid var(--game-accent, var(--purple));
}

.private-result-callout {
  font-size: clamp(1.3rem, 4vw, 2rem);
  font-weight: 900;
}

.selection-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.werewolf-choice {
  min-width: 0;
}

.narrator-card {
  position: relative;
  min-width: 0;
  padding: clamp(1.15rem, 3vw, 1.8rem);
  background:
    linear-gradient(135deg, var(--game-soft, var(--ambient-purple)), transparent 48%),
    var(--surface);
  border: 1px solid var(--game-accent, var(--purple));
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}

.narrator-card::before {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 1rem;
  height: 1rem;
  content: "";
  background: var(--game-accent, var(--purple));
  border-radius: 50%;
  box-shadow: -0.45rem 0.1rem 0 0.16rem var(--surface);
  opacity: 0.8;
}

.narration-line {
  max-width: 64ch;
  font-size: 1.1rem;
  line-height: 1.7;
}

.narration-notes,
.death-list,
.round-history {
  padding-inline-start: 1.4rem;
}

.narration-notes li,
.death-list li,
.round-history li {
  margin-block: 0.45rem;
}

.werewolf-roster .player-eliminated {
  border-style: dashed;
}

.werewolf-roster .player-alive {
  border-left: 0.3rem solid var(--success);
}

.werewolf-roster .player-eliminated {
  border-left: 0.3rem solid var(--danger);
}

.werewolf-result {
  background:
    radial-gradient(circle at 82% 20%, var(--game-soft, var(--ambient-purple)), transparent 17rem),
    linear-gradient(145deg, var(--surface), var(--surface-2));
}

@media (max-width: 760px) {
  .platform-game-grid,
  .phase-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .platform-game-grid {
    width: calc(100% - 0.35rem);
  }

  .game-tile {
    min-height: 19rem;
  }
}

@media (max-width: 480px) {
  .welcome-copy,
  .game-tile {
    padding: 0.85rem;
  }

  .role-setup-row,
  .selection-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .role-quantity {
    grid-template-columns: minmax(0, 1fr) auto;
    justify-items: start;
  }

  input[type="number"] {
    width: min(100%, 8rem);
  }
}

@media (forced-colors: active) {
  .game-tile::after,
  .narrator-card::before,
  main[data-game="werewolf"]::before {
    display: none;
  }

  .game-tile,
  .role-setup-row,
  .check-option,
  .private-action-disclosure,
  .narrator-card,
  input[type="number"] {
    border: 2px solid CanvasText;
  }
}

@media print {
  .site-header,
  .site-footer,
  .button,
  .link-button,
  .private-information {
    display: none !important;
  }
}
