:root {
  --bg: #0b1020;
  --bg-elev: #121a30;
  --surface: rgba(20, 29, 53, 0.9);
  --surface-solid: #16203b;
  --surface-hover: #1d2a4d;
  --border: rgba(255, 255, 255, 0.11);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
  --accent-2: #818cf8;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --touch: 44px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  background: radial-gradient(circle at top right, #172554 0%, var(--bg) 52%);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body.reduced-effects {
  background: var(--bg);
}

body.reduced-effects *,
body.reduced-effects *::before,
body.reduced-effects *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  backdrop-filter: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.12rem 0.35rem;
  border-radius: 6px;
  font-size: 0.9em;
}

.hidden {
  display: none !important;
}

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

.small {
  font-size: 0.85rem;
}

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

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

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

.section-head h2,
.section-head h3 {
  margin: 0;
}

.section-title {
  margin: 0 0 0.25rem;
}

/* Topbar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(11, 16, 32, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  min-height: 54px;
  padding: 0.35rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  min-height: var(--touch);
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand:hover {
  text-decoration: none;
}

.brand-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-badge {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.ws-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  white-space: nowrap;
}

@media (max-width: 479px) {
  /* Only the colored dot on small phones – text stays available for screen readers */
  .ws-pill {
    padding: 0.55rem;
  }
  .ws-pill .ws-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
  }
}

.ws-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
  flex-shrink: 0;
}
.ws-dot.online {
  background: var(--success);
}
.ws-dot.offline {
  background: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  min-width: var(--touch);
  min-height: var(--touch);
  padding: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.15rem;
  cursor: pointer;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.menu-wrap {
  position: relative;
}

.settings-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.45rem);
  width: min(92vw, 330px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 60;
}

.settings-title {
  font-weight: 800;
  font-size: 0.95rem;
  padding: 0 0.15rem 0.2rem;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--touch);
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  cursor: pointer;
}

.switch-row.is-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.switch-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.88rem;
}

.switch-text small {
  color: var(--muted);
  font-size: 0.75rem;
}

/* Accessible toggle switch built on a native checkbox */
.switch {
  appearance: none;
  -webkit-appearance: none;
  flex-shrink: 0;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  position: relative;
  cursor: pointer;
  transition: background-color 0.15s ease;
  margin: 0;
}

.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:disabled {
  cursor: not-allowed;
}

.conn-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.45rem 0.85rem;
  background: rgba(251, 191, 36, 0.16);
  border-top: 1px solid rgba(251, 191, 36, 0.35);
  color: #fde68a;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: center;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 0.85rem 1.5rem;
  flex: 1 0 auto;
  min-width: 0;
}

.container.narrow {
  max-width: 480px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.container-game {
  padding-top: 0.6rem;
}

/* Cards & Surface */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card h1,
.card h2,
.card h3 {
  margin-top: 0;
}

.card h2 {
  margin-bottom: 0;
}

@media (max-width: 479px) {
  .card {
    padding: 1rem;
  }
  .form-stack {
    gap: 0.7rem;
  }
}

/* Forms & Buttons */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.field-help {
  margin: -0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.input,
.select {
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(9, 14, 28, 0.85);
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
}

.input:focus,
.select:focus {
  outline: 2px solid var(--accent);
  border-color: transparent;
}

.select:disabled {
  opacity: 0.75;
}

.password-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, opacity 0.15s ease;
  color: var(--text);
  background: var(--surface-hover);
  user-select: none;
  text-decoration: none;
}

.btn:hover {
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06101f;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border);
}

.btn-danger {
  background: rgba(248, 113, 113, 0.16);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
}

.btn-danger-solid {
  background: #dc2626;
  color: #fff;
}

/* Small buttons stay at the 44px touch minimum, only visually more compact */
.btn-sm {
  min-height: var(--touch);
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
}

.btn-lg {
  min-height: 52px;
  font-size: 1.02rem;
}

.btn-block {
  width: 100%;
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.alert-error {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.4);
  color: #fecaca;
}

.alert-info {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.35);
  color: #bae6fd;
}

/* Hub Layout */
.hub-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    'name'
    'join'
    'lobbies'
    'games';
}

.hub-name {
  grid-area: name;
}
.hub-join {
  grid-area: join;
}
.hub-lobbies {
  grid-area: lobbies;
}
.hub-games {
  grid-area: games;
}

@media (min-width: 820px) {
  .hub-grid {
    grid-template-columns: 340px minmax(0, 1fr);
    grid-template-areas:
      'name games'
      'join games'
      'lobbies games';
    align-items: start;
  }
  .hub-games {
    grid-row: 1 / span 3;
  }
}

.card.attention {
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.35), var(--shadow);
}

/* Lobby: waiting room on top, match settings below */
.lobby-view {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lobby-waiting {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.lobby-subhead {
  font-size: 1.05rem;
  margin: 0;
}

.lobby-summary {
  margin: 0;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(129, 140, 248, 0.12);
  border: 1px solid rgba(129, 140, 248, 0.3);
  color: #c7d2fe;
  font-size: 0.84rem;
  font-weight: 600;
}

.lobby-summary:empty {
  display: none;
}

.waiting-host {
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border);
}

.settings-sections {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-top: 0.85rem;
}

.settings-section {
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

.settings-section:first-child {
  border-top: 0;
  padding-top: 0;
}

.settings-section h3 {
  margin: 0;
  font-size: 0.98rem;
  display: inline;
}

.settings-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  margin-bottom: 0.6rem;
}

.settings-section > summary::-webkit-details-marker {
  display: none;
}

.settings-section > summary::after {
  content: '▾';
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.settings-section:not([open]) > summary {
  margin-bottom: 0;
}

.settings-section:not([open]) > summary::after {
  transform: rotate(-90deg);
}

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

@media (min-width: 820px) {
  .settings-section:first-child .settings-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.multi-field {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.multi-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.toggle-grid {
  display: grid;
  gap: 0.45rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.toggle-chip {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  min-height: var(--touch);
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  text-align: left;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.toggle-chip:disabled {
  cursor: default;
}

.toggle-chip[aria-pressed='true'] {
  color: var(--text);
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.12);
}

.toggle-chip.tone-buff[aria-pressed='true'] {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.12);
}

.toggle-chip.tone-debuff[aria-pressed='true'] {
  border-color: rgba(248, 113, 113, 0.55);
  background: rgba(248, 113, 113, 0.12);
}

.toggle-chip-check {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 6px;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 900;
  color: #06101f;
}

.toggle-chip[aria-pressed='true'] .toggle-chip-check {
  background: var(--accent);
  border-color: transparent;
}

.toggle-chip.tone-buff[aria-pressed='true'] .toggle-chip-check {
  background: var(--success);
}

.toggle-chip.tone-debuff[aria-pressed='true'] .toggle-chip-check {
  background: var(--danger);
}

.toggle-chip-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.toggle-chip-text strong {
  font-size: 0.86rem;
}

.toggle-chip-text small {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
}

.invite-card {
  margin-bottom: 1rem;
  border-color: rgba(56, 189, 248, 0.5);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.invite-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 800;
  text-align: center;
}

.code-input::placeholder {
  letter-spacing: 0.18em;
}

.games-grid {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
}

.game-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.85rem;
}

.game-card.highlight {
  border-color: var(--accent);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.25);
}

.lobby-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lobby-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.lobby-list-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.lobby-list-title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lobby-list-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Lobby Layout */
.lobby-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.lobby-title-block h1 {
  margin: 0.1rem 0 0;
}

.lobby-code-box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lobby-code-pill {
  font-size: 1.45rem;
  font-weight: 900;
  letter-spacing: 0.22em;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
  white-space: nowrap;
}

.lobby-columns {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1fr);
}

.lobby-columns h3 {
  margin: 0;
}

@media (min-width: 820px) {
  .lobby-columns {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    align-items: start;
  }
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.player-item.is-offline {
  border-style: dashed;
  opacity: 0.8;
}

.player-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.player-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.player-name-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex-wrap: wrap;
}

.player-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-sub {
  font-size: 0.76rem;
  color: var(--muted);
}

.seat-swatch {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.player-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

.badge:empty {
  display: none;
}

.badge-host {
  background: rgba(251, 191, 36, 0.2);
  color: #fde68a;
}

.badge-bot {
  background: rgba(129, 140, 248, 0.22);
  color: #c7d2fe;
}

.badge-offline {
  background: rgba(248, 113, 113, 0.2);
  color: #fecaca;
}

.badge-team {
  background: rgba(56, 189, 248, 0.2);
  color: #bae6fd;
}

.team-pills {
  display: inline-flex;
  gap: 0.25rem;
}

.team-btn {
  min-width: var(--touch);
  min-height: var(--touch);
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.team-btn[aria-pressed='true'] {
  background: var(--accent);
  color: #06101f;
  border-color: transparent;
}

.kick-btn {
  min-width: var(--touch);
  padding: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--touch);
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
}

/* Footer */
.site-footer {
  padding: 0.85rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

body.in-game .site-footer {
  display: none;
}

/* Phones in landscape: every pixel of height counts during a game */
@media (orientation: landscape) and (max-height: 560px) {
  body.in-game .topbar {
    position: static;
  }
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  width: min(92vw, 420px);
  pointer-events: none;
}

body.in-game .toast-container {
  bottom: auto;
  top: calc(64px + env(safe-area-inset-top));
}

.toast {
  pointer-events: auto;
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text);
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
}

.toast.error {
  background: #450a0a;
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.toast-success {
  background: #064e3b;
  border-color: rgba(52, 211, 153, 0.5);
  color: #d1fae5;
}

/* Dialogs (native <dialog>: focus trap, Escape, inert background for free) */
.ui-dialog {
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text);
  width: min(94vw, 460px);
  max-height: min(88dvh, 760px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.ui-dialog::backdrop {
  background: rgba(4, 8, 18, 0.78);
}

.ui-dialog-wide {
  width: min(94vw, 640px);
}

.ui-dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: inherit;
}

.ui-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.85rem 0.5rem 1.1rem;
}

.ui-dialog-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.ui-dialog-close {
  font-size: 1rem;
}

.ui-dialog-body {
  padding: 0.25rem 1.1rem 0.9rem;
  overflow-y: auto;
  font-size: 0.93rem;
}

.ui-dialog-body > p:first-child {
  margin-top: 0;
}

.ui-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid var(--border);
}

.reclaim-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

/* Invite dialog */
.invite-dialog {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.invite-code-big {
  text-align: center;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: #e0f2fe;
}

.qr-box {
  align-self: center;
  width: min(62vw, 230px);
  padding: 0.4rem;
  background: #fff;
  border-radius: 12px;
}

.qr-box svg {
  display: block;
  width: 100%;
  height: auto;
}

.invite-link-input {
  font-size: 15px;
  text-align: center;
}

/* Rules */
.rules-content h3 {
  font-size: 1rem;
  margin: 1rem 0 0.35rem;
  color: #e2e8f0;
}

.rules-content h3:first-child {
  margin-top: 0;
}

.rules-content p {
  margin: 0 0 0.4rem;
}

.rules-content ul {
  margin: 0;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.rules-cards {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.rules-cards th,
.rules-cards td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.rules-cards td:nth-child(2) {
  white-space: nowrap;
}

/* Legal page */
.legal-card section {
  margin-top: 1.15rem;
}

.legal-card h2 {
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
  color: #e2e8f0;
}
