/* =====================================================================
   StudyBoard 社労士2027 — 見た目
   ・文字・色・グラフは WorksBoard と同じ決まり（明るい画面）
   ・グラフの色：--c1〜--c8（科目のまとまり）、--s1〜--s5（量の濃さ）
   ・演出（隠し演出の光・旗・揺れ）は最後のほう
   ===================================================================== */

/* ---------- 色と文字の決まり（WorksBoard と同じ） ---------- */
:root {
  /* WorksBoard の色 */
  --brand: #004EA2; --brand2: #3B7DD8; --brandD: #003A78; --side-bg: #F5F8FD;
  --ink: #241D1A; --sub: #5B6570; --faint: #98A2AD;
  --bg: #ffffff; --bg2: #F7F8FA; --rule: #E1E4E9; --rule2: #EEF0F3;
  --live: #0E7A55; --draft: #B07C0A;
  --pink: #DB4F82; --pinkBg: #FBF0F5; --pinkInk: #A63160;
  --hot: #E07B00;   /* 目安を超えたとき（FEVER など） */
  --xp: #6F5CC7;    /* XP・連チャン */
  /* 画面の中で使う名前（上の色につなぐ） */
  --surface: #ffffff; --sunk: #F1F3F6; --muted: var(--sub); --line: var(--rule);
  --accent: var(--brand); --accent-ink: #ffffff; --accent-soft: #EAF1FA;
  --ok: #1E6F45; --ok-soft: #E9F7EF; --err: #B42318; --err-soft: #FDECEA;
  --warn-bg: #FFF6E5; --warn-ink: #8A5A00; --warn-line: #EFD39A;
  /* 文字（WorksBoard と同じ。端末に入っている文字を使う） */
  --jp: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Noto Sans JP", "Meiryo", sans-serif;
  --nm: "Helvetica Neue", Arial, sans-serif;
  --f-display: var(--jp); --f-body: var(--jp);
  --f-data: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic Medium", "Noto Sans JP", "Meiryo", sans-serif;
  --f-fx: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  --r: 10px;
  --shadow: 0 1px 3px rgba(26, 36, 48, .06), 0 1px 10px rgba(26, 36, 48, .04);
  --shadow-pop: 0 4px 18px rgba(26, 36, 48, .12);
  /* グラフ：科目のまとまり（WorksBoard のグラフの色。決まった順に使う） */
  --c0: #A3ACB6; --c1: #2A63B5; --c2: #1BAF7A; --c3: #E07B00; --c4: #8E44AD;
  --c5: #C0392B; --c6: #C9950B; --c7: #29A0DA; --c8: #D97757;
  /* グラフ：量の濃さ（WorksBoard の青の、明るい→濃い） */
  --s1: #DCE7F5; --s2: #A8C5EA; --s3: #5B92D9; --s4: #2A63B5; --s5: #003A78;
  --nav-h: 60px;
  color-scheme: light;
}

/* ---------- 土台 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--jp); font-size: 14.5px; line-height: 1.55; font-weight: 400;
  font-feature-settings: "palt" 1; letter-spacing: .01em;
  -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body.no-scroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.35; }
h2 { font-size: 16px; font-weight: 700; margin: 0; }
h3 { font-size: 15px; font-weight: 700; margin: 0; }
p { margin: 0 0 8px; }
a { color: var(--accent); }
code { font-family: var(--f-data); font-size: .92em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1080px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 6px 12px; border-radius: 8px; z-index: 300; }
.skip:focus { left: 8px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-family: var(--f-data); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.grow { flex: 1 1 auto; }
.ok-text { color: var(--ok); font-weight: 700; }
.warn-text { color: var(--warn-ink); font-weight: 700; }
.pre { white-space: pre-wrap; word-break: break-word; }
.empty { text-align: center; padding: 22px 8px; margin: 0; }
.loading { padding: 40px 0; text-align: center; }
.sub-h { font-size: 14px; margin: 18px 0 8px; color: var(--ink); }

/* ---------- 上の帯 ---------- */
header.top {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 3px rgba(26, 36, 48, .06), 0 1px 10px rgba(26, 36, 48, .04);
  padding-top: env(safe-area-inset-top);
}
.rail { height: 3px; background: var(--brand); }
.top-in { display: flex; align-items: center; gap: 14px; min-height: 54px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font: 700 14px/1 var(--nm); letter-spacing: .02em;
}
.brand h1 { font-size: 17px; font-weight: 700; margin: 0; white-space: nowrap; color: var(--brandD); }
.brand h1 span { font-size: 12.5px; font-weight: 600; color: var(--sub); margin-left: 4px; }

/* 画面の切り替え（WorksBoard と同じ、下線で選んでいる画面を示す） */
.tabs { display: flex; gap: 4px; margin-left: 12px; flex: 1 1 auto; min-width: 0; align-self: stretch; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; color: var(--sub); text-decoration: none;
  font-weight: 700; font-size: 13.5px; white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); background: var(--bg2); }
.tab.on { color: var(--brand); border-bottom-color: var(--brand); }
.tab .nav-icon { font-size: 15px; }
.nav-dot {
  position: absolute; top: 10px; right: 3px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--pink); box-shadow: 0 0 0 2px #fff;
}
.top-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: none; }
.demo-badge {
  font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; text-decoration: none;
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line);
}
.lv-chip {
  font: 700 12px/1 var(--f-data); padding: 5px 9px; border-radius: 6px;
  background: var(--accent-soft); color: var(--brand);
}
.nw { white-space: nowrap; }
.who { font-size: 13px; color: var(--muted); white-space: nowrap; }
body.logged-out .tabs, body.logged-out .bottom-nav, body.logged-out .top-right { display: none; }

main#main { padding-top: 18px; padding-bottom: 24px; outline: none; min-height: 60vh; }
.foot { color: var(--muted); font-size: 12px; padding-top: 4px; padding-bottom: 28px; text-align: center; }

/* 下の帯（スマホ） */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  .tabs, .who { display: none; }
  .brand h1 { font-size: 17px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--rule);
    box-shadow: 0 -1px 3px rgba(26, 36, 48, .05);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bn {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 1px; height: var(--nav-h); color: var(--sub); text-decoration: none; font-size: 11px; font-weight: 700;
  }
  .bn .nav-icon { font-size: 20px; line-height: 1.1; }
  .bn.on { color: var(--brand); }
  .bn.on::before { content: ""; position: absolute; top: 0; left: 24%; right: 24%; height: 3px; background: var(--brand); }
  .bn .nav-dot { top: 8px; right: calc(50% - 18px); }
  body:not(.logged-out) { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
}

/* ---------- カード・見出し ---------- */
.card {
  background: #fff; border: 1px solid var(--rule); border-radius: var(--r);
  box-shadow: 0 1px 2px rgba(26, 36, 48, .04); padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
@media (max-width: 760px) { .card { padding: 14px 14px; margin-bottom: 12px; } }

.cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr); gap: 0; } }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 0 16px; border-radius: 6px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink);
  font-size: 13.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; text-decoration: none;
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: #F7FAFD; border-color: var(--brand2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--brandD); border-color: var(--brandD); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--sunk); color: var(--ink); }
.btn.danger-ghost { background: transparent; border-color: transparent; color: var(--err); }
.btn.danger-ghost:hover { background: var(--err-soft); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.big { min-height: 54px; padding: 0 32px; font-size: 17px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 16px;
}
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.link-btn {
  border: 0; background: none; padding: 4px 2px; color: var(--accent);
  font-size: 13px; font-weight: 600; text-decoration: none; white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.row-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.row-center { display: flex; justify-content: center; margin-top: 12px; }

/* ---------- 入力 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0 0 12px; }
.field > span:first-child { font-size: 13px; font-weight: 600; color: var(--muted); }
.field small { font-size: 12px; line-height: 1.5; }
input[type="text"], input[type="email"], input[type="number"], input[type="date"], input[type="time"],
input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 40px; padding: 8px 10px; border-radius: 6px;
  border: 1px solid var(--rule); background: #fff; color: var(--ink);
  font-size: 16px; line-height: 1.4;
}
textarea { resize: vertical; min-height: 80px; }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input:disabled, select:disabled, textarea:disabled { background: var(--sunk); color: var(--muted); }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.with-unit { display: flex; align-items: center; gap: 8px; }
.with-unit input { flex: 1 1 auto; }
.with-unit .unit { color: var(--muted); font-size: 14px; flex: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); column-gap: 16px; }
@media (min-width: 560px) { .span2 { grid-column: span 2; } }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 10px 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch-row:first-of-type { border-top: 0; }
.switch-row > span { display: flex; flex-direction: column; }
.switch-row b { font-weight: 600; }
.switch-row small { font-size: 12px; }
input.switch {
  -webkit-appearance: none; appearance: none; position: relative; flex: none;
  width: 46px; height: 26px; border-radius: 999px; background: var(--line); cursor: pointer; transition: background .2s; margin: 0;
}
input.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s;
}
input.switch:checked { background: var(--accent); }
input.switch:checked::before { transform: translateX(20px); }
input.switch:disabled { opacity: .5; }

.kv { display: grid; grid-template-columns: 7.5em 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* 切り替え（いくつかから1つ） */
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--rule); border-radius: 6px; background: #fff; overflow: hidden; }
.seg-btn {
  border: 0; border-left: 1px solid var(--rule); background: #fff; padding: 6px 16px; border-radius: 0;
  font-size: 13.5px; font-weight: 600; color: var(--sub); white-space: nowrap;
}
.seg-btn:first-child { border-left: 0; }
.seg-btn:hover { color: var(--ink); background: var(--bg2); }
.seg-btn.on { background: var(--brand2); color: #fff; font-weight: 700; }
@media (max-width: 520px) { .seg-btn { padding: 6px 11px; } }

/* 選ぶボタン（科目・種類） */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; min-height: 34px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; color: var(--ink); line-height: 1.3;
}
.chip:hover { border-color: var(--muted); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent); }
.chip .swatch { margin-right: 0; }
.chip-icon { font-size: 15px; }
.small-chips .chip { padding: 2px 9px; min-height: 28px; font-size: 12px; }
.pk { display: flex; flex-direction: column; gap: 10px; }
.pk-row { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); gap: 8px; align-items: start; }
.pk-label { font-size: 13px; font-weight: 600; color: var(--muted); padding-top: 7px; }
.pk-item { max-width: 100%; }

/* 小さな札 */
.tag {
  display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 4px;
  font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: var(--sunk); color: var(--muted); border: 1px solid var(--line);
}
.small-tag { font-size: 11px; padding: 0 6px; }
.tag.bonus { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.tag.t-test { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.ok-tag { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.tag.ev-web { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.tag.ev-mat { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.tag.ev-plan { background: var(--sunk); color: var(--muted); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; margin-right: 5px; vertical-align: -1px; }

/* ---------- 上の数字（ホーム・分析・答練） ---------- */
.hero { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.hero.hero-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card .hero { margin-bottom: 10px; }
@media (max-width: 760px) {
  .hero, .hero.hero-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
  .hero.hero-3 .stat:last-child { grid-column: 1 / -1; }
}
.stat {
  background: var(--bg2); border: 0; border-radius: 10px;
  padding: 10px 14px; min-width: 0;
}
.card .stat { background: var(--bg2); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--sub); }
.stat-val { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 4px; margin: 2px 0; }
.stat-sub { line-height: 1.5; }
.stat-ring { display: flex; align-items: center; gap: 12px; }
.stat-ring > div:first-child { flex: none; line-height: 0; }
.stat-ring > div:last-child { min-width: 0; }
.big-num { font: 700 24px/1.2 var(--f-data); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.mid-num { font: 700 19px/1.25 var(--f-data); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.unit { font-size: 12px; color: var(--sub); margin-left: 2px; }
.flame { font-size: 22px; margin-left: 2px; animation: flicker 1.6s ease-in-out infinite; }
@media (max-width: 760px) { .big-num { font-size: 21px; } .stat { padding: 10px 12px; } .stat-ring { gap: 8px; } .stat-ring svg { width: 52px; height: 52px; } }
.xpbar { height: 8px; border-radius: 999px; background: var(--rule); overflow: hidden; margin: 6px 0 4px; }
.xpbar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand2), var(--xp)); transition: width .6s; }

/* ---------- 今日のクエスト ---------- */
.quests { list-style: none; margin: 0; padding: 0; }
.quest { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.quest:first-child { border-top: 0; }
.q-check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 13px; font-weight: 900; color: #fff;
}
.quest.done .q-check { background: var(--ok); border-color: var(--ok); animation: pop .4s ease-out; }
.quest.done .q-label { color: var(--muted); }
.q-label { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; font-weight: 600; font-size: 14px; }
.q-bar { height: 6px; border-radius: 999px; background: var(--sunk); overflow: hidden; margin-top: 5px; }
.q-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .6s; }
.quest.done .q-bar > span { background: var(--ok); }
.q-val { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* ---------- 予定 ---------- */
.events { list-style: none; margin: 0; padding: 0; }
.events li { display: grid; grid-template-columns: 4.6em auto minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 6px 6px; border-radius: 8px; font-size: 14px; }
.events li.is-today { background: var(--accent-soft); font-weight: 700; }
.ev-date { font-family: var(--f-data); font-size: 13px; color: var(--muted); white-space: nowrap; }
.ev-text { min-width: 0; }

/* ---------- 記録の一覧 ---------- */
.ses-list { list-style: none; margin: 0; padding: 0; }
.ses { display: grid; grid-template-columns: 6.2em minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.ses:first-child { border-top: 0; }
.ses-time { font-family: var(--f-data); font-size: 12px; color: var(--muted); white-space: nowrap; }
.ses-what { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; min-width: 0; font-size: 14px; }
.ses-what .swatch { margin-right: 0; }
.ses-note { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.ses-min { font-weight: 700; white-space: nowrap; }
@media (max-width: 520px) { .ses { grid-template-columns: minmax(0, 1fr) auto auto; } .ses-time { grid-column: 1 / -1; margin-bottom: -6px; } }

/* ---------- タイマー ---------- */
.timer-card.idle .tm-start { display: flex; justify-content: center; margin-top: 16px; }
.timer-card.on { text-align: center; transition: border-color .3s, box-shadow .3s; }
.tm-head { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tm-what { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 17px; }
.tm-what .swatch { margin: 0; width: 12px; height: 12px; }
.tm-kind { color: var(--muted); font-size: 14px; }
.tm-live { display: flex; justify-content: center; margin: 14px 0 10px; }
.tm-ring-wrap { position: relative; width: 220px; height: 220px; border-radius: 50%; }
.tm-ring-wrap .ring { display: block; }
.tm-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tm-clock { font-size: 42px; font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
.tm-sub { font-size: 13px; color: var(--muted); margin-top: 4px; padding: 0 30px; line-height: 1.4; }
.tm-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.tm-ring .ring-fg { transition: stroke-dashoffset 1s linear, stroke .4s; }
.tm-ring-wrap.paused .ring-fg { stroke: var(--muted); opacity: .55; }
.tm-ring-wrap.paused .tm-clock { color: var(--muted); }
.tm-ring-wrap.paused { animation: breathe 2.4s ease-in-out infinite; }
.tm-ring-wrap.over .ring-fg { stroke: var(--hot); }
.tm-ring-wrap.over { animation: over-glow 1.6s ease-in-out infinite; }
.tm-ring-wrap.over .tm-clock { color: var(--hot); }
.tm-ring-wrap.hb { animation: heartbeat 1s ease-in-out infinite; }
.timer-card.over { border-color: var(--hot); box-shadow: 0 0 0 1px var(--hot), 0 6px 24px color-mix(in srgb, var(--hot) 30%, transparent); }
.timer-card.paused { background: color-mix(in srgb, var(--surface) 70%, var(--sunk)); }
@media (max-width: 520px) { .tm-actions .btn { flex: 1 1 30%; padding: 0 8px; } }

.tm-item { margin-top: 2px; }
.q-body { min-width: 0; }
.quest.weak .q-label .tag { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }

/* タイマーを終えたときの結果 */
.result { text-align: center; }
.result-main { padding: 6px 0 12px; }
.result-main .big-num { font-size: 40px; color: var(--accent); }
.tags { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 8px; }
.tag.fever { background: linear-gradient(135deg, #ff9a1f, #d1361b); color: #fff; border-color: transparent; }
.tag.premium { background: linear-gradient(90deg, #ff4d4d, #ffcc00, #33d17a, #3399ff, #b366ff); color: #fff; border-color: transparent; text-shadow: 0 1px 2px rgba(0, 0, 0, .35); }
.tag.renchan { background: var(--xp); color: #fff; border-color: transparent; }
.result-list { list-style: none; margin: 0 0 12px; padding: 0; text-align: left; }
.result-list li { display: flex; align-items: center; gap: 4px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.result-list li:first-child { border-top: 0; }
.result-list .num { margin-left: auto; font-weight: 700; padding-left: 10px; }
.result-xp { font-size: 18px; margin: 4px 0; }
.result-xp b { color: var(--xp); font-family: var(--f-data); margin-right: 6px; }
.result-today, .result-quests { font-size: 14px; margin: 2px 0; }
.result .field { text-align: left; margin-top: 14px; }

.next-card .btn { align-self: flex-start; }

/* ---------- 見守る画面 ---------- */
.live { display: flex; align-items: center; gap: 14px; }
.live-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--muted); }
.live.on .live-dot { background: var(--ok); box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 50%, transparent); animation: ping 1.8s ease-out infinite; }
.live.paused .live-dot { background: var(--hot); }
.live-body { flex: 1 1 auto; min-width: 0; }
.live-title { font: 700 17px/1.4 var(--jp); }
.live-what { display: flex; align-items: center; flex-wrap: wrap; gap: 2px 4px; font-size: 14px; }
.live-right { text-align: right; flex: none; }
.live-clock { font-size: 28px; font-weight: 700; line-height: 1.1; }
.live-card .live.on { color: var(--ink); }

.composer .stamps { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.stamp-btn {
  width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-size: 24px; display: grid; place-items: center; transition: transform .12s;
}
.stamp-btn:hover { transform: scale(1.08); }
.stamp-btn.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }

.cheers { list-style: none; margin: 0; padding: 0; }
.cheer { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.cheer:first-child { border-top: 0; }
.cheer-stamp { font-size: 30px; line-height: 1; flex: none; }
.cheer-body { min-width: 0; font-size: 14px; }
.cheer-card.new { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow); animation: pop .5s ease-out; }
.cheer-card.new .cheer-stamp { animation: wiggle 1.4s ease-in-out 2; }

/* 次に進める回・バッジ */
.next-item { display: flex; flex-direction: column; gap: 8px; }
.next-name { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 15px; }
.next-name .swatch { margin: 0; }
.badge-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.badge-row li { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; line-height: 1.35; }
.b-icon { font-size: 26px; line-height: 1.2; }
.badge-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.badge {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 12px 8px; border-radius: var(--r); border: 1px solid var(--rule); background: var(--bg2); line-height: 1.4;
}
.badge.got { background: #fff; border-color: var(--warn-line); }
.badge.locked { opacity: .6; }
.badge.locked .b-icon { filter: grayscale(1); opacity: .6; }
.badge.secret.locked .b-icon { filter: blur(2px) grayscale(1); }
.badge b { font-size: 13px; }

/* ---------- ログイン ---------- */
.login-card { max-width: 420px; margin: 6vh auto 0; text-align: center; padding: 28px 24px; }
.login-mark {
  width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff; margin: 0 auto 12px;
  display: grid; place-items: center; font: 700 21px/1 var(--nm);
}
.login-card h2 { font-size: 19px; margin-bottom: 10px; }
.login-form { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; text-align: left; }
.login-form .btn { width: 100%; }
.login-note { font-size: 12px; color: var(--muted); margin-top: 16px; }
.login-card .warn-text { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 8px 10px; font-weight: 600; text-align: left; }

/* ---------- カリキュラム ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.cur-summary .hero { margin-bottom: 8px; }
.blk { border-top: 1px solid var(--line); }
.blk:first-of-type { border-top: 0; }
.blk > summary {
  list-style: none; cursor: pointer; display: grid; align-items: center; gap: 4px 12px;
  grid-template-columns: minmax(0, 1fr) auto auto 80px; padding: 10px 4px; border-radius: 8px;
}
.blk > summary::-webkit-details-marker { display: none; }
.blk > summary:hover { background: var(--sunk); }
.blk-title { font-weight: 700; display: flex; align-items: center; gap: 6px; }
.blk-title::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .15s; }
.blk[open] .blk-title::before { transform: rotate(90deg); }
.blk.all-done .blk-title::after { content: "✓"; color: var(--ok); font-weight: 900; }
.blk-range { grid-column: 1; grid-row: 2; padding-left: 18px; }
.blk-min { grid-row: 1 / span 2; }
.blk-count { grid-row: 1 / span 2; font-size: 13px; font-weight: 700; }
.blk-bar { grid-row: 1 / span 2; height: 6px; border-radius: 999px; background: var(--sunk); overflow: hidden; }
.blk-bar > span { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
@media (max-width: 560px) { .blk > summary { grid-template-columns: minmax(0, 1fr) auto 48px; } .blk-min { display: none; } }

.ci-list { list-style: none; margin: 0 0 8px; padding: 0; }
.ci {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 14px; align-items: center;
  padding: 10px 6px 10px 12px; border-top: 1px dashed var(--line); border-left: 3px solid transparent;
}
.ci.done { border-left-color: var(--ok); }
.ci.future { opacity: .72; }
.ci.late { border-left-color: var(--warn-line); }
.ci-main { min-width: 0; }
.ci-name { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.ci-name .swatch { margin: 0; }
.ci-no { font-size: 12px; color: var(--muted); }
.ci-meta { line-height: 1.5; }
.ci-soon { color: var(--accent); font-weight: 700; }
.ci-late { color: var(--warn-ink); font-weight: 700; }
.ci-memo { margin-top: 4px; padding: 4px 8px; border-radius: 6px; background: var(--sunk); white-space: pre-wrap; word-break: break-word; }
.ci-marks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ci-side { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); }
.ci-side:empty { display: none; }
.ci-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.ci-score { color: var(--ink); font-weight: 600; }
@media (max-width: 640px) {
  .ci { grid-template-columns: minmax(0, 1fr); }
  .ci-marks, .ci-acts { justify-content: flex-start; }
}
.mark {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px 3px 6px; min-height: 32px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
button.mark:hover { border-color: var(--muted); color: var(--ink); }
.mark.on { border-color: transparent; background: var(--ok-soft); color: var(--ok); }
span.mark { cursor: default; }
.mk-box {
  width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--line);
  display: grid; place-items: center; font-size: 12px; font-weight: 900; line-height: 1; color: #fff;
}
.mark.on .mk-box { background: var(--ok); border-color: var(--ok); }
.mk-at { font: 400 11px/1 var(--f-data); color: var(--muted); margin-left: 2px; }

/* ---------- 答練 ---------- */
.tr-list { list-style: none; margin: 0; padding: 0; }
.tr {
  width: 100%; display: grid; grid-template-columns: 4.6em minmax(0, 1fr) 7.5em; gap: 12px; align-items: center;
  padding: 12px 6px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; border-radius: 0;
}
.tr-list li:first-child .tr { border-top: 0; }
.tr:hover { background: var(--sunk); }
.tr-date { font-family: var(--f-data); font-size: 13px; color: var(--muted); }
.tr-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.tr-title { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.tr-title .swatch { margin: 0; }
.tr-detail { line-height: 1.5; }
.tr-score { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.tr-score b { font-size: 18px; }
.tr-bar { width: 100%; height: 5px; border-radius: 999px; background: var(--sunk); overflow: hidden; margin-top: 3px; }
.tr-bar > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
@media (max-width: 520px) {
  .tr { grid-template-columns: minmax(0, 1fr) 5.4em; gap: 8px; }
  .tr-date { grid-column: 1 / -1; margin-bottom: -4px; }
}
.tv-head { display: flex; flex-direction: column; gap: 4px; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tv-score { display: flex; align-items: baseline; gap: 10px; }
.tv-score .big-num { font-size: 40px; }
.file-ref { display: flex; gap: 6px; align-items: flex-start; }
.file-ref code { background: var(--sunk); border-radius: 6px; padding: 2px 8px; word-break: break-all; }
.wrong-list { list-style: none; margin: 0; padding: 0; }
.wrong-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.wrong-list li:first-child { border-top: 0; }
.wrong-list .swatch { margin: 0; }
.wq-no { font-weight: 700; white-space: nowrap; }
.wq-res { color: var(--muted); font-size: 13px; }
.wq-memo { flex-basis: 100%; font-size: 13px; color: var(--muted); padding-left: 2px; }

.te-head { margin-bottom: 4px; }
.te-score {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; padding: 10px 14px; margin: 4px 0 10px;
  background: var(--accent-soft); border-radius: var(--r);
}
.te-score .big-num { color: var(--accent); }
.q-sec { margin: 14px 0; }
.q-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.q-sec-head .sub-h { margin: 8px 0; }
.q-row {
  display: grid; grid-template-columns: 3.4em minmax(84px, 9em) minmax(0, 1fr); gap: 6px 8px; align-items: center;
  padding: 6px 6px; border-top: 1px dashed var(--line); border-left: 3px solid transparent;
}
.q-row.wrong { border-left-color: var(--err); background: color-mix(in srgb, var(--err-soft) 55%, transparent); }
.q-row.lucky { border-left-color: var(--hot); background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.q-no { font-size: 13px; font-weight: 700; }
select.q-sub { min-height: 34px; padding: 4px 24px 4px 8px; font-size: 14px; }
.q-why { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 6px; padding-left: 3.4em; }
input.q-memo { min-height: 34px; padding: 4px 8px; font-size: 14px; }
.q-grid { display: block; }
@media (min-width: 900px) { .sheet.wide .q-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 20px; } }
@media (max-width: 520px) { .q-row { grid-template-columns: 3em minmax(0, 1fr); } .q-row .blanks, .q-row .res { grid-column: 1 / -1; } .q-why { padding-left: 0; } }
.blanks, .res { display: flex; flex-wrap: wrap; gap: 6px; }
.bl {
  width: 44px; height: 44px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  font: 700 12px/1.1 var(--f-data); color: var(--muted); padding: 0;
}
.bl i { font-style: normal; font-size: 17px; min-height: 18px; font-family: var(--f-body); }
.bl.o { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.bl.x { background: var(--err-soft); border-color: var(--err); color: var(--err); }
.rs {
  min-width: 46px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface);
  font-size: 17px; font-weight: 700; color: var(--muted); padding: 0 10px;
}
.rs:hover { border-color: var(--muted); }
.rs-o.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.rs-t.on { background: var(--hot); border-color: var(--hot); color: #fff; }
.rs-x.on { background: var(--err); border-color: var(--err); color: #fff; }
.bulk { display: flex; gap: 8px; margin: 6px 0 10px; }
.bulk input { flex: 1 1 auto; font-family: var(--f-data); }

/* ---------- 分析 ---------- */
.heat-wrap { overflow-x: auto; }
.weak-list { list-style: none; margin: 0; padding: 0; counter-reset: wk; }
.weak-list > li { padding: 12px 0; border-top: 1px solid var(--line); counter-increment: wk; }
.weak-list > li:first-child { border-top: 0; padding-top: 4px; }
.wk-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.wk-head::before {
  content: counter(wk); width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 700 12px/1 var(--f-data); margin-right: 4px;
}
.wk-head .swatch { margin: 0; }
.wk-rate { margin-left: auto; font-size: 13px; color: var(--muted); }
.wk-why { margin: 6px 0 4px; padding-left: 1.4em; font-size: 14px; }
.wk-why li { margin: 2px 0; }
.wk-topics { padding-left: 2px; }

.hist { list-style: none; margin: 0; padding: 0; }
.hist-row {
  width: 100%; display: grid; grid-template-columns: 4.8em minmax(0, 1fr) 5.6em 6.4em; gap: 10px; align-items: center;
  padding: 6px 4px; border: 0; background: transparent; text-align: left; border-radius: 8px;
}
.hist-row:hover { background: var(--sunk); }
.hist-date { font-family: var(--f-data); font-size: 13px; }
.hist-date.we { color: var(--accent); }
.hist-bar { display: flex; gap: 2px; height: 12px; align-items: stretch; min-width: 0; }
.hist-bar > span { display: block; min-width: 2px; }
.hist-bar > span:last-child { border-radius: 0 4px 4px 0; }
.hist-min { font-size: 13px; font-weight: 700; text-align: right; }
.hist-goal { text-align: right; }
@media (max-width: 560px) { .hist-row { grid-template-columns: 4.4em minmax(0, 1fr) 4.8em; } .hist-goal { display: none; } }

/* ---------- グラフ ---------- */
figure.chart { margin: 0 0 6px; min-width: 0; }
figure.chart + figure.chart { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }
figure.chart figcaption { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
figure.chart figcaption h3 { font-size: 14px; }
figure.chart figcaption p { margin: 0; }
.legend { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 12px; color: var(--sub); }
.legend li { display: inline-flex; align-items: center; }
.chart-body { min-width: 0; overflow-x: auto; }
.chart-table { margin-top: 8px; }
svg.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
svg.chart-svg.heat { width: auto; max-width: none; }
.chart-svg text { font-family: var(--f-data); letter-spacing: 0; }
.chart-svg .axis { fill: var(--faint); font-size: 11px; }
.chart-svg .grid { stroke: var(--rule2); stroke-width: 1; }
.chart-svg .grid.base { stroke: #CBD2DA; }
.chart-svg .we { fill: #FAFBFC; }
.chart-svg .ax-day { fill: var(--sub); font-size: 12px; font-weight: 600; }
.chart-svg .ax-wd { fill: var(--faint); font-size: 10.5px; font-weight: 600; font-family: var(--jp); }
.chart-svg .sat { fill: #2E6DB4; }
.chart-svg .sun { fill: #C0392B; }
.chart-svg .ref { stroke: var(--sub); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart-svg .ref-label { fill: var(--ink); font-weight: 600; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 2; }
.chart-svg .hit { fill: transparent; cursor: default; }
.chart-svg rect.hit.tip-on { fill: var(--brand); fill-opacity: .06; }
.chart-svg circle.hit.tip-on { fill: var(--ink); fill-opacity: .1; }
.hc.l0, .hc-key.l0 { fill: var(--rule2); background: var(--rule2); }
.hc.l1, .hc-key.l1 { fill: var(--s1); background: var(--s1); }
.hc.l2, .hc-key.l2 { fill: var(--s2); background: var(--s2); }
.hc.l3, .hc-key.l3 { fill: var(--s3); background: var(--s3); }
.hc.l4, .hc-key.l4 { fill: var(--s4); background: var(--s4); }
.hc.l5, .hc-key.l5 { fill: var(--s5); background: var(--s5); }
.hc.today { stroke: var(--ink); stroke-width: 1.5; }
.hc.tip-on { stroke: var(--accent); stroke-width: 2; }
.heat-scale { display: flex; align-items: center; flex-wrap: wrap; gap: 3px; margin-top: 6px; }
.hc-key { display: inline-block; width: 11px; height: 11px; border-radius: 2px; }
.heat-scale .sep { margin-left: 6px; }

/* 行どうしで列の幅をそろえる（棒の起点と長さの基準を全行で同じにする） */
.hbars { display: grid; grid-template-columns: fit-content(8.6em) minmax(0, 1fr) max-content; row-gap: 6px; column-gap: 10px; }
.hbars.has-ref { padding-top: 16px; }
.hb-row { grid-column: 1 / -1; display: grid; grid-template-columns: 7.6em minmax(0, 1fr) 8.6em; grid-template-columns: subgrid; column-gap: 10px; align-items: center; font-size: 13px; padding: 2px 4px; border-radius: 6px; }
.hb-row.tip-on { background: #F4F8FC; }
.hb-label { display: flex; align-items: center; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { position: relative; height: 14px; border-radius: 2px; background: var(--rule2); }
.hb-fill { height: 100%; border-radius: 0 2px 2px 0; min-width: 3px; }
.hb-ref { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 2px dashed var(--sub); }
.hb-ref > span { position: absolute; bottom: 100%; left: 0; transform: translateX(-50%); font-size: 11px; color: var(--sub); white-space: nowrap; margin-bottom: 1px; }
.hb-row:not(:first-child) .hb-ref > span { display: none; }
.hb-val { font-family: var(--f-data); font-weight: 700; white-space: nowrap; text-align: right; }
@media (max-width: 520px) {
  .hbars { grid-template-columns: fit-content(7.4em) minmax(0, 1fr) max-content; column-gap: 8px; }
  .hb-row { column-gap: 8px; }
}

.ring { display: block; }
.ring-bg { fill: none; stroke: var(--rule); }
.ring-fg { fill: none; stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring.done .ring-fg { stroke: var(--ok); }

#chart-tip {
  position: fixed; z-index: 1200; pointer-events: none; max-width: 280px;
  background: #fff; color: var(--ink); border: 0; border-radius: 8px;
  box-shadow: 0 0 0 1px var(--rule), 0 4px 14px rgba(26, 36, 48, .08); padding: 6px 10px; font-size: 12px; line-height: 1.5;
  opacity: 0; transition: opacity .12s;
}
#chart-tip.on { opacity: 1; }
#chart-tip .swatch { margin-right: 5px; }

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { text-align: left; white-space: nowrap; }
table.data th { padding: 7px 9px; color: var(--faint); font-weight: 700; font-size: 12px; border-bottom: 1px solid var(--rule); }
table.data td { padding: 8px 9px; border-bottom: 1px solid var(--rule2); }
table.data .num { text-align: right; }
table.data tbody tr:hover { background: #F4F8FC; }

/* ---------- 下から出る窓・お知らせ ---------- */
.sheet-wrap {
  position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center;
  background: rgba(10, 18, 28, .45); opacity: 0; transition: opacity .18s; padding: 16px;
}
.sheet-wrap.in { opacity: 1; }
.sheet-wrap.out { opacity: 0; }
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid var(--rule); border-radius: 14px; box-shadow: 0 4px 18px rgba(0, 0, 0, .06), 0 12px 40px rgba(26, 36, 48, .14);
  transform: translateY(14px); transition: transform .2s ease-out;
}
.sheet.wide { max-width: 960px; }
.sheet-wrap.in .sheet { transform: none; }
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 12px 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.sheet-head h2 { font-size: 16px; min-width: 0; }
.sheet-body { padding: 14px 18px 18px; }
.sheet-body .row-end { position: sticky; bottom: -18px; background: var(--surface); padding: 10px 0 4px; margin-bottom: -4px; border-top: 1px solid var(--line); }
.confirm-msg { white-space: pre-wrap; margin: 4px 0 6px; }
@media (max-width: 760px) {
  .sheet-wrap { align-items: flex-end; padding: 0; }
  .sheet { max-width: none; border-radius: 16px 16px 0 0; max-height: 94vh; max-height: 94dvh; transform: translateY(40px); padding-bottom: env(safe-area-inset-bottom); }
  .sheet.wide { max-width: none; }
  .sheet-body { padding: 12px 14px 16px; }
  .sheet-body .row-end { bottom: -16px; }
}

#toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1100;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-pop);
  font-size: 14px; font-weight: 600; animation: toast-in .22s ease-out; transition: opacity .4s, transform .4s; text-align: center;
}
.toast.ok { background: var(--ok); color: #fff; }
.toast.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }
.toast.err { background: var(--err); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (max-width: 760px) { #toasts { bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); } }

/* ---------- お試しモード ---------- */
.demo-card { border-color: var(--warn-line); background: color-mix(in srgb, var(--warn-bg) 35%, var(--surface)); }
.demo-card .seg { background: var(--surface); }

/* =====================================================================
   演出（隠し演出）
   ===================================================================== */
#fx-layer { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
#fx-layer canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

.fx-flash { position: fixed; inset: 0; z-index: 999; pointer-events: none; animation: fx-flash 1s ease-out forwards; }
.fx-flash.blue { background: radial-gradient(circle at 50% 45%, rgba(92, 158, 240, .55), rgba(31, 111, 209, .18) 45%, transparent 75%); }
.fx-flash.gold { background: radial-gradient(circle at 50% 45%, rgba(255, 236, 150, .9), rgba(237, 161, 0, .35) 45%, transparent 80%); }
.fx-flash.rainbow { background: conic-gradient(from 0deg at 50% 45%, rgba(255, 80, 80, .45), rgba(255, 200, 0, .45), rgba(60, 210, 120, .45), rgba(60, 150, 255, .45), rgba(170, 90, 255, .45), rgba(255, 80, 80, .45)); animation: fx-flash-long 1s ease-out forwards; }

.fx-banner {
  position: fixed; left: 50%; top: 40%; z-index: 1001; pointer-events: none;
  transform: translate(-50%, -50%) scale(.55); opacity: 0;
  min-width: min(84vw, 320px); max-width: 92vw; padding: 18px 34px 16px; border-radius: 20px; text-align: center;
  background: rgba(12, 22, 40, .86); color: #fff; box-shadow: 0 18px 60px rgba(0, 0, 0, .35);
  transition: transform .45s cubic-bezier(.2, 1.6, .4, 1), opacity .25s;
}
.fx-banner.in { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.fx-banner.out { opacity: 0; transform: translate(-50%, -64%) scale(1.04); transition: transform .6s ease-in, opacity .6s; }
.fx-main { font: 900 clamp(34px, 9vw, 68px)/1.08 var(--f-fx); letter-spacing: .02em; white-space: nowrap; }
.fx-sub { font: 700 15px/1.5 var(--f-fx); margin-top: 6px; opacity: .92; }

.fx-banner.mile { top: 22%; padding: 10px 22px; min-width: 0; background: rgba(31, 111, 209, .92); }
.fx-banner.mile .fx-main { font-size: clamp(26px, 6vw, 40px); }
.fx-banner.fever { background: radial-gradient(circle at 50% 0%, #ff9a1f, #d1361b 70%); box-shadow: 0 0 0 3px #ffd34d, 0 0 60px rgba(255, 140, 0, .8); }
.fx-banner.fever .fx-main { color: #fff6c2; text-shadow: 0 3px 0 #9a2a00, 0 0 24px #ffd34d; animation: fx-pulse .5s ease-in-out infinite alternate; }
.fx-banner.premium { background: #10061f; box-shadow: 0 0 0 3px transparent, 0 0 80px rgba(200, 120, 255, .8); border: 3px solid transparent; background-clip: padding-box; }
.fx-banner.premium::before {
  content: ""; position: absolute; inset: -3px; border-radius: 22px; z-index: -1;
  background: conic-gradient(#ff4d4d, #ffcc00, #33d17a, #3399ff, #b366ff, #ff4d4d); animation: fx-spin 2s linear infinite;
}
.fx-banner.premium .fx-main {
  background: linear-gradient(90deg, #ff4d4d, #ffcc00, #33d17a, #3399ff, #b366ff, #ff4d4d); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 1.2s linear infinite;
}
.fx-banner.renchan { top: 30%; background: rgba(98, 80, 214, .92); }
.fx-banner.renchan .fx-main { font-size: clamp(30px, 7vw, 52px); }
.fx-banner.r2 { background: rgba(31, 111, 209, .94); }
.fx-banner.r3 { background: rgba(27, 175, 122, .94); }
.fx-banner.r4 { background: rgba(235, 104, 52, .95); }
.fx-banner.r5 { background: linear-gradient(135deg, #e34948, #eda100); box-shadow: 0 0 0 3px #ffd34d, 0 0 50px rgba(237, 161, 0, .7); }
.fx-banner.r5 .fx-main { font-size: clamp(38px, 10vw, 72px); animation: fx-pulse .45s ease-in-out infinite alternate; }
.fx-banner.goal { background: linear-gradient(135deg, #0f7a4d, #1baf7a); box-shadow: 0 0 0 3px #b8f2d6, 0 0 50px rgba(27, 175, 122, .6); }
.fx-banner.level { background: linear-gradient(135deg, #2a3fd6, #6250d6 60%, #b04ad6); box-shadow: 0 0 0 3px #d9d2ff, 0 0 60px rgba(98, 80, 214, .7); }
.fx-banner.level .fx-main { letter-spacing: .08em; }
.fx-banner.badge { top: 30%; background: #1d1606; border: 2px solid #e8b931; box-shadow: 0 0 40px rgba(232, 185, 49, .55); }
.fx-banner.badge .fx-main { font-size: clamp(26px, 6.5vw, 44px); color: #ffe08a; }
.fx-banner.badge.secret { background: #14072a; border-color: #b366ff; box-shadow: 0 0 50px rgba(179, 102, 255, .7); }
.fx-banner.badge.secret .fx-main { color: #e4c8ff; }
.fx-banner.pb { background: linear-gradient(135deg, #c0281b, #eb6834); box-shadow: 0 0 0 3px #ffc9a8, 0 0 50px rgba(235, 104, 52, .6); }
.fx-banner.stamp { top: 18%; background: var(--surface); color: var(--ink); border: 2px solid var(--accent); padding: 12px 24px; }
.fx-banner.stamp .fx-main { font-size: clamp(40px, 10vw, 60px); }
.fx-banner.stamp .fx-sub { color: var(--ink); }

.fx-shake { animation: fx-shake .6s cubic-bezier(.36, .07, .19, .97) both; }
.fx-quake { animation: fx-quake .75s cubic-bezier(.36, .07, .19, .97) both; }

/* ---------- ドドドドド…ドン!! ---------- */
/* 連打のあいだ、まわりがだんだん暗くなる */
.fx-dim {
  position: fixed; inset: 0; z-index: -1; opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(10, 16, 28, .3), rgba(10, 16, 28, .82) 78%);
  transition: opacity var(--ms, 1.2s) cubic-bezier(.4, 0, .7, .8);
}
.fx-dim.on { opacity: 1; }
.fx-dim.off { opacity: 0; transition: opacity 1.1s ease-out; }
/* 「ド」の文字（白い文字・太い縁・色の影） */
.fx-do {
  position: absolute; translate: -50% -50%; rotate: var(--rot, 0deg);
  font: 900 40px/1 var(--f-fx); color: #fff; white-space: nowrap; letter-spacing: 0;
  -webkit-text-stroke: .11em #1A1410; paint-order: stroke fill;
  text-shadow: .07em .08em 0 var(--do, #FFB21F);
  animation: fx-do-pop .2s cubic-bezier(.2, 1.8, .4, 1) both;
}
.fx-do.gone { animation: fx-do-gone .45s ease-in forwards; }
/* 「ドン!!」の文字 */
.fx-don {
  position: fixed; left: 50%; top: 45%; translate: -50% -50%;
  font: 900 clamp(84px, 25vw, 230px)/1 var(--f-fx); letter-spacing: -.04em; white-space: nowrap;
  color: #fff; -webkit-text-stroke: .075em #1A1410; paint-order: stroke fill;
  text-shadow: .045em .055em 0 var(--do, #FFB21F), .09em .11em 0 #1A1410;
  animation: fx-don .95s cubic-bezier(.2, .9, .3, 1) forwards;
}
.fx-don.rainbow { animation: fx-don .95s cubic-bezier(.2, .9, .3, 1) forwards, fx-hue .32s steps(4) infinite; }
/* 集中線（真ん中を空けて、まわりから線が刺さる） */
.fx-lines {
  position: fixed; left: -50vw; right: -50vw; top: -55vh; bottom: -45vh;
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(26, 20, 16, .88) 0deg 1.1deg, transparent 1.1deg 4.2deg,
    rgba(26, 20, 16, .7) 4.2deg 4.8deg, transparent 4.8deg 9deg);
  -webkit-mask: radial-gradient(circle closest-side, transparent 0 17%, #000 40%);
  mask: radial-gradient(circle closest-side, transparent 0 17%, #000 40%);
  animation: fx-lines .9s steps(1, end) forwards;
}
.fx-lines.rainbow {
  background: repeating-conic-gradient(from 0deg at 50% 50%,
    rgba(255, 77, 109, .9) 0deg 1.1deg, transparent 1.1deg 4.2deg,
    rgba(255, 204, 0, .85) 4.2deg 4.8deg, transparent 4.8deg 6.6deg,
    rgba(51, 153, 255, .85) 6.6deg 7.2deg, transparent 7.2deg 9deg);
}
/* ドンの衝撃の輪 */
.fx-ring {
  position: fixed; left: 50%; top: 45%; width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border-radius: 50%; border: 10px solid var(--do, #fff); box-shadow: 0 0 24px var(--do, #fff);
  animation: fx-ring .75s cubic-bezier(.1, .7, .3, 1) forwards;
}
.fx-flash.white { background: radial-gradient(circle at 50% 45%, #fff 0 35%, rgba(255, 255, 255, .82) 80%); animation: fx-flash-white .55s ease-out forwards; }

body.fever-mode .timer-card.on { border-color: #ff8a1f; animation: fever-glow 1.2s ease-in-out infinite; }
body.fever-mode .tm-ring-wrap .ring-fg { stroke: #ff8a1f; }
body.premium-mode .timer-card.on {
  border: 2px solid transparent;
  background: linear-gradient(var(--surface), var(--surface)) padding-box,
    conic-gradient(from var(--fx-angle, 0deg), #ff4d4d, #ffcc00, #33d17a, #3399ff, #b366ff, #ff4d4d) border-box;
  animation: fx-angle 3s linear infinite;
}
body.premium-mode .tm-clock {
  background: linear-gradient(90deg, #ff4d4d, #ffcc00, #33d17a, #3399ff, #b366ff, #ff4d4d); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 1.6s linear infinite;
}
@property --fx-angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

/* ---------- 動き ---------- */
@keyframes pop { 0% { transform: scale(.85); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-14deg); } 40% { transform: rotate(12deg); } 60% { transform: rotate(-8deg); } 80% { transform: rotate(5deg); } }
@keyframes flicker { 0%, 100% { transform: scale(1) rotate(-3deg); } 50% { transform: scale(1.12) rotate(3deg); } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }
@keyframes heartbeat { 0%, 40%, 100% { transform: scale(1); } 15% { transform: scale(1.035); } 28% { transform: scale(1.015); } }
@keyframes over-glow { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hot) 0%, transparent); } 50% { box-shadow: 0 0 34px 6px color-mix(in srgb, var(--hot) 45%, transparent); } }
@keyframes ping { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 12px color-mix(in srgb, var(--ok) 0%, transparent); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fx-flash { 0% { opacity: 0; } 12% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-flash-long { 0% { opacity: 0; filter: hue-rotate(0deg); } 15% { opacity: 1; } 100% { opacity: 0; filter: hue-rotate(180deg); } }
@keyframes fx-pulse { from { transform: scale(1); } to { transform: scale(1.07); } }
@keyframes fx-spin { to { transform: rotate(360deg); } }
@keyframes fx-slide { to { background-position: 200% 0; } }
@keyframes fx-angle { to { --fx-angle: 360deg; } }
@keyframes fx-shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); } 20%, 80% { transform: translate3d(4px, 1px, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, -1px, 0); } 40%, 60% { transform: translate3d(7px, 1px, 0); }
}
@keyframes fx-quake {
  0% { transform: translate3d(0, 14px, 0); }
  8% { transform: translate3d(-16px, -10px, 0) rotate(-.6deg); }
  16% { transform: translate3d(14px, 8px, 0) rotate(.5deg); }
  26% { transform: translate3d(-11px, 6px, 0) rotate(-.4deg); }
  38% { transform: translate3d(9px, -5px, 0); }
  52% { transform: translate3d(-6px, 3px, 0); }
  68% { transform: translate3d(4px, -2px, 0); }
  84% { transform: translate3d(-2px, 1px, 0); }
  100% { transform: none; }
}
@keyframes fx-do-pop { 0% { scale: 2.4; opacity: 0; } 55% { opacity: 1; } 100% { scale: 1; opacity: 1; } }
@keyframes fx-do-gone { from { scale: 1; opacity: 1; } to { scale: 1.9; opacity: 0; } }
@keyframes fx-don {
  0% { scale: 4; rotate: -10deg; opacity: 0; }
  12% { scale: .88; rotate: -5deg; opacity: 1; }
  20% { scale: 1.08; }
  28% { scale: 1; rotate: -4deg; }
  55% { scale: 1.04; opacity: 1; }
  100% { scale: 1.7; rotate: -3deg; opacity: 0; }
}
@keyframes fx-lines {
  0% { rotate: 0deg; opacity: 1; } 18% { rotate: 1.6deg; } 36% { rotate: -1.1deg; }
  54% { rotate: 2.2deg; opacity: 1; } 72% { rotate: .4deg; opacity: .55; } 90% { rotate: -.8deg; opacity: .25; } 100% { opacity: 0; }
}
@keyframes fx-ring { from { scale: .2; opacity: 1; } to { scale: 18; opacity: 0; } }
@keyframes fx-flash-white { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fx-hue { to { filter: hue-rotate(360deg); } }
@keyframes fever-glow { 0%, 100% { box-shadow: 0 0 0 1px #ff8a1f, 0 0 12px rgba(255, 138, 31, .35); } 50% { box-shadow: 0 0 0 2px #ffb21f, 0 0 36px rgba(255, 138, 31, .7); } }

/* 動きを控える設定の端末では、動きを止める（光と旗は短く出る） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .fx-shake { animation: none !important; }
  .fx-banner.in { transform: translate(-50%, -50%); }
}

/* 印刷 */
@media print {
  header.top, .bottom-nav, .foot, .btn, .icon-btn, #toasts, #fx-layer { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
