/* DC20 Table: shared design system for the GM screen and the prep screen.
   See DESIGN.md for the principles. Page stylesheets only add layout on top of this. */

:root {
  /* surfaces and text */
  --paper: #f5f2ec;
  --card: #ffffff;
  /* Bars that float over the page (the player's header and dock): their own surface and shadows. */
  --bar: #e3dccf;
  /* The player's dock sits higher than the page: a light top edge and a deep shadow above it. */
  --lift-dock: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 -12px 28px rgba(40, 30, 20, 0.3), 0 -2px 6px rgba(40, 30, 20, 0.22);
  --lift-up: 0 -6px 18px rgba(40, 30, 20, 0.16), 0 -1px 4px rgba(40, 30, 20, 0.08);
  --lift-down: 0 6px 18px rgba(40, 30, 20, 0.14), 0 1px 4px rgba(40, 30, 20, 0.08);
  --ink: #1c1917;
  --mid: #6f675f;
  --rule: #e4ddd2;
  --chip: #f0ebe3;
  --scrim: rgba(20, 14, 10, 0.45);
  /* accent and kinds */
  --accent: #9b2420;
  --pc: #3d2f8f;
  --monster: #9b2420;
  /* meaning */
  --hp: #2f7a42;
  --temp: #3a7fb3;
  --mana: #5847b8;
  --stamina: #c06a1c;
  --rest: #7a6f5d;
  --ap: #17818f;
  /* The player's Abilities list: one colour per kind (class features use their class colour). */
  --kind-spell: var(--mana); --kind-maneuver: var(--card-martial-ink); /* Action Points: teal, apart from HP, Mana and Stamina */
  --bloodied: #c0680f;
  --well: #b3151c;
  --down: #8a837c;
  /* turn: the gold of the player display's Now and Next tags, with dark text on it */
  --next: #e2c27e; --next-ink: #1a130b;
  /* spell and maneuver cards (from the printed spell cards): header per source, school colours */
  --card-arcane: #2d1f5e; --card-divine: #9a6b00; --card-primal: #1a3d1a; --card-martial: #1c2e42; --card-martial-ink: #1c2e42; --card-none: #4a4440;
  --card-rule: #141210; --card-soft: #d6d0c6; --card-tint: #f6f5f2; --card-band: #555555; --card-band-ink: #ffffff;
  --card-school-astromancy: #3b3b8f; --card-school-conjuration: #6e1a4a; --card-school-divination: #2a5a00; --card-school-elemental: #7a3200;
  --card-school-enchantment: #8a1f5c; --card-school-invocation: #006060; --card-school-nullification: #2a2a3a; --card-school-transmutation: #1a4a6e;
  --card-type-attack: #6b1d12; --card-type-defence: #1a4a6e; --card-type-grapple: #5a4a12; --card-type-utility: #2a5a00;
  --card-school-none: #6f675f; --card-type-none: #6f675f;
  /* class feature cards: a header colour per class (from the printed class feature cards); the same
     colour for names and the footer on the card (in dark mode those use the text colour) */
  --class-berserker: #9b1c1c; --class-monk: #b0541a; --class-cleric: #9a7a12; --class-hunter: #5a6b1f; --class-druid: #2e6b2e; --class-spellblade: #0e6a6a; --class-commander: #1d4f8c; --class-champion: #3c4a5c; --class-wizard: #2a2f7a; --class-sorcerer: #6a2a9a; --class-warlock: #4a1a4a; --class-bard: #a3245e; --class-rogue: #2a2a2a; --class-none: #4a4440;
  --class-ink-berserker: #9b1c1c; --class-ink-monk: #b0541a; --class-ink-cleric: #9a7a12; --class-ink-hunter: #5a6b1f; --class-ink-druid: #2e6b2e; --class-ink-spellblade: #0e6a6a; --class-ink-commander: #1d4f8c; --class-ink-champion: #3c4a5c; --class-ink-wizard: #2a2f7a; --class-ink-sorcerer: #6a2a9a; --class-ink-warlock: #4a1a4a; --class-ink-bard: #a3245e; --class-ink-rogue: #2a2a2a; --class-ink-none: #4a4440;
  /* type */
  --font: 'Figtree', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --radius: 0;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bar: #2b2623;
    --lift-dock: inset 0 1.5px 0 rgba(255, 255, 255, 0.16), 0 -16px 36px rgba(0, 0, 0, 0.85);
    --lift-up: 0 -8px 22px rgba(0, 0, 0, 0.55), 0 -1px 0 rgba(255, 255, 255, 0.06);
    --lift-down: 0 8px 22px rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.06);
    --paper: #121010; --card: #1c1918; --ink: #f1ebe3; --mid: #a49a8f; --rule: #2f2a27; --chip: #26211f;
    --scrim: rgba(0, 0, 0, 0.6);
    --accent: #e0645a; --pc: #a99cf5; --monster: #e0645a;
    --hp: #63c27a; --temp: #6cb3e6; --mana: #a497f5; --stamina: #f0a35c; --rest: #bdb3a2; --ap: #5ccad6;
    --bloodied: #f0a24a; --well: #ff6b5e; --down: #8a837c;
    --card-martial-ink: #8fb0d6;
    --card-rule: #8d847b; --card-soft: #3a3431; --card-tint: #221e1c; --card-band: #3a3633; --card-band-ink: #f1ebe3;
    --card-school-astromancy: #a9a9f0; --card-school-conjuration: #e58fc0; --card-school-divination: #9fd36a; --card-school-elemental: #e59a5c;
    --card-school-enchantment: #f08cc4; --card-school-invocation: #4fc1c1; --card-school-nullification: #b9b9d6; --card-school-transmutation: #7fb6e0;
    --card-type-attack: #e0806f; --card-type-defence: #7fb6e0; --card-type-grapple: #d6bd6a; --card-type-utility: #9fd36a;
    --card-school-none: #a49a8f; --card-type-none: #a49a8f;
    --class-ink-berserker: var(--ink); --class-ink-monk: var(--ink); --class-ink-cleric: var(--ink); --class-ink-hunter: var(--ink); --class-ink-druid: var(--ink); --class-ink-spellblade: var(--ink); --class-ink-commander: var(--ink); --class-ink-champion: var(--ink); --class-ink-wizard: var(--ink); --class-ink-sorcerer: var(--ink); --class-ink-warlock: var(--ink); --class-ink-bard: var(--ink); --class-ink-rogue: var(--ink); --class-ink-none: var(--ink);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; font-variant-numeric: tabular-nums; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.35 var(--font); }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
h2 { font-size: 18px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
p { margin: 0; }
a { color: var(--accent); }
.label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--mid); margin: 0 0 6px;
}
.hint { color: var(--mid); font-size: 13px; margin: 4px 0 10px; }
.hint.small { font-size: 12px; margin: 2px 0 8px; }

/* ---------- buttons ---------- */
button {
  font: 600 15px var(--font); color: inherit; background: none; cursor: pointer;
  border: 1.5px solid transparent; border-radius: 0; padding: 8px 12px; min-height: 44px;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; cursor: default; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.primary { background: var(--accent); color: #fff; font-weight: 700; }
.secondary { background: var(--card); border-color: var(--rule); color: var(--ink); font-weight: 700; }
.ghost { border-color: var(--rule); background: transparent; }
.ghost.small, a.ghost.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.danger { color: var(--accent); }
.wide { width: 100%; margin-top: 10px; }
.icon { min-width: 44px; padding: 0; font-size: 20px; border-color: var(--rule); }
a.ghost { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); border: 1.5px solid var(--rule); border-radius: 0; }

/* ---------- inputs ---------- */
input, select, textarea {
  font: 15px var(--font); color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 0; padding: 8px 10px; min-height: 42px; width: 100%; min-width: 0;
}
input::placeholder, textarea::placeholder { color: var(--mid); opacity: 0.6; }
textarea { resize: vertical; line-height: 1.45; }
input[type=checkbox], input[type=radio] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- cards and tags ---------- */
.card { background: var(--card); border: 1px solid var(--rule); border-radius: 0; padding: 12px; }
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 0; color: #fff; background: var(--mid);
}
.badge.bloodied { background: var(--bloodied); }
.badge.well { background: var(--well); }
.badge.down { background: var(--down); }
.badge.ctag { background: var(--c); }
.badge i { font-style: normal; font-weight: 600; opacity: 0.9; }

/* ---------- bottom panel ---------- */
.sheet-bg { position: fixed; inset: 0; background: var(--scrim); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; max-width: 620px; margin: 0 auto;
  max-height: 88vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--card); border-radius: 0;
  padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
}
.sheet::before { content: ''; display: block; width: 38px; height: 4px; border-radius: 0; background: var(--rule); margin: 0 auto 10px; }
/* Hidden means hidden, whatever display a class gives an element (buttons, links styled as buttons). */
[hidden] { display: none !important; }
.sheet[hidden], .sheet-bg[hidden] { display: none; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding-bottom: 8px; margin-bottom: 10px; border-bottom: 1px solid var(--rule); }
.sheet-head .label { margin: 0 0 2px; }
.sheet-head.pc h2 { color: var(--pc); }
.sheet-head.monster h2 { color: var(--monster); }
.sheet-head .icon { min-height: 36px; min-width: 36px; font-size: 16px; }

/* ---------- messages ---------- */
.toast {
  position: fixed; left: 50%; top: calc(10px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 0; font-size: 14px;
  max-width: calc(100% - 32px);
}
.toast[hidden] { display: none; }
.offline { background: var(--bloodied); color: #fff; text-align: center; padding: 4px; font-size: 13px; font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
