/* ------------------------------------------------------------------------------------------------------------
   Mandat game look for every screen outside the board: the welcome page, sign up, profile, character slots, the
   character maker, the lobby and admin. It follows the board's own style (warm cream paper, chunky buttons with a
   pressed edge, the purple of the area card, gold for rewards, green for "go"), so moving from one screen to the
   next feels like one game. Loaded last; it changes colours, shapes and spacing only, never what is on a screen.
   ------------------------------------------------------------------------------------------------------------ */
:root, html[data-theme="light"] {
  --app-bg: #fdf1df;
  --app-card: #fffaf1;
  --app-soft: #fff1d9;
  --app-line: #efd9b4;
  --app-ink: #3d2a1d;
  --app-text: #7d5f42;
  --app-accent: #8e1fa6;
  --app-accent-hover: #6f1483;
  --app-accent-ink: #fff;
  --app-mint: #e2f7e6;
  --app-mint-ink: #1d7a45;
  --app-lilac: #f6e3fb;
  --app-lilac-ink: #7a1590;
  --app-peach: #ffecc9;
  --app-peach-ink: #8b4a10;
  --app-shadow: 0 5px 0 #ecd3a8, 0 14px 30px rgba(120, 80, 20, .13);
  --g-edge: #ecd3a8;
  --g-green: #3cbb60;
  --g-green-deep: #22893f;
  --g-green-edge: #1a6b31;
  --g-gold: #ffd25a;
  --g-gold-deep: #f2a900;
  --g-gold-edge: #b47600;
  --g-purple: #b829c9;
  --g-purple-deep: #771491;
  --g-purple-edge: #4f0b61;
  --g-sky: linear-gradient(180deg, #bfe6ff 0%, #e7f6ff 52%, #dff3c9 100%);
  --g-page: repeating-linear-gradient(135deg, rgba(255, 255, 255, .5) 0 28px, rgba(255, 255, 255, 0) 28px 56px),
    radial-gradient(circle at 18% 0%, #fff9ee 0, transparent 46%), linear-gradient(180deg, #fff3df 0%, #f8e2c6 100%);
  --g-font: 'Segoe UI', 'Nunito', Inter, system-ui, -apple-system, sans-serif;
}
html[data-theme="dark"] {
  --app-bg: #2a1d26;
  --app-card: #382630;
  --app-soft: #45303b;
  --app-line: #5f4453;
  --app-ink: #fff4e4;
  --app-text: #e0c6ad;
  --app-accent: #e07bf2;
  --app-accent-hover: #f0a6fb;
  --app-accent-ink: #2a0f30;
  --app-mint: #1f4a32;
  --app-mint-ink: #a8f0c0;
  --app-lilac: #4f2a5a;
  --app-lilac-ink: #f3c9ff;
  --app-peach: #5a3b20;
  --app-peach-ink: #ffd7a6;
  --app-shadow: 0 5px 0 #1a1117, 0 14px 30px rgba(0, 0, 0, .35);
  --g-edge: #1a1117;
  --g-sky: linear-gradient(180deg, #3c3a63 0%, #4b3f66 55%, #3d4a3a 100%);
  --g-page: repeating-linear-gradient(135deg, rgba(255, 255, 255, .035) 0 28px, rgba(255, 255, 255, 0) 28px 56px),
    linear-gradient(180deg, #2e2029 0%, #21161d 100%);
}

/* ---- Page, type and the brand -------------------------------------------------------------------------------- */
html[data-theme] body { background: var(--app-bg); }
html[data-theme] :is(.landing, .creator-shell, .slots-shell, .admin-shell, .mandat-app, .boot) {
  background: var(--g-page);
  background-attachment: fixed;
  color: var(--app-ink);
  font-family: var(--g-font);
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(h1, h2, h3, .brand, .button) {
  font-family: var(--g-font);
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(h1, h2) { font-weight: 900; letter-spacing: -.025em; }
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) .eyebrow { color: var(--g-gold-edge); font-weight: 900; letter-spacing: .14em; }
html[data-theme=dark] :is(.landing, .game-shell, .mandat-app, .admin-shell) .eyebrow { color: var(--g-gold); }
html[data-theme] .brand { color: var(--g-purple-deep); text-shadow: 0 2px 0 #fff, 0 3px 0 rgba(120, 60, 0, .15); font-weight: 900; }
html[data-theme=dark] .brand { color: #fff4e4; text-shadow: 0 2px 0 #000; }
html[data-theme] .brand > span { color: var(--g-gold-deep); }
html[data-theme] .boot p { color: var(--app-text); font-weight: 700; }
html[data-theme] .brand-mark { color: var(--g-purple-deep); }

/* ---- Headers: the same cream bar as the game's top HUD ------------------------------------------------------- */
html[data-theme] :is(.mandat-top, .game-header) {
  background: linear-gradient(180deg, var(--app-card), var(--app-soft));
  border-bottom: 3px solid var(--app-line);
  box-shadow: 0 3px 0 rgba(160, 110, 40, .1);
}
html[data-theme] .web-header { padding: 6px 0; }

/* The brand sits at the start of the bar, so the buttons beside it never run into it. */
html[data-theme] :is(.slots-shell, .creator-shell) .game-header .brand { position: static; transform: none; flex: 0 0 auto; }
html[data-theme] :is(.slots-shell, .creator-shell) .game-header .brand small { display: none; }
html[data-theme] :is(.slots-shell, .creator-shell) .game-header .header-right-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
html[data-theme] .web-header { flex-wrap: wrap; height: auto; row-gap: 8px; }
html[data-theme] .web-header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 1100px) { html[data-theme] .game-header .account-lock-pills { display: none; } }
@media (max-width: 560px) {
  html[data-theme] :is(.game-header, .mandat-top, .web-header) .theme-switcher { display: none; }
  html[data-theme] :is(.game-header, .mandat-top) { padding-inline: 10px; gap: 8px; }
  html[data-theme] .game-header .brand { font-size: 24px; }
}

/* ---- Buttons: chunky, with a pressed edge ------------------------------------------------------------------ */
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.mandat-btn, .button, .icon-button, .mandat-icon, .google-button) {
  border: 2px solid var(--app-line);
  border-radius: 14px;
  background: var(--app-card);
  color: var(--app-ink);
  font-weight: 800;
  box-shadow: 0 3px 0 var(--g-edge);
  transition: transform .12s ease, box-shadow .12s ease, filter .15s ease, background .15s ease;
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.mandat-btn, .button, .icon-button, .mandat-icon, .google-button):hover:not(:disabled) {
  transform: translateY(-1px); filter: brightness(1.04); border-color: var(--app-accent);
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.mandat-btn, .button, .icon-button, .mandat-icon, .google-button):active:not(:disabled) {
  transform: translateY(2px); box-shadow: 0 1px 0 var(--g-edge);
}
/* The main "go" action on every screen is the green of the board's Roll button. */
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.button.gold, .mandat-btn.primary, .mandat-icon.primary, .mandat-cta) {
  background: linear-gradient(180deg, #5bd27b 0%, var(--g-green) 45%, var(--g-green-deep) 100%);
  border-color: var(--g-green-edge);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .28);
  box-shadow: 0 4px 0 var(--g-green-edge), 0 8px 18px rgba(30, 120, 60, .22);
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.button.gold, .mandat-btn.primary, .mandat-icon.primary, .mandat-cta):hover:not(:disabled) {
  background: linear-gradient(180deg, #6ee08c 0%, #45c66a 45%, #25954a 100%); border-color: var(--g-green-edge); color: #fff;
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(.button.gold, .mandat-btn.primary, .mandat-icon.primary, .mandat-cta):active:not(:disabled) {
  box-shadow: 0 1px 0 var(--g-green-edge);
}
html[data-theme] .button.gold::after { display: none; }
/* Secondary actions in the board's purple. */
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.button.secondary, .header-right-actions > .button) {
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep));
  border-color: var(--g-purple-edge);
  color: #fff;
  box-shadow: 0 3px 0 var(--g-purple-edge);
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.danger-button, .mandat-btn.danger) {
  background: #fff0ea; border: 2px solid #f3c1ad; color: #c4320a; box-shadow: 0 3px 0 #e9b39d; border-radius: 14px;
}
html[data-theme] :is(.mandat-icon, .icon-button) svg { width: 20px; height: 20px; }
html[data-theme] .mandat-fullscreen-toggle { color: var(--g-purple-deep); }

/* ---- Tabs and switches: the area card's purple pill ------------------------------------------------------- */
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.segmented, .wizard-steps, .lang-switcher, .theme-switcher, .adm-tabs) {
  background: var(--app-soft);
  border: 2px solid var(--app-line);
  border-radius: 14px;
  padding: 4px;
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.segmented, .wizard-steps, .lang-switcher, .theme-switcher, .adm-tabs) button {
  border-radius: 10px; font-weight: 800; color: var(--app-text); background: transparent; border-color: transparent;
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.segmented, .wizard-steps, .lang-switcher, .theme-switcher, .adm-tabs) button[aria-pressed="true"],
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) :is(.wizard-steps button[aria-current], .adm-tabs [aria-selected="true"]) {
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 0 var(--g-purple-edge);
}
html[data-theme] .gender-picker > button[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)) !important; color: #fff !important; border-color: var(--g-purple-edge) !important;
}

/* ---- Cards and panels: cream paper with a thick edge ---------------------------------------------------- */
html[data-theme] :is(.auth-card, .mandat-card, .slot-card, .mandat-ops-card, .catalog-list, .admin-editor, .starter-note) {
  background: var(--app-card);
  border: 2px solid var(--app-line);
  border-radius: 22px;
  box-shadow: var(--app-shadow);
  color: var(--app-ink);
}
html[data-theme] :is(.slots-panel, .customizer) { background: var(--app-card); border-color: var(--app-line); }
html[data-theme] .slot-card { border-style: solid; }
html[data-theme] .slot-card:has(.slot-avatar) { border-color: var(--g-gold-deep); box-shadow: 0 5px 0 var(--g-gold-edge), 0 14px 30px rgba(180, 118, 0, .18); }
html[data-theme] :is(.slot-number, .step-badge, .status-pill, .header-step, .edition) {
  background: var(--app-soft); color: var(--g-purple-deep); border: 2px solid var(--app-line); border-radius: 99px; font-weight: 900;
}
html[data-theme=dark] :is(.slot-number, .step-badge, .status-pill, .header-step, .edition) { color: var(--app-accent); }
html[data-theme] .lock-pill { background: var(--app-card); border: 2px solid var(--app-line); border-radius: 99px; color: var(--app-ink); padding: 4px 12px; flex-direction: row; align-items: center; gap: 6px; box-shadow: 0 2px 0 var(--g-edge); }
html[data-theme] .lock-pill small { font-size: 10px; color: var(--app-text); }
html[data-theme] .lock-pill strong { color: var(--app-ink); font-size: 12px; }
html[data-theme] .lock-pill strong .icon { width: 14px; height: 14px; color: var(--g-gold-deep); }
html[data-theme] .permanent-notice, html[data-theme] .landing .auth-card p.permanent-notice {
  background: var(--app-peach); color: var(--app-peach-ink); border: 2px dashed #f2c477; border-radius: 14px;
}

/* ---- Fields ------------------------------------------------------------------------------------------- */
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea) {
  background: #fff;
  border: 2px solid var(--app-line);
  border-radius: 12px;
  color: var(--app-ink);
  min-height: 46px;
  font-weight: 600;
}
html[data-theme=dark] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(input:not([type=checkbox]):not([type=radio]):not([type=color]), select, textarea) { background: var(--app-soft); }
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell, #menu-dialog) :is(input, select, textarea):focus {
  border-color: var(--app-accent); box-shadow: 0 0 0 4px rgba(242, 169, 0, .25); outline: none;
}
html[data-theme] :is(.landing, .game-shell, .mandat-app, .admin-shell) label { color: var(--app-text); font-weight: 800; }

/* ---- 3D stages: the board's sky ------------------------------------------------------------------------ */
html[data-theme] .landing .landing-stage, html[data-theme] .mandat-hero { border: 3px solid #fff; box-shadow: var(--app-shadow); }
html[data-theme] :is(.creator-shell, .slots-shell) .character-preview { background: var(--g-sky); }
html[data-theme=dark] .landing .landing-stage, html[data-theme=dark] .mandat-hero { border-color: var(--app-line); }
html[data-theme] :is(.creator-shell, .slots-shell) .character-preview { border-width: 0 3px 0 0; border-color: var(--app-line); box-shadow: none; }
html[data-theme] .character-preview .character-nameplate {
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)); border: 2px solid #fff; color: #fff; box-shadow: 0 4px 0 var(--g-purple-edge);
}
html[data-theme] :is(.preview-tools button, .stage-shuffle-btn, .world-caption, .wizard-preview-label) {
  background: var(--app-card); color: var(--app-ink); border: 2px solid var(--app-line); border-radius: 99px; box-shadow: 0 3px 0 var(--g-edge); font-weight: 800;
}
html[data-theme] .landing .stage-shuffle-btn { background: linear-gradient(180deg, var(--g-gold), var(--g-gold-deep)); border-color: var(--g-gold-edge); color: #3d2a00; box-shadow: 0 3px 0 var(--g-gold-edge); }

/* ---- Welcome page ---------------------------------------------------------------------------------------- */
html[data-theme] .landing { display: flex; flex-direction: column; min-height: 100dvh; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
html[data-theme] .landing .landing-layout { flex: 1; align-items: center; }
html[data-theme] .landing .landing-story h1 { color: var(--app-ink); text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(160, 100, 20, .12); }
html[data-theme=dark] .landing .landing-story h1 { text-shadow: 0 3px 0 #000; }
html[data-theme] .landing .landing-story h1 em { color: var(--g-purple-deep); -webkit-text-fill-color: currentColor; background: none; text-shadow: 0 3px 0 #fff, 0 5px 0 rgba(119, 20, 145, .18); }
html[data-theme=dark] .landing .landing-story h1 em { color: var(--app-accent); text-shadow: 0 3px 0 #000; }
html[data-theme] .landing .landing-copy > p { color: var(--app-text); font-weight: 600; }
html[data-theme] .landing .auth-card { position: relative; overflow: hidden; padding-top: clamp(26px, 3.4vw, 40px); }
html[data-theme] .landing .auth-card::before {
  content: ''; position: absolute; inset: 0 0 auto; height: 8px;
  background: linear-gradient(90deg, var(--g-purple), var(--g-gold-deep), var(--g-green));
}
html[data-theme] .landing .divider::before, html[data-theme] .landing .divider::after { border-color: var(--app-line); }
html[data-theme] .landing .web-footer { border-top: 2px dashed var(--app-line); font-weight: 600; }

/* ---- Character slots and the character maker ----------------------------------------------------------- */
html[data-theme] .slots-panel .slots-heading h2, html[data-theme] .customizer h2 { color: var(--app-ink); }
html[data-theme] .slot-avatar, html[data-theme] .slot-avatar-placeholder { border-radius: 14px; }
html[data-theme] .slot-avatar-placeholder { background: var(--app-soft); border: 2px dashed var(--app-line); }
html[data-theme] :is(.wizard-feature, .hair-card, .choice-chip) {
  background: #fff; border: 2px solid var(--app-line); border-radius: 16px; box-shadow: 0 3px 0 var(--g-edge); color: var(--app-ink);
}
html[data-theme=dark] :is(.wizard-feature, .hair-card, .choice-chip) { background: var(--app-soft); }
html[data-theme] :is(.wizard-feature, .hair-card, .choice-chip)[aria-pressed="true"] {
  border-color: var(--g-gold-deep); background: #fff6dc; box-shadow: 0 3px 0 var(--g-gold-edge), 0 0 0 3px rgba(242, 169, 0, .25);
}
html[data-theme=dark] :is(.wizard-feature, .hair-card, .choice-chip)[aria-pressed="true"] { background: #5a4220; }
html[data-theme] .swatches button { border: 3px solid #fff; box-shadow: 0 3px 0 var(--g-edge); }
html[data-theme] .swatches button[aria-pressed="true"] { outline: 3px solid var(--g-gold-deep); }
html[data-theme] .wizard-footer, html[data-theme] .creator-save { border-top: 2px dashed var(--app-line); background: transparent; }

/* ---- Lobby ------------------------------------------------------------------------------------------------ */
html[data-theme] .mandat-rail { background: transparent; }
html[data-theme] .mandat-rail :is(a, button) { border-radius: 14px; font-weight: 800; }
html[data-theme] .mandat-rail :is(a, button)[aria-current],
html[data-theme] .mandat-rail :is(a, button).active {
  background: linear-gradient(180deg, var(--g-purple), var(--g-purple-deep)); color: #fff; box-shadow: 0 3px 0 var(--g-purple-edge);
}
html[data-theme] .mandat-player { background: var(--app-card); border: 2px solid var(--app-line); border-radius: 18px; box-shadow: 0 3px 0 var(--g-edge); }
html[data-theme] .mandat-greeting h1 { color: var(--app-ink); }
html[data-theme] .mandat-hero-copy h2, html[data-theme] .mandat-hero-copy h1 { color: #2b1d10; text-shadow: 0 2px 0 rgba(255, 255, 255, .8); }
html[data-theme] .mandat-slot { background: linear-gradient(180deg, var(--g-gold), var(--g-gold-deep)); color: #3d2a00; border: 2px solid var(--g-gold-edge); border-radius: 99px; font-weight: 900; }

/* ---- Dialogs, toast and admin ------------------------------------------------------------------------- */
html[data-theme] #menu-dialog { border: 3px solid var(--app-line); border-radius: 24px; box-shadow: 0 8px 0 var(--g-edge), 0 24px 60px rgba(60, 30, 0, .3); }
html[data-theme] #toast { background: linear-gradient(180deg, #fffaf0, #ffefc9); color: var(--app-ink); border: 3px solid var(--g-gold-deep); box-shadow: 0 4px 0 var(--g-gold-edge), 0 12px 30px rgba(60, 30, 0, .25); font-weight: 800; }
html[data-theme] .admin-shell { min-height: 100dvh; }
html[data-theme] .admin-title h1 { color: var(--app-ink); }
html[data-theme] .admin-title p, html[data-theme] .catalog-row small, html[data-theme] .catalog-count { color: var(--app-text); }
html[data-theme] .catalog-row { border-top: 2px dashed var(--app-line); }
html[data-theme] .catalog-row b { color: var(--app-ink); }
html[data-theme] .catalog-row:is(:hover, .selected) { background: var(--app-soft); }
html[data-theme] .catalog-symbol { background: var(--app-soft); color: var(--g-purple-deep); border: 2px solid var(--app-line); }

/* ---- Full screen layouts that fit phones, tablets and laptops ---------------------------------------- */
html[data-theme] :is(.game-shell, .mandat-app) { min-height: 100dvh; }
@media (max-width: 700px) {
  html[data-theme] .landing { padding-inline: 14px; padding-top: max(12px, env(safe-area-inset-top)); }
  html[data-theme] .landing .landing-layout { margin-top: 10px; gap: 18px; }
  html[data-theme] .landing .landing-story h1 { font-size: clamp(34px, 11vw, 46px); }
  html[data-theme] .landing .auth-card { border-radius: 20px; }
  html[data-theme] :is(.mandat-btn, .button) { min-height: 46px; }
  html[data-theme] .web-footer { flex-direction: column; align-items: center; text-align: center; }
}
@media (min-width: 701px) and (max-width: 1100px) {
  html[data-theme] .landing { padding-inline: 24px; }
  html[data-theme] .landing .landing-layout { grid-template-columns: 1fr; max-width: 680px; margin-inline: auto; }
  html[data-theme] .landing .landing-story { text-align: center; align-items: center; }
  html[data-theme] .landing .landing-copy > p { margin-inline: auto; }
}
@media (min-width: 1101px) and (max-height: 820px) {
  /* Laptops: everything fits on one screen, like the game. */
  html[data-theme] .landing { padding-top: 14px; }
  html[data-theme] .landing .landing-layout { margin: 12px auto; }
  html[data-theme] .landing .landing-stage { height: clamp(250px, 42vh, 380px); }
  html[data-theme] .landing .auth-card { padding: 22px 26px; }
  html[data-theme] .landing .auth-card form { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme] :is(.mandat-btn, .button, .icon-button, .mandat-icon) { transition: none; }
}
