/* 都道府県じんとり style.css — 構造とクラス名は docs/design.md */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-bg: #f7efdc;
  --c-washi: #f4e8cc;
  --c-washi-deep: #e6d3a8;
  --c-line: #e2cfa6;

  --c-aka: #e8513b;
  --c-aka-deep: #b83a28;
  --c-aka-soft: #fbdcd6;
  --c-ao: #2f5e9e;
  --c-ao-deep: #1e3256;
  --c-ao-soft: #dbe5f3;

  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-matcha: #7bc96f;
  --c-matcha-deep: #4fa443;
  --c-ng: #d8343a;

  --font-base: "Hiragino Maru Gothic ProN", "Hiragino Maru Gothic Pro", "BIZ UDPGothic",
    "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --font-num: "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN", "SF Pro Rounded",
    ui-rounded, system-ui, sans-serif;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;
  --border: 3px solid var(--c-ink);
  --btn-depth: 6px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --dur-fast: 0.15s;
  --dur-mid: 0.3s;
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* プレイ画面の可変サイズ */
  --gap: 8px;
  --card-h: clamp(84px, 17dvh, 150px);
  --act-h: clamp(44px, 6.6dvh, 58px);
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; height: 100%; overflow: hidden; position: fixed; inset: 0; width: 100%; }

body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background-color: var(--c-bg);
  background-image:
    radial-gradient(rgba(170, 135, 80, 0.16) 1.4px, transparent 1.5px),
    radial-gradient(rgba(170, 135, 80, 0.10) 1px, transparent 1.1px);
  background-size: 24px 24px, 17px 17px;
  background-position: 0 0, 9px 13px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
canvas { display: block; }

.app {
  position: relative;
  max-width: 560px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.num {
  font-family: var(--font-num);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- 画面切替 ---------- */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(12px + var(--safe-top)) calc(12px + var(--safe-right)) calc(12px + var(--safe-bottom)) calc(12px + var(--safe-left));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
}
.screen.is-active {
  opacity: 1; visibility: visible; pointer-events: auto; transform: none;
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s;
}

/* ---------- ボタン（前作と共通） ---------- */

.btn {
  --btn-bg: var(--c-aka);
  --btn-edge: var(--c-aka-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 54px;
  padding: 10px 24px;
  border: var(--border);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 var(--btn-depth) 0 var(--btn-edge), 0 var(--btn-depth) 0 3px var(--c-ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter var(--dur-fast);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 5px;
  border-radius: 999px; background: rgba(255, 255, 255, 0.35); pointer-events: none;
}
.btn:active, .btn.is-pressed {
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn:focus-visible, .link-btn:focus-visible, .mode:focus-visible, .cand:focus-visible {
  outline: 4px solid var(--c-gold); outline-offset: 3px;
}
.btn:disabled {
  filter: grayscale(0.75) opacity(0.55);
  cursor: not-allowed;
  transform: translateY(var(--btn-depth));
  box-shadow: 0 0 0 var(--btn-edge), 0 0 0 3px var(--c-ink);
}
.btn--block { display: flex; width: 100%; }
.btn--ao { --btn-bg: var(--c-ao); --btn-edge: var(--c-ao-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--green { --btn-bg: var(--c-matcha); --btn-edge: var(--c-matcha-deep); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-washi-deep); --btn-fg: var(--c-ink); }
.btn--small { min-height: 42px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }
.btn--small::after { top: 4px; height: 4px; }
.btn__icon { font-size: 1.15em; line-height: 1; }

.link-btn {
  min-height: 36px; border: 0; background: none; padding: 4px 2px;
  color: var(--c-ink-sub); font-size: 13px; font-weight: 700;
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}

.icon-btn {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: var(--border); border-radius: 50%; background: var(--c-paper);
  font-size: 16px; font-weight: 900; line-height: 1; cursor: pointer; box-shadow: 0 3px 0 var(--c-ink);
}
.icon-btn:active { transform: translateY(3px); box-shadow: none; }
.icon-btn:focus-visible { outline: 3px solid var(--c-gold); outline-offset: 2px; }
.icon-btn.is-muted { color: var(--c-ink-sub); background: var(--c-washi); }
.icon-btn.is-muted::after { content: ""; position: absolute; width: 26px; height: 3px; border-radius: 2px; background: var(--c-ink); transform: rotate(-45deg); }
.icon-btn { position: relative; }

/* ---------- タイトル ---------- */

.screen--title { align-items: center; justify-content: safe center; gap: 14px; text-align: center; overflow-y: auto; }
.screen--title > a.back-to-games { position: absolute !important; top: calc(12px + var(--safe-top)); left: 12px; z-index: 6; display: inline-flex; align-items: center; padding: 6px 12px 7px; font: 800 13px/1 var(--font-base); color: var(--c-ink); text-decoration: none; background: var(--c-paper); border: 3px solid var(--c-ink); border-radius: 999px; box-shadow: 0 3px 0 var(--c-ink); }
.screen--title > a.back-to-games[hidden] { display: none; }
.screen--title > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }
.title__mute { position: absolute; top: calc(10px + var(--safe-top)); right: 12px; z-index: 6; }

.logo { margin: 28px 0 0; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.logo__sub {
  padding: 5px 16px; border: var(--border); border-radius: 999px; background: var(--c-paper);
  font-size: 18px; font-weight: 900; letter-spacing: 0.25em; text-indent: 0.25em; box-shadow: 0 3px 0 var(--c-ink);
}
.logo__main { display: flex; gap: 3px; margin-top: 12px; }
.logo__char {
  display: grid; place-items: center; width: 52px; height: 58px; border: var(--border); border-radius: 8px;
  background: var(--c-aka); color: #fff; font-size: 32px; font-weight: 900;
  box-shadow: 0 5px 0 var(--c-ink);
  transform: rotate(calc((var(--i) - 1.5) * 3deg));
  animation: logo-hop 2.4s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.12s);
}
.logo__char--ao { background: var(--c-ao); }
@keyframes logo-hop { 0%, 70%, 100% { translate: 0 0; } 80% { translate: 0 -6px; } }

.title__board { width: 132px; height: 132px; border: var(--border); border-radius: 12px; background: var(--c-washi); box-shadow: 0 5px 0 var(--c-ink); overflow: hidden; }
.title__board canvas { width: 100%; height: 100%; }

.title__lead { margin: 0; font-size: 15px; font-weight: 800; line-height: 1.6; }
.title__lead .aka { color: var(--c-aka-deep); }
.title__lead .ao { color: var(--c-ao); }

.modes { display: grid; gap: 10px; width: 100%; max-width: 360px; }
.modes__label { margin: 0 0 -4px; font-size: 12px; font-weight: 800; color: var(--c-ink-sub); letter-spacing: 0.1em; }
.modes__cpu { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode {
  --m-bg: var(--c-paper);
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 64px; padding: 6px 4px; border: var(--border); border-radius: var(--radius-m);
  background: var(--m-bg); box-shadow: 0 5px 0 var(--c-ink); cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.mode:active { transform: translateY(5px); box-shadow: 0 0 0 var(--c-ink); }
.mode__name { font-size: 16px; font-weight: 900; line-height: 1.1; }
.mode__stars { font-size: 11px; letter-spacing: 1px; color: var(--c-aka); line-height: 1; }
.mode__best { font-size: 11px; font-weight: 700; color: var(--c-ink-sub); line-height: 1.2; }
.mode__streak { font-size: 10px; font-weight: 900; color: var(--c-aka-deep); line-height: 1.1; white-space: nowrap; }
.mode__best .num { color: var(--c-ink); font-size: 12px; }
.mode--easy { --m-bg: #fff3d6; }
.mode--normal { --m-bg: #ffe2cf; }
.mode--hard { --m-bg: #fbd0c8; }
.mode--duo {
  flex-direction: row; gap: 10px; min-height: 54px;
  background: linear-gradient(100deg, var(--c-aka-soft) 0 50%, var(--c-ao-soft) 50% 100%);
}
.mode--duo .mode__name { font-size: 17px; }
.mode__vs { display: inline-flex; gap: 4px; }
.mode__vs i { width: 14px; height: 14px; border: 2px solid var(--c-ink); border-radius: 3px; background: var(--c-aka); }
.mode__vs i + i { background: var(--c-ao); }

.title__best { margin: 0; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); }
.title__links { display: flex; gap: 16px; }

/* ---------- モーダル（ルール・やめる確認） ---------- */

.modal {
  position: absolute; inset: 0; z-index: 50; display: grid; place-items: center;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  background: rgba(59, 47, 47, 0.45);
  animation: fade-in 0.2s both;
}
.modal__panel {
  width: 100%; max-width: 360px; max-height: 100%; overflow-y: auto;
  padding: 18px 18px 22px; border: var(--border); border-radius: var(--radius-l);
  background: var(--c-paper); box-shadow: 0 6px 0 var(--c-ink);
  animation: pop-in 0.3s var(--ease-pop) both;
}
.modal__title {
  margin: 0 0 12px; text-align: center; font-size: 20px; font-weight: 900;
}
.modal__title span { display: inline-block; padding: 2px 14px; border-radius: 999px; background: var(--c-gold); border: var(--border); }
.modal__text { margin: 0 0 16px; text-align: center; font-size: 15px; font-weight: 700; }
.modal__actions { display: flex; gap: 10px; }
.modal__actions .btn { flex: 1; padding-inline: 8px; }

.rules { list-style: none; margin: 0 0 18px; padding: 0; display: grid; gap: 10px; }
.rules__item { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 700; line-height: 1.45; }
.rules__no {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px;
  border: var(--border); border-radius: 8px; background: var(--c-aka); color: #fff;
  font: 900 15px/1 var(--font-num);
}
.rules__item:nth-child(2) .rules__no { background: var(--c-ao); }
.rules__item:nth-child(3) .rules__no { background: var(--c-gold); color: var(--c-ink); }
.rules__item strong { color: var(--c-aka-deep); }
.rules__pic { flex: none; width: 58px; height: 58px; border: 2px solid var(--c-ink); border-radius: 8px; background: var(--c-washi); }

/* ---------- プレイ ---------- */

.screen--play { gap: var(--gap); padding-top: calc(8px + var(--safe-top)); padding-bottom: calc(10px + var(--safe-bottom)); }

/* HUD */
.hud { flex: none; display: flex; align-items: center; gap: 6px; }
.hud__side {
  --side: var(--c-aka); --side-soft: var(--c-aka-soft);
  position: relative; flex: 1 1 0; min-width: 0;
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 6px; align-items: center;
  padding: 4px 8px 4px 6px; border: var(--border); border-radius: 14px;
  background: var(--side-soft);
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
.hud__side--ao { --side: var(--c-ao); --side-soft: var(--c-ao-soft); grid-template-columns: 1fr auto; text-align: right; padding: 4px 6px 4px 8px; }
.hud__side.is-turn { box-shadow: 0 4px 0 var(--c-ink); transform: translateY(-2px); background: var(--c-paper); }
.hud__side.is-turn::before {
  content: ""; position: absolute; inset: -7px; border: 3px solid var(--side); border-radius: 18px; pointer-events: none;
  animation: turn-glow 1.2s ease-in-out infinite;
}
.hud__flag {
  grid-row: 1 / 3; width: 28px; height: 28px; border: 2.5px solid var(--c-ink); border-radius: 5px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.45)) center / 2px 100% no-repeat,
    linear-gradient(rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.45)) center / 100% 2px no-repeat,
    var(--side);
}
.hud__side--ao .hud__flag { grid-column: 2; grid-row: 1 / 3; }
.hud__name { font-size: 11px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud__side--ao .hud__name, .hud__side--ao .hud__score { grid-column: 1; }
.hud__score { display: flex; align-items: baseline; gap: 3px; line-height: 1; white-space: nowrap; }
.hud__side--ao .hud__score { justify-content: flex-end; }
.hud__cells { font-size: 22px; color: var(--side); }
.hud__unit { font-size: 10px; font-weight: 800; }
.hud__count { font-size: 10px; font-weight: 800; color: var(--c-ink-sub); }
.hud__done {
  position: absolute; top: -10px; right: -6px; transform: rotate(6deg);
  padding: 1px 8px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-ink); color: #fff;
  font-size: 10px; font-weight: 800; line-height: 1.4; white-space: nowrap;
}
.hud__side.is-done { filter: saturate(0.4); }
.hud__mid { flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.hud__btns { display: flex; gap: 4px; }
.hud__btns .icon-btn { width: 34px; height: 34px; font-size: 13px; border-width: 2.5px; box-shadow: 0 2px 0 var(--c-ink); }
.hud__btns .icon-btn:active { transform: translateY(2px); }
.hud__btns .icon-btn.is-muted::after { width: 22px; }
.turn {
  padding: 1px 8px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-aka); color: #fff;
  font-size: 11px; font-weight: 900; line-height: 1.5; white-space: nowrap;
}
.turn.is-ao { background: var(--c-ao); }
.turn.is-cpu::after { content: "…"; display: inline-block; animation: think 1s steps(1) infinite; }

/* 盤面: 余った高さを使い、正方形に収める */
.screen--play { justify-content: center; }
/* 盤面は幅いっぱいの正方形を基準に、高さが足りないときだけ縮む。余った高さは候補カードへ */
.board-wrap {
  flex: 0 1 auto; width: 100%; max-width: 536px; align-self: center; aspect-ratio: 1; min-height: 0;
  display: grid; place-items: center;
  container-type: size;
}
.board {
  position: relative;
  width: min(100cqw, 100cqh, 536px);
  aspect-ratio: 1;
  border: var(--border); border-radius: 12px;
  background: var(--c-washi);
  box-shadow: 0 5px 0 var(--c-ink);
  overflow: hidden;
}
.board canvas { width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.board.is-pop { animation: board-pop 0.35s var(--ease-pop); }
.board.is-ng { animation: shake 0.3s ease; }
.board.is-locked canvas { cursor: default; }

/* メッセージ行 */
.msg {
  flex: none; min-height: 26px; display: flex; align-items: center; justify-content: center; gap: 6px;
  margin: 0; padding: 0 8px; font-size: 14px; font-weight: 800; line-height: 1.2; text-align: center;
  color: var(--c-ink-sub);
}
.msg.is-ok { color: var(--c-matcha-deep); }
.msg.is-ng { color: var(--c-ng); }
.msg.is-ng::before { content: "×"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--c-ng); color: #fff; font-size: 12px; }
.msg.is-ok::before { content: "○"; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--c-matcha-deep); color: #fff; font-size: 11px; }
.msg.is-under-toast { visibility: hidden; }
.msg.is-flash { animation: shake 0.3s ease; }

/* 候補カード */
.cands { flex: 1 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; height: calc(var(--card-h) + 10px); max-height: 180px; padding: 6px 0 4px; }
.cand {
  --cand: var(--c-aka); --cand-soft: var(--c-aka-soft);
  position: relative; min-width: 0; height: 100%;
  display: grid; grid-template-rows: 1fr auto; padding: 5px 5px 4px;
  border: var(--border); border-radius: 14px; background: var(--c-paper);
  box-shadow: 0 4px 0 var(--c-ink); cursor: pointer; text-align: center;
  transition: transform 0.18s var(--ease-pop), box-shadow 0.18s ease, background var(--dur-fast);
}
.cands.is-ao .cand { --cand: var(--c-ao); --cand-soft: var(--c-ao-soft); }
.cand:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--c-ink); }
.cand.is-selected {
  transform: translateY(-6px); background: var(--cand-soft);
  box-shadow: 0 6px 0 var(--c-ink), 0 0 0 3px var(--cand) inset;
}
.cand.is-selected::before {
  content: "えらぶ"; position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  padding: 0 7px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--cand); color: #fff;
  font-size: 10px; font-weight: 900; line-height: 1.5; white-space: nowrap;
}
.cand.is-swapped::after {
  content: "いれかえ"; position: absolute; top: -9px; right: -4px;
  padding: 0 5px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-gold);
  font-size: 9px; font-weight: 900; line-height: 1.5;
}
.cand:disabled, .cands.is-locked .cand { cursor: default; filter: saturate(0.3); opacity: 0.35; transform: none; box-shadow: 0 2px 0 var(--c-ink); }
.cands .cand.is-cpu-pick { filter: none; opacity: 1; transform: translateY(-6px); box-shadow: 0 6px 0 var(--c-ink), 0 0 0 3px var(--cand) inset; background: var(--cand-soft); }
.cand.is-empty { visibility: hidden; }
.cand__pics { min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 3px; align-items: center; }
.cand__shape, .cand__sil { width: 100%; height: 100%; min-height: 0; max-height: 110px; }
.cand__sil { border-left: 2px dashed var(--c-line); }
.cand__meta { display: flex; flex-direction: column; align-items: center; line-height: 1.1; padding-top: 2px; }
.cand__name { max-width: 100%; font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand__cells { font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.cand__cells .num { font-size: 13px; color: var(--cand); }

/* 操作ボタン */
.acts { flex: none; display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; padding-bottom: var(--btn-depth); }
.acts .btn { min-height: var(--act-h); padding-inline: 8px; }
.cands.is-ao + .acts .btn--place, .acts.is-ao .btn--place { --btn-bg: var(--c-ao); --btn-edge: var(--c-ao-deep); }

/* 手番交代の帯（ふたりで） */
.turn-banner {
  position: absolute; left: 0; right: 0; top: 40%; z-index: 40; display: flex; justify-content: center; pointer-events: none;
}
.turn-banner__text {
  padding: 10px 28px; border: var(--border); border-radius: 999px; background: var(--c-aka); color: #fff;
  font-size: 22px; font-weight: 900; box-shadow: 0 5px 0 var(--c-ink);
  animation: banner 1.2s ease both;
}
.turn-banner.is-ao .turn-banner__text { background: var(--c-ao); }

/* トースト */
.toast {
  position: absolute; left: 50%; top: calc(64px + var(--safe-top)); z-index: 60;
  display: flex; align-items: center; gap: 6px;
  padding: 6px 16px; border: var(--border); border-radius: 999px; background: var(--c-paper);
  font-size: 15px; font-weight: 900; white-space: nowrap; box-shadow: 0 4px 0 var(--c-ink);
  transform: translateX(-50%);
  animation: toast 1.2s ease both;
  pointer-events: none;
}
.toast.is-aka { background: var(--c-aka); color: #fff; }
.toast.is-ao { background: var(--c-ao); color: #fff; }
.toast.is-big { font-size: 17px; padding: 7px 18px; box-shadow: 0 4px 0 var(--c-ink), 0 0 0 4px var(--c-gold); }
.toast__plus { padding: 0 6px; border-radius: 999px; background: var(--c-gold); color: var(--c-ink); font: 900 14px/1.4 var(--font-num); }

/* 数字がふえたとき */
.is-bump { animation: bump 0.4s var(--ease-pop); display: inline-block; }

/* ---------- 結果 ---------- */

.screen--result { align-items: center; justify-content: safe center; gap: 12px; overflow-y: auto; text-align: center; }
.result__head { margin: 8px 0 0; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.result__title {
  margin: 0; padding: 6px 26px 8px; border: var(--border); border-radius: 14px;
  background: var(--c-aka); color: #fff; font-size: 30px; font-weight: 900; line-height: 1.2;
  box-shadow: 0 5px 0 var(--c-ink); transform: rotate(-2deg);
  animation: pop-in 0.5s var(--ease-pop) both;
}
.result__head.is-lose .result__title { background: var(--c-ao); }
.result__head.is-draw .result__title { background: var(--c-gold); color: var(--c-ink); }
.result__board { flex: none; width: min(100%, 240px); aspect-ratio: 1; border: var(--border); border-radius: 10px; background: var(--c-washi); box-shadow: 0 4px 0 var(--c-ink); overflow: hidden; }
.result__board canvas { width: 100%; height: 100%; }
.result__streak { margin: 0; padding: 1px 12px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font-size: 14px; font-weight: 900; }
.result__tip { margin: -4px 0 0; max-width: 400px; font-size: 12px; font-weight: 800; color: var(--c-ao-deep); line-height: 1.4; }
@media (max-height: 699px) { .result__board { width: min(100%, 180px); } }
.result__sub { margin: 0; font-size: 13px; font-weight: 700; color: var(--c-ink-sub); }

.panel {
  width: 100%; max-width: 400px; padding: 12px 14px; border: var(--border); border-radius: var(--radius-m);
  background: var(--c-paper); box-shadow: 0 4px 0 var(--c-ink); text-align: left;
}
.panel__title { margin: 0 0 8px; font-size: 13px; font-weight: 900; color: var(--c-ink-sub); }

.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 70px 1fr 62px; align-items: center; gap: 8px; }
.bar__who { font-size: 13px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar__track { height: 20px; border: 2.5px solid var(--c-ink); border-radius: 999px; background: var(--c-washi); overflow: hidden; }
.bar__fill {
  display: block; height: 100%; width: calc(var(--v, 0) * 100%);
  background: var(--c-aka); border-right: 2.5px solid var(--c-ink);
  transform-origin: left; animation: bar-grow 0.8s ease-out both 0.2s;
}
.bar--ao .bar__fill { background: var(--c-ao); }
.bar__num { font-size: 13px; font-weight: 800; text-align: right; white-space: nowrap; }
.bar__num .num { font-size: 20px; }
.bar.is-win .bar__who::before { content: "★"; color: var(--c-gold-deep); margin-right: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 132px; overflow-y: auto; }
.chip {
  display: inline-flex; align-items: baseline; gap: 3px; padding: 2px 8px;
  border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-aka-soft);
  font-size: 12px; font-weight: 800; line-height: 1.5;
}
.chip .num { font-size: 11px; color: var(--c-aka-deep); }
.chip--ao { background: var(--c-ao-soft); }
.chip--ao .num { color: var(--c-ao); }
.chip.is-biggest { background: var(--c-gold); }

.result__facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; max-width: 400px; }
.fact { padding: 8px 10px; border: var(--border); border-radius: 14px; background: var(--c-paper); text-align: center; }
.fact__label { display: block; font-size: 11px; font-weight: 800; color: var(--c-ink-sub); }
.fact__value { display: block; font-size: 16px; font-weight: 900; line-height: 1.3; }
.fact__value .num { font-size: 18px; }

.result__actions { display: grid; gap: 14px; width: 100%; max-width: 400px; margin-top: 4px; padding-bottom: var(--btn-depth); }
.result__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- スマホ横 ---------- */

.rotate-hint { display: none; position: fixed; inset: 0; z-index: 100; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--c-bg); font-size: 18px; font-weight: 800; }
.rotate-hint__phone { width: 54px; height: 90px; border: var(--border); border-radius: 12px; background: var(--c-paper); animation: rotate-phone 2s ease-in-out infinite; }
@media (orientation: landscape) and (max-height: 499px) {
  .app { display: none; }
  .rotate-hint { display: flex; }
}

/* ---------- 高さが低い端末 ---------- */

@media (max-height: 760px) {
  :root { --gap: 6px; }
  .cand__name { font-size: 13px; }
  .logo { margin-top: 36px; }
  .title__board { width: 96px; height: 96px; }
}
@media (max-height: 680px) {
  :root { --gap: 5px; --btn-depth: 4px; }
  .screen--play { padding-top: calc(6px + var(--safe-top)); padding-bottom: calc(6px + var(--safe-bottom)); }
  .hud__cells { font-size: 19px; }
  .hud__side { padding-block: 2px; border-radius: 12px; }
  .hud__flag { width: 24px; height: 24px; }
  .msg { min-height: 20px; font-size: 13px; }
  .cand { padding: 4px 4px 3px; border-radius: 12px; }
  .cand__name { font-size: 12px; }
  .cand__cells { font-size: 10px; }
  .acts .btn { font-size: 17px; }
  .screen--title { gap: 10px; }
  .logo__char { width: 44px; height: 50px; font-size: 27px; }
  .title__board { display: none; }
  .mode { min-height: 56px; }
  .result__title { font-size: 26px; }
  .chips { max-height: 84px; }
  .screen--result { gap: 7px; }
  .result__actions { gap: 10px; margin-top: 0; }
  /* 盤面を出すぶん、低い画面では要約だけにする */
  .result__head { margin-top: 0; gap: 3px; }
  .result__title { font-size: 24px; padding: 4px 22px 6px; }
  .result__facts { display: none; }
  .panel { padding: 8px 12px; }
  .panel__title { display: none; }
  .bars { gap: 4px; }
  .bar__track { height: 16px; }
  .bar__num .num { font-size: 17px; }
  .chips { max-height: 58px; }
  .result__actions .btn--block { min-height: 48px; }
}

@media (max-height: 860px) {
  .result__facts { display: none; }
}

/* ---------- アニメ ---------- */

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.7); } }
@keyframes think { 0% { content: ""; } 33% { content: "・"; } 66% { content: "・・"; } }
@keyframes turn-glow { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes board-pop { 0% { transform: scale(1); } 40% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { translate: 0 0; } 25% { translate: -5px 0; } 50% { translate: 5px 0; } 75% { translate: -3px 0; } }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.4); } 100% { transform: scale(1); } }
@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  12% { opacity: 1; transform: translate(-50%, 0) scale(1.06); }
  20%, 80% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -12px); }
}
@keyframes banner {
  0% { opacity: 0; transform: translateX(-40px) scale(0.9); }
  20%, 75% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateX(40px); }
}
@keyframes bar-grow { from { transform: scaleX(0); } }
@keyframes rotate-phone { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001s !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important; transition-delay: 0s !important;
  }
  .toast { animation: none !important; }
  .hud__side.is-turn::before { animation: none !important; }
}
