/* Shared base: theme tokens, buttons, cards, lists, sheets, toast. Colors follow the ruleset item colors
   (boss green, invader red, small goal blue, trade grey, yugao purple, challenge gold). No inline styles (CSP). */
:root {
  --bg: #eceff3; --surface: #ffffff; --surface2: #f4f6f9; --ink: #1b2230; --muted: #566175; --line: #d3d9e3;
  --boss: #1f7a4d; --boss-soft: #dff1e7; --invader: #b3302e; --invader-soft: #f8e1e0;
  --goal: #2a62c4; --goal-soft: #e0e9f8; --trade: #566175; --trade-soft: #e6e9ef;
  --yugao: #7b3fa0; --yugao-soft: #eddff5; --gold: #94650a; --gold-soft: #f6ecd2;
  --danger: #b3302e; --on: #ffffff; --focus: #1b2230; --shadow: 0 1px 2px rgba(20, 30, 50, .08), 0 8px 24px rgba(20, 30, 50, .08);
  --font: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --num: "Bahnschrift", "Arial Narrow", "Roboto Condensed", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="contrast"]) {
    --bg: #0f1218; --surface: #1a1f2a; --surface2: #222836; --ink: #e8ecf4; --muted: #9aa5b8; --line: #303849;
    --boss: #4cc38a; --boss-soft: #16322a; --invader: #ff7b72; --invader-soft: #3a1f23;
    --goal: #7fa8ff; --goal-soft: #1c2a47; --trade: #9aa5b8; --trade-soft: #272d3b;
    --yugao: #c79bff; --yugao-soft: #2f2342; --gold: #e6b450; --gold-soft: #3a2f16;
    --danger: #ff7b72; --on: #0e1117; --focus: #e8ecf4; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
/* Display settings chosen in the app (saved on this device only). */
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #1a1f2a; --surface2: #222836; --ink: #e8ecf4; --muted: #9aa5b8; --line: #303849;
  --boss: #4cc38a; --boss-soft: #16322a; --invader: #ff7b72; --invader-soft: #3a1f23;
  --goal: #7fa8ff; --goal-soft: #1c2a47; --trade: #9aa5b8; --trade-soft: #272d3b;
  --yugao: #c79bff; --yugao-soft: #2f2342; --gold: #e6b450; --gold-soft: #3a2f16;
  --danger: #ff7b72; --on: #0e1117; --focus: #e8ecf4; --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="contrast"] {
  --bg: #000000; --surface: #0b0b0b; --surface2: #1a1a1a; --ink: #ffffff; --muted: #d0d0d0; --line: #8a8a8a;
  --boss: #00a651; --boss-soft: #003a1f; --invader: #e0201b; --invader-soft: #3d0907;
  --goal: #1f6fff; --goal-soft: #00183d; --trade: #6b6b6b; --trade-soft: #222222;
  --yugao: #9b3bd6; --yugao-soft: #2a0f3d; --gold: #ffc400; --gold-soft: #3a2e00;
  --danger: #ff5a52; --on: #ffffff; --focus: #ffff00; --shadow: none;
  color-scheme: dark;
}
:root[data-theme="contrast"] .gold { color: #000; }
:root[data-size="large"] body { font-size: 17px; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
a { color: var(--goal); }
h1, h2, h3 { margin: 0; line-height: 1.3; text-wrap: balance; }
.muted { color: var(--muted); }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; }

/* login */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.login { max-width: 420px; margin: 12vh auto 0; padding: 20px; }
.login h1 { font-size: 1.25rem; margin-bottom: 12px; }
label { display: block; margin: 12px 0; font-size: .9rem; }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 12px; font-size: 1rem; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.login button[type="submit"], .primary { width: 100%; padding: 14px; font-size: 1rem; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 700; }
#message { min-height: 1.4em; color: var(--danger); }
body > main.login { margin-inline: 16px; }
@media (min-width: 460px) { body > main.login { margin-inline: auto; } }

/* buttons */
.btn { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 14px 18px; border-radius: 16px; font-weight: 700; text-align: left; color: var(--on); transition: transform .06s; }
.btn:active { transform: scale(.985); }
.btn em { font-family: var(--num); font-style: normal; font-size: 2.2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.btn small { display: block; font-weight: 500; font-size: .78rem; opacity: .92; }
.boss { background: var(--boss); } .invader { background: var(--invader); } .goalb { background: var(--goal); }
.trade { background: var(--trade); } .yugao { background: var(--yugao); } .gold { background: var(--gold); }
.btn.done { opacity: .6; }
.btn[disabled], .mini[disabled] { opacity: .4; cursor: not-allowed; }
.mini { padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface2); font-size: .85rem; min-height: 40px; }
.mini.danger { color: var(--danger); }
.mini.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); font-weight: 700; }

/* lists */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.row { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); font-size: .9rem; }
.row:first-child { border-top: 0; }
.row .sub { display: block; color: var(--muted); font-size: .75rem; }
.row .pt { font-family: var(--num); font-size: 1.25rem; font-variant-numeric: tabular-nums; min-width: 2.2em; text-align: right; }
.row.void { opacity: .5; }
.row.void .what { text-decoration: line-through; }
.warn { color: var(--gold); font-size: .72rem; }
.tag { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tag.ok { color: var(--boss); border-color: var(--boss); }
.tag.bad { color: var(--danger); border-color: var(--danger); }
.tag.off { color: var(--gold); border-color: var(--gold); }

/* toast and sheets */
.toast { position: fixed; left: 12px; right: 12px; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); max-width: 520px; margin-inline: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); z-index: 30; }
.toast .grow { flex: 1; min-width: 0; }
.toast button { padding: 8px 12px; border-radius: 8px; background: var(--bg); color: var(--ink); font-weight: 700; min-height: 40px; }
.toast i { display: block; height: 3px; margin-top: 6px; background: currentColor; opacity: .5; border-radius: 2px; transform-origin: left; animation: drain 8s linear forwards; }
.toast.error { background: var(--danger); color: #fff; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { .toast i { animation: none; } .btn { transition: none; } }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 40; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 560px; margin-inline: auto; max-height: 82%; overflow: auto; background: var(--surface); border-top: 1px solid var(--line); border-radius: 20px 20px 0 0; box-shadow: var(--shadow); padding: 14px 14px calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 50; display: grid; gap: 10px; }
.sheet h3 { font-size: 1rem; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hint { color: var(--muted); font-size: .82rem; }
