:root {
  color-scheme: light;
  --font-sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --bg: #f4f7f3;
  --bg-soft: #edf3ee;
  --surface: #fffdfa;
  --surface-raised: #ffffff;
  --surface-muted: #f8faf7;
  --text: #18211c;
  --text-muted: #536158;
  --line: #dbe5dc;
  --line-strong: #c4d2c8;

  --primary: #b92f58;
  --primary-strong: #8a2040;
  --primary-soft: #fde8ef;
  --accent: #157a63;
  --accent-soft: #dff3e9;
  --warning: #e5a326;
  --warning-soft: #fff2cf;
  --focus: #2f8cff;

  --shadow-sm: 0 1px 2px rgba(24, 33, 28, 0.06);
  --shadow-md: 0 14px 38px rgba(24, 33, 28, 0.1);
  --shadow-lg: 0 24px 70px rgba(24, 33, 28, 0.14);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.35rem;
  --text-2xl: 1.75rem;
  --text-3xl: 2.45rem;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101513;
  --bg-soft: #171f1b;
  --surface: #18211d;
  --surface-raised: #1f2924;
  --surface-muted: #121a16;
  --text: #eef5ef;
  --text-muted: #a5b3aa;
  --line: #2e3d35;
  --line-strong: #405248;
  --primary: #ff7da2;
  --primary-strong: #ff9bb7;
  --primary-soft: #3b1d2a;
  --accent: #67d5b9;
  --accent-soft: #17392f;
  --warning: #f5c768;
  --warning-soft: #3a2f16;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.36);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101513;
    --bg-soft: #171f1b;
    --surface: #18211d;
    --surface-raised: #1f2924;
    --surface-muted: #121a16;
    --text: #eef5ef;
    --text-muted: #a5b3aa;
    --line: #2e3d35;
    --line-strong: #405248;
    --primary: #ff7da2;
    --primary-strong: #ff9bb7;
    --primary-soft: #3b1d2a;
    --accent: #67d5b9;
    --accent-soft: #17392f;
    --warning: #f5c768;
    --warning-soft: #3a2f16;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 14px 38px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 24px 70px rgba(0, 0, 0, 0.36);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--accent-soft), transparent 18%), transparent 31rem),
    linear-gradient(145deg, var(--bg), var(--bg-soft));
  font-family: var(--font-sans);
}

.skip-link {
  position: fixed;
  left: var(--space-4);
  top: var(--space-4);
  z-index: 10;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--surface);
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
}

.skip-link:focus {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: min(1360px, calc(100% - 32px));
  margin: 0 auto;
  padding: var(--space-4) 0 var(--space-8);
}

.topbar,
.brand-lockup,
.topbar-actions,
.section-heading,
.person-main,
.card-actions,
.theme-toggle,
.stats-row {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-3);
}

.brand-lockup {
  min-width: 0;
  gap: var(--space-4);
}

.gift-mark {
  position: relative;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 16px;
  background:
    linear-gradient(90deg, transparent 42%, rgba(255, 255, 255, 0.72) 42% 58%, transparent 58%),
    linear-gradient(0deg, transparent 42%, rgba(255, 255, 255, 0.72) 42% 58%, transparent 58%),
    linear-gradient(135deg, var(--primary), var(--warning));
  box-shadow: var(--shadow-md);
}

.gift-mark span {
  position: absolute;
  inset: -10px 15px auto;
  height: 16px;
  border: 4px solid var(--primary-strong);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
}

.topbar h1,
.overview h2,
.section-heading h2,
.draw-copy h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.8rem, 4vw, 2.25rem);
  line-height: 1;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 var(--space-2);
  color: var(--primary);
  font-size: var(--text-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  justify-content: flex-end;
  gap: var(--space-2);
}

.user-menu {
  min-height: 42px;
  display: flex;
  align-items: center;
}

.user-chip {
  min-height: 46px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-2);
  max-width: 320px;
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.user-avatar {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 900;
}

.user-copy {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-copy strong,
.user-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy strong {
  font-size: var(--text-sm);
}

.user-copy small {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.theme-toggle {
  min-height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface), transparent 12%);
  box-shadow: var(--shadow-sm);
}

.theme-toggle-option {
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 800;
}

.theme-toggle-option.active {
  background: var(--text);
  color: var(--surface);
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.42fr);
  gap: var(--space-4);
  align-items: end;
  margin-bottom: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-raised), transparent 4%), color-mix(in srgb, var(--accent-soft), transparent 38%)),
    var(--surface);
  box-shadow: var(--shadow-lg);
}

.overview h2 {
  max-width: 760px;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  line-height: 1.12;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.stepper {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.stepper button {
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 850;
  text-align: center;
}

.stepper button.active {
  border-color: color-mix(in srgb, var(--primary), var(--line) 35%);
  background: var(--primary-soft);
  color: var(--primary-strong);
}

.notice-strip {
  grid-column: 1 / -1;
  padding: var(--space-3) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--warning), var(--line) 35%);
  border-radius: var(--radius-md);
  background: var(--warning-soft);
  color: var(--text);
  line-height: 1.5;
}

.notice-strip strong {
  color: var(--primary-strong);
}

.ad-slot {
  position: relative;
  overflow: hidden;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface), transparent 10%);
  box-shadow: var(--shadow-sm);
}

.ad-slot > span {
  position: absolute;
  top: var(--space-2);
  left: var(--space-3);
  z-index: 1;
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.ad-slot-top {
  margin-top: calc(var(--space-4) * -1);
  margin-bottom: var(--space-5);
}

.ad-slot-inline {
  min-height: 250px;
  margin-top: var(--space-5);
}

.adsbygoogle {
  min-height: inherit;
}

.stat-tile {
  min-height: 78px;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--surface-raised), transparent 10%);
}

.stat-tile span {
  display: block;
  font-size: var(--text-2xl);
  font-weight: 800;
  line-height: 1;
}

.stat-tile p {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: start;
}

.main-column {
  display: grid;
  gap: var(--space-4);
}

.workspace,
.game-panel,
.message-panel,
.draw-panel,
.results {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface), transparent 2%);
  box-shadow: var(--shadow-md);
}

.workspace,
.message-panel,
.results {
  padding: var(--space-5);
}

.game-panel {
  margin-bottom: var(--space-4);
  padding: var(--space-5);
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(170px, 1fr) minmax(190px, 1fr) minmax(120px, 0.65fr) minmax(150px, 0.75fr);
  gap: var(--space-3);
  align-items: end;
}

.game-support {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.45fr);
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.side-panel {
  display: grid;
  gap: var(--space-4);
  position: sticky;
  top: var(--space-4);
}

.draw-panel {
  padding: var(--space-4);
}

.message-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: var(--space-4);
  align-items: start;
}

.message-editor {
  display: grid;
  gap: var(--space-3);
}

.variables-card {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.variables-card h3 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-base);
}

.wizard-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.section-heading {
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

.section-heading h2,
.draw-copy h2 {
  font-size: var(--text-xl);
  line-height: 1.2;
}

.compact {
  margin-bottom: var(--space-4);
}

.counter,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 800;
  white-space: nowrap;
}

.participant-form {
  display: grid;
  grid-template-columns: minmax(140px, 0.9fr) minmax(160px, 1fr) minmax(180px, 1.1fr) auto;
  gap: var(--space-3);
  align-items: end;
  margin-bottom: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.helper-panel {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.helper-panel span,
.person-id {
  display: inline-grid;
  place-items: center;
  min-width: 48px;
  min-height: 30px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: var(--text-xs);
  font-weight: 900;
}

.helper-panel p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.import-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.import-strip h3 {
  margin: 0;
  font-size: var(--text-base);
}

.import-strip p {
  margin: 4px 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.import-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.file-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.bulk-panel {
  display: grid;
  gap: var(--space-3);
  margin: calc(var(--space-4) * -1) 0 var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

label,
.field {
  display: grid;
  gap: var(--space-2);
}

label span,
.field span {
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  color: var(--text);
  outline: 0;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input {
  height: 44px;
  padding: 0 var(--space-3);
}

select {
  height: 44px;
  padding: 0 var(--space-3);
}

textarea {
  min-height: 112px;
  padding: var(--space-3);
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
summary:focus-visible,
#mainContent:focus {
  outline: 2px solid transparent;
  border-color: var(--focus);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus), transparent 78%);
}

.participant-form button,
.primary-button,
.ghost-button,
.mini-button,
.icon-button {
  min-height: 42px;
  border-radius: var(--radius-md);
  font-weight: 800;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.primary-button,
.ghost-button,
.mini-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  text-decoration: none;
}

.participant-form button,
.primary-button {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #ffffff;
  box-shadow: 0 14px 28px color-mix(in srgb, var(--primary), transparent 74%);
}

.participant-form button {
  padding: 0 var(--space-5);
}

.primary-button,
.ghost-button.wide {
  width: 100%;
}

.ghost-button,
.mini-button,
.icon-button {
  border: 1px solid var(--line);
  background: var(--surface-raised);
  color: var(--text);
}

.icon-button {
  width: 42px;
  display: inline-grid;
  place-items: center;
  font-size: var(--text-lg);
  line-height: 1;
}

.mini-button {
  min-height: 34px;
  padding: 0 var(--space-3);
  color: var(--text);
  font-size: var(--text-xs);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.participant-list,
.assignment-grid {
  display: grid;
  gap: var(--space-3);
}

.empty-state {
  min-height: 128px;
  display: grid;
  align-content: center;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent-soft), transparent 22%), transparent 72%),
    var(--surface-muted);
  color: var(--text-muted);
  font-weight: 700;
}

.empty-state strong {
  color: var(--text);
  font-size: var(--text-lg);
}

.empty-state span {
  max-width: 640px;
  line-height: 1.55;
}

.empty-state .mini-button {
  width: fit-content;
  margin-top: var(--space-2);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.auth-panel {
  width: min(100%, 440px);
  display: grid;
  gap: var(--space-5);
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface), transparent 5%);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: 900;
  text-decoration: none;
}

.auth-heading,
.oauth-stack,
.auth-form {
  display: grid;
  gap: var(--space-3);
}

.auth-heading h1,
.auth-heading p,
.auth-switch {
  margin: 0;
}

.auth-heading p:not(.eyebrow),
.auth-switch {
  color: var(--text-muted);
}

.auth-oauth {
  width: 100%;
}

.auth-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
  height: 1px;
  content: "";
  background: var(--line);
}

.auth-message {
  margin: 0;
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--primary), transparent 55%);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 700;
}

.auth-message[data-type="success"] {
  border-color: color-mix(in srgb, var(--accent), transparent 55%);
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-switch {
  text-align: center;
}

.participant-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.person-main {
  min-width: 0;
  gap: var(--space-3);
}

.person-id {
  align-self: center;
}

.avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--warning), var(--accent));
  color: #151a17;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.participant-card h3,
.assignment-card h3 {
  margin: 0;
  font-size: var(--text-base);
}

.participant-card p {
  margin: 3px 0 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.card-actions {
  gap: var(--space-2);
}

.remove-button {
  color: var(--primary);
}

.exclusions {
  grid-column: 1 / -1;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.exclusion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-2);
}

.checkbox-pill {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  color: var(--text);
  font-weight: 750;
}

.checkbox-pill input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.field + .field {
  margin-top: var(--space-3);
}

.advanced-options {
  margin-top: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  padding: 0;
}

.advanced-options summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 850;
}

.advanced-options summary::after {
  content: "+";
  color: var(--primary);
  font-size: var(--text-lg);
  line-height: 1;
}

.advanced-options[open] summary::after {
  content: "−";
}

.advanced-fields {
  display: grid;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-3);
}

.advanced-fields .field + .field {
  margin-top: 0;
}

.instructions-card {
  margin: 0;
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.instructions-card h3 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-base);
}

.instructions-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.instructions-card ol {
  margin: var(--space-2) 0 0;
  padding-left: 1.25rem;
  color: var(--text);
}

.instructions-card li + li {
  margin-top: var(--space-2);
}

.draw-panel {
  display: grid;
  gap: var(--space-2);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--primary-soft), transparent 15%), transparent 72%),
    var(--surface);
}

.secondary-actions {
  display: grid;
  gap: var(--space-2);
}

.draw-copy p:last-child {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  line-height: 1.45;
}

.results {
  margin-top: var(--space-5);
}

.assignment-grid {
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.assignment-card {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-raised);
  box-shadow: var(--shadow-sm);
}

.assignment-card textarea {
  min-height: 168px;
  background: var(--surface-muted);
}

.assignment-card textarea[data-private-message] {
  font-weight: 750;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--text);
  color: var(--surface);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
  box-shadow: var(--shadow-lg);
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.ad-consent {
  position: fixed;
  right: var(--space-5);
  bottom: var(--space-5);
  z-index: 30;
  width: min(100% - 40px, 520px);
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-raised);
  box-shadow: var(--shadow-lg);
}

.ad-consent h2,
.ad-consent p {
  margin: 0;
}

.ad-consent h2 {
  font-size: var(--text-lg);
}

.ad-consent p {
  color: var(--text-muted);
  line-height: 1.5;
}

.ad-consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.legal-footer {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-6);
  padding: var(--space-4);
  color: var(--text-muted);
}

.legal-footer a,
.legal-page a {
  color: var(--primary);
  font-weight: 850;
}

.legal-page {
  width: min(920px, calc(100% - 32px));
  margin: 0 auto;
  padding: var(--space-6) 0 var(--space-10);
}

.legal-card {
  margin-top: var(--space-4);
  padding: var(--space-6);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.legal-card h1 {
  margin: 0 0 var(--space-5);
  font-size: clamp(2rem, 5vw, var(--text-3xl));
  line-height: 1.05;
}

.legal-card h2 {
  margin: var(--space-6) 0 var(--space-2);
  font-size: var(--text-xl);
}

.legal-card p,
.legal-card li,
.legal-card dd {
  color: var(--text-muted);
  line-height: 1.65;
}

.legal-table {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-muted);
}

.legal-table dt {
  font-weight: 900;
}

.legal-table dd {
  margin: 0;
}

.reveal-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.reveal-card {
  width: min(620px, 100%);
  padding: var(--space-8);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.reveal-card h1 {
  margin: 0 0 var(--space-5);
  font-size: clamp(1.7rem, 5vw, var(--text-3xl));
  line-height: 1.05;
}

.reveal-card p {
  color: var(--text-muted);
  line-height: 1.55;
}

.reveal-result {
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  border-radius: var(--radius-md);
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: var(--text-2xl);
  font-weight: 900;
}

.reference-sections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
  margin-top: 0;
}

.reference-sections article {
  padding: var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.reference-sections h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--text-xl);
}

.reference-sections ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.idea-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.idea-tags span {
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: 850;
}

details:not(.advanced-options) {
  border-top: 1px solid var(--line);
  padding: var(--space-3) 0;
}

summary {
  cursor: pointer;
  font-weight: 850;
}

details:not(.advanced-options) p {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  line-height: 1.5;
}

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

@media (max-width: 940px) {
  .side-panel {
    position: static;
  }

  .topbar,
  .overview {
    align-items: stretch;
  }

  .topbar,
  .overview,
  .layout,
  .message-layout,
  .game-grid,
  .game-support {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 720px) {
  .participant-form,
  .stats-row,
  .stepper,
  .reference-sections {
    grid-template-columns: 1fr;
  }

  .import-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading,
  .participant-card {
    align-items: stretch;
  }

  .participant-card {
    grid-template-columns: 1fr;
  }

  .card-actions {
    justify-content: flex-start;
  }

  .reference-sections {
    order: 3;
  }

  .legal-table {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .app-shell {
    width: min(100% - 20px, 1220px);
    padding-top: var(--space-4);
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .gift-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
  }

  .theme-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .overview,
  .workspace,
  .game-panel,
  .message-panel,
  .draw-panel,
  .results {
    padding: var(--space-4);
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .topbar,
  .overview,
  .workspace,
  .side-panel,
  .reference-sections,
  .copy-assignment,
  .toast,
  .ad-consent,
  .ad-slot,
  .assignment-card .mini-button {
    display: none !important;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .results {
    display: block !important;
    border: 0;
    box-shadow: none;
  }

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

  .assignment-card {
    break-inside: avoid;
    min-height: 240px;
  }
}
