/* 都道府県カードバトル style.css — 構造とクラス名は docs/design.md */

:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #7a6a5e;
  --c-paper: #fffdf7;
  --c-bg: #fff6e4;
  --c-line: #eadcc0;
  --c-shu: #e8513b;
  --c-shu-deep: #b83a28;
  --c-ai: #2f4b7c;
  --c-ai-deep: #1e3256;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-matcha: #7bc96f;
  --c-matcha-deep: #4fa443;
  --c-sky: #d9eefb;

  --c-me: var(--c-shu);
  --c-me-soft: #fbdcd6;
  --c-foe: var(--c-ai);
  --c-foe-soft: #dfe6f2;

  --hand-h: clamp(106px, 17.5dvh, 200px);

  --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: 18px;
  --radius-l: 28px;
  --border: 3px solid var(--c-ink);
  --shadow-hard: 0 5px 0 var(--c-ink);
  --btn-depth: 6px;

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

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

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

html, body { margin: 0; height: 100%; }

body {
  font-family: var(--font-base);
  color: var(--c-ink);
  background-color: var(--c-bg);
  background-image:
    radial-gradient(rgba(184, 155, 106, 0.22) 1.5px, transparent 1.6px);
  background-size: 22px 22px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
  line-height: 1.5;
}

button { font: inherit; color: inherit; }

.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;
  letter-spacing: -0.01em;
}

.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(14px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity var(--dur-mid) ease, transform var(--dur-mid) ease, visibility 0s linear var(--dur-mid);
  overflow-y: auto;
}

.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-shu);
  --btn-edge: var(--c-shu-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 28px;
  border: var(--border);
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: 20px;
  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: 6px;
  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 {
  outline: 4px solid var(--c-gold);
  outline-offset: 4px;
}

.btn:disabled {
  filter: grayscale(0.7) opacity(0.6);
  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--secondary { --btn-bg: var(--c-ai); --btn-edge: var(--c-ai-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-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 42px; padding: 6px 18px; font-size: 15px; --btn-depth: 4px; }
.btn--small::after { top: 4px; height: 4px; }

.link-btn {
  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;
}


.link-btn { min-height: 36px; }
.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: 17px; font-weight: 900; 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; }
html, body { overflow: hidden; position: fixed; inset: 0; width: 100%; }
body { user-select: none; -webkit-user-select: none; }
[hidden] { display: none !important; }

.r1 { --rc: #b39ddb; --rs: #ece5f8; }
.r2 { --rc: #f7a440; --rs: #fdead3; }
.r3 { --rc: #ff8fab; --rs: #ffe3eb; }
.r4 { --rc: #7bc96f; --rs: #e3f5df; }
.r5 { --rc: #ffd23f; --rs: #fff4cc; }
.r6 { --rc: #3fbfad; --rs: #d9f3ef; }
.r7 { --rc: #7fa9e6; --rs: #dfe9f8; }
.r8 { --rc: #f38e7e; --rs: #fbdcd6; }

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

.screen--title { align-items: center; justify-content: safe center; gap: 16px; text-align: center; }
.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; }

.logo { margin: 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: 20px; font-weight: 900; letter-spacing: 0.25em; text-indent: 0.25em; box-shadow: 0 3px 0 var(--c-ink);
}
.logo__main { display: flex; gap: 2px; margin-top: 12px; }
.logo__char {
  display: grid; place-items: center; width: 46px; height: 58px; border: var(--border); border-radius: 12px;
  background: var(--c-shu); color: #fff; font-size: 30px; font-weight: 900; box-shadow: 0 5px 0 var(--c-ink);
  transform: rotate(calc((var(--i) - 2.5) * 3deg)) translateY(calc((var(--i) - 2.5) * (var(--i) - 2.5) * 1.6px));
}
.logo__char--b { background: var(--c-ai); }
.title__cast { display: flex; justify-content: center; align-items: flex-end; margin-top: 8px; }
.title__cast canvas { width: 78px !important; height: 78px !important; margin: 0 2px; }
.title__cast canvas:nth-child(2) { width: 98px !important; height: 98px !important; }
.title__lead { margin: 0; font-size: 15px; font-weight: 700; }
.title__lead strong { color: var(--c-shu); }
.title__actions { display: flex; flex-direction: column; gap: 14px; width: min(100%, 300px); }
.title__best { margin: 0; padding: 4px 16px; border: 2px dashed var(--c-line); border-radius: 999px; background: var(--c-paper); font-size: 13px; font-weight: 700; }
.title__best .num { font-size: 18px; color: var(--c-shu); }
.title__links { display: flex; gap: 18px; justify-content: center; }

/* 難易度 */
.seg { display: flex; width: 100%; border: var(--border); border-radius: 14px; overflow: hidden; background: var(--c-paper); }
.seg__btn { flex: 1; min-width: 0; min-height: 42px; padding: 2px; border: 0; border-left: 2px solid var(--c-ink); background: none; font-size: 13px; font-weight: 800; cursor: pointer; }
.seg__btn:first-child { border-left: 0; }
.seg__btn.is-on { background: var(--c-gold); }
.seg__note { margin: -8px 0 0; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); }

/* ---------- 共通パネル ---------- */

.panel { border: var(--border); border-radius: var(--radius-l); background: var(--c-paper); box-shadow: var(--shadow-hard); padding: 18px 16px; }
.panel__title { margin: 0 0 10px; font-size: 20px; font-weight: 900; text-align: center; }

/* ---------- 相手選び ---------- */

.screen--select { gap: 12px; }
.screen__head { display: flex; align-items: center; gap: 10px; flex: none; }
.screen__head h2 { margin: 0; flex: 1; font-size: 20px; font-weight: 900; }
.rivals { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.rival {
  position: relative; display: grid; grid-template-columns: 84px 1fr; gap: 12px; align-items: center;
  padding: 10px 14px; border: var(--border); border-radius: var(--radius-m); background: var(--c-paper); box-shadow: var(--shadow-hard);
}
.rival + .rival::before { content: ""; position: absolute; top: -24px; left: 50px; height: 20px; border-left: 5px dotted var(--c-ink); }
.rival__face { display: grid; place-items: center; width: 84px; height: 84px; border: var(--border); border-radius: 50%; background: var(--c-sky); }
.rival__face canvas { width: 70px !important; height: 70px !important; }
.rival__no { font-size: 12px; font-weight: 800; color: var(--c-ink-sub); }
.rival__name { font-size: 20px; font-weight: 900; line-height: 1.25; }
.rival__line { margin: 2px 0 0; font-size: 12px; font-weight: 700; }
.rival.is-next { background: #fff4cc; }
.rival.is-next::after, .rival.is-won::after {
  position: absolute; top: -12px; right: 14px; padding: 2px 10px; border: 2px solid var(--c-ink); border-radius: 999px;
  font-size: 12px; font-weight: 900; color: #fff;
}
.rival.is-next::after { content: "つぎの相手"; background: var(--c-shu); }
.rival.is-won::after { content: "かった！"; background: var(--c-matcha-deep); }
.rival.is-locked { background: var(--c-line); }
.rival.is-locked .rival__face canvas { filter: brightness(0) opacity(.45); }

/* ---------- ルール ---------- */

.screen--rules { justify-content: safe center; }
.rules__steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 12px; }
.rules__step { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; font-size: 15px; font-weight: 700; word-break: auto-phrase; }
.rules__pic { display: grid; place-items: center; width: 56px; height: 56px; border: var(--border); border-radius: 16px; background: #fff4cc; }
.rules__pic canvas { width: 42px !important; height: 42px !important; }
.rules__step strong { color: var(--c-shu); }
.rules__step small { display: block; font-size: 12px; color: var(--c-ink-sub); }

/* ---------- 対戦 ---------- */

.screen--battle { gap: 6px; padding: calc(6px + var(--safe-top)) 8px calc(12px + var(--safe-bottom)); overflow: hidden; }
.screen--battle > * { flex: none; }

.side { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; position: relative; }
.side__face { display: grid; place-items: center; width: 48px; height: 48px; border: var(--border); border-radius: 50%; background: var(--c-foe-soft); }
.side__face canvas { width: 40px !important; height: 40px !important; }
.side--me .side__face { width: 36px; height: 36px; background: var(--c-me-soft); }
.side--me .side__face canvas { width: 29px !important; height: 29px !important; }
.side__body { min-width: 0; }
.side__row { display: flex; align-items: center; gap: 6px; height: 24px; }
.side__name { font-size: 13px; font-weight: 900; white-space: nowrap; }
.side__cards { display: flex; gap: 3px; margin-left: auto; align-items: center; }
.mini { width: 15px; height: 21px; border: 2px solid var(--c-ink); border-radius: 4px; background: var(--c-foe); }
.mini--fx { width: 15px; height: 15px; border-radius: 50%; background: var(--c-gold); }
.mini.is-empty { background: transparent; border-style: dashed; border-color: #c9b99a; }

.life { position: relative; height: 22px; border: var(--border); border-radius: 999px; background: #d9cbb0; overflow: hidden; }
.life__lag, .life__bar { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--v, 1)); border-radius: 0; }
.life__lag { background: #fff; transition: transform 0.5s ease 0.35s; }
.life__bar { background: var(--c-matcha); transition: transform 0.2s ease; }
.life.is-mid .life__bar { background: var(--c-gold); }
.life.is-low .life__bar { background: var(--c-shu); }
.life__num {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 4px;
  font-family: var(--font-num); font-size: 14px; font-weight: 900; line-height: 1; color: var(--c-ink);
  -webkit-text-stroke: 3px var(--c-paper); paint-order: stroke;
}
.side.is-hit .side__face { animation: shake 0.4s ease; background: #ffb3a6; }
.side.is-heal .side__face { background: #cdeec7; animation: bump 0.4s var(--ease-pop); }
.dmg {
  position: absolute; left: 56px; bottom: -6px; z-index: 12; font-family: var(--font-num); font-weight: 900; font-size: 38px; line-height: 1; color: var(--c-shu);
  -webkit-text-stroke: 6px var(--c-paper); paint-order: stroke; pointer-events: none; animation: dmg 0.8s ease-out both;
}
.dmg--heal { color: var(--c-matcha-deep); }
.side--me .dmg { bottom: 4px; }

/* セリフ */
.bubble {
  position: absolute; left: 56px; top: calc(100% - 2px); z-index: 10; max-width: 250px; padding: 5px 12px; border: 2px solid var(--c-ink); border-radius: 14px;
  background: var(--c-paper); font-size: 13px; font-weight: 800; pointer-events: none; animation: pop 0.25s var(--ease-pop) both;
}
.bubble::before { content: ""; position: absolute; left: -2px; top: -8px; border: 6px solid transparent; border-bottom-color: var(--c-ink); border-top: 0; transform: translateX(10px); }

.theme {
  display: grid; grid-template-columns: 46px 1fr; gap: 8px; align-items: center; min-height: 58px; padding: 4px 10px 4px 6px;
  border: var(--border); border-radius: var(--radius-m); background: #fff4cc; box-shadow: 0 3px 0 var(--c-ink); margin-bottom: 3px;
}
.theme__icon canvas, .theme__icon { width: 46px !important; height: 46px !important; display: block; }
.theme__text { margin: 0; font-size: 17px; font-weight: 900; line-height: 1.25; text-wrap: balance; word-break: auto-phrase; }
.theme__text em { font-style: normal; color: var(--c-shu); }
.theme.is-less { background: #dfe9f8; }
.theme.is-less .theme__text em { color: var(--c-ai); }
.theme.is-new { animation: pop 0.35s var(--ease-pop); }
.theme.is-flip { animation: flip-y 0.4s ease; }
.next { display: flex; align-items: center; gap: 6px; height: 22px; padding: 0 4px; font-size: 12px; font-weight: 700; color: var(--c-ink-sub); }
.next__tag { flex: none; padding: 0 8px; border-radius: 999px; background: var(--c-ink); color: #fff; font-size: 11px; font-weight: 800; line-height: 18px; }
.next__icon { flex: none; width: 20px; height: 20px; }
.next__icon canvas { width: 20px !important; height: 20px !important; display: block; }
.next__text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.screen--battle > .mid { flex: 1 1 0; min-height: 0; }
.mid { position: relative; display: grid; grid-template-columns: 1fr 30px 1fr; align-items: center; justify-items: center; }
.mid__vs { font-family: var(--font-num); font-size: 18px; font-weight: 900; color: var(--c-ink-sub); }
.fcard {
  position: relative; width: 100%; max-width: 210px; height: 100%; max-height: 270px; border: var(--border); border-radius: 18px;
  background: var(--c-paper); box-shadow: 0 4px 0 var(--c-ink); overflow: hidden;
}
.fcard--me { border-color: var(--c-shu-deep); box-shadow: 0 4px 0 var(--c-shu-deep); }
.fcard--foe { border-color: var(--c-ai); box-shadow: 0 4px 0 var(--c-ai); }
.fcard__back { position: absolute; inset: 0; width: 100% !important; height: 100% !important; object-fit: cover; display: none; }
.fcard__body { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: space-evenly; padding: 22px 4px 4px; background: linear-gradient(var(--rs, #fff) 0 100%); }
.fcard__who { position: absolute; top: 0; left: 0; z-index: 2; padding: 1px 10px 2px; border-radius: 0 0 10px 0; color: #fff; font-size: 12px; font-weight: 900; }
.fcard--me .fcard__who { background: var(--c-shu-deep); }
.fcard--foe .fcard__who { background: var(--c-ai); }
.fcard__shape { flex: 0 1 auto; min-height: 0; height: 40%; aspect-ratio: 1; }
.fcard__shape canvas { width: 100% !important; height: 100% !important; display: block; }
.fcard__name { font-size: clamp(16px, 4.6vw, 22px); font-weight: 900; line-height: 1.1; }
.fcard__value { font-weight: 900; line-height: 1.1; white-space: nowrap; }
.fcard__value .num { font-size: clamp(20px, 5.8vw, 28px); }
.fcard__value .unit { font-size: 12px; margin-left: 2px; }
.fcard__rank { padding: 1px 10px; border: 2px solid var(--c-ink); border-radius: 999px; background: #fff; font-size: 13px; font-weight: 900; line-height: 1.3; white-space: nowrap; }
.fcard__rank.is-up { background: var(--c-gold); }
.fcard--foe .fcard__who { left: auto; right: 0; border-radius: 0 0 0 10px; }
.fcard__fx { position: absolute; top: 25px; left: 3px; z-index: 3; display: grid; place-items: center; width: 34px; height: 34px; border: 2px solid var(--c-ink); border-radius: 50%; background: var(--fxc, var(--c-gold)); }
.fcard--foe .fcard__fx { left: auto; right: 3px; }
.fcard__fx canvas { width: 24px !important; height: 24px !important; }
.fcard__fx.is-cancel { filter: grayscale(1); }
.fcard__fx.is-cancel::after { content: ""; position: absolute; width: 130%; height: 4px; background: var(--c-ink); transform: rotate(-45deg); }
.fcard.is-empty { border-style: dashed; background: rgba(255, 255, 255, 0.4); box-shadow: none; border-color: #c9b99a; }
.fcard.is-empty .fcard__body { background: none; justify-content: center; }
.fcard.is-empty .fcard__who { background: #a89a83; }
.fcard__ask { font-size: 13px; font-weight: 800; color: var(--c-ink-sub); text-align: center; }
.fcard.is-back .fcard__back { display: block; }
.fcard.is-back .fcard__body { display: none; }
.fcard.is-back .fcard__who { display: none; }
.fcard.is-in-foe { animation: in-foe 0.3s var(--ease-pop) both; }
.fcard.is-in-me { animation: in-me 0.3s var(--ease-pop) both; }
.fcard.is-flip { animation: flip-x 0.36s ease; }
.fcard.is-win { z-index: 3; animation: win 0.45s var(--ease-pop) both; }
.fcard.is-win .fcard__body { background: #fff0b8; }
.fcard.is-lose { animation: shake 0.4s ease; }
.fcard.is-lose .fcard__body { filter: grayscale(0.75) brightness(0.94); }

.verdict {
  position: absolute; left: 50%; top: 50%; z-index: 8; transform: translate(-50%, -50%) rotate(-5deg); padding: 3px 10px;
  border: var(--border); border-radius: 14px; background: var(--c-gold); box-shadow: 0 4px 0 var(--c-ink);
  font-size: 20px; font-weight: 900; line-height: 1.25; text-align: center; white-space: nowrap; pointer-events: none; animation: stamp 0.35s var(--ease-pop) both;
}
.verdict small { display: block; font-size: 12px; }
.verdict--win { background: var(--c-shu); color: #fff; }
.verdict--lose { background: var(--c-ai); color: #fff; }
.mid > .verdict { top: 33%; }

/* のぞき見 */
.peek { position: absolute; left: 0; right: 0; top: 0; z-index: 7; display: flex; align-items: center; justify-content: center; gap: 4px; padding: 5px; border: 2px solid var(--c-ink); border-radius: 12px; background: #d9f3ef; }
.peek__chip { padding: 1px 6px; border: 2px solid var(--c-ink); border-radius: 8px; background: var(--rs, #fff); font-size: 12px; font-weight: 800; white-space: nowrap; }

.tip { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 22px; font-size: 13px; font-weight: 800; line-height: 1.3; text-align: center; color: var(--c-ink); }
.tip__btn { flex: none; min-height: 28px; padding: 0 12px; border: 2px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font-size: 12px; font-weight: 900; cursor: pointer; }
.tip__btn:disabled { opacity: 0.45; }

.effects { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.ecard {
  position: relative; display: flex; align-items: center; gap: 2px; min-width: 0; height: 44px; padding: 0 3px; border: var(--border); border-radius: 14px;
  background: var(--fxc, var(--c-paper)); box-shadow: 0 3px 0 var(--c-ink); cursor: pointer; transition: transform 0.12s var(--ease-pop); text-align: left; touch-action: manipulation;
}
.ecard__icon { flex: none; width: 27px; height: 27px; }
.ecard__icon canvas { width: 27px !important; height: 27px !important; display: block; }
.ecard__name { min-width: 0; font-size: 12px; font-weight: 900; line-height: 1.15; letter-spacing: -0.06em; white-space: nowrap; }
.ecard__text { display: none; }
.ecard.is-selected { transform: translateY(-5px); outline: 4px solid var(--c-shu); outline-offset: 0; }
.ecard.is-disabled, .ecard:disabled { filter: grayscale(0.8); opacity: 0.55; cursor: default; }
.ecard--empty { border-style: dashed; border-color: #c9b99a; background: none; box-shadow: none; pointer-events: none; }

.hand { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; height: var(--hand-h); padding-top: 0; }
.pcard {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: space-between; min-width: 0; padding: 3px 0 0; overflow: hidden;
  border: var(--border); border-radius: 14px; background: var(--rs); box-shadow: 0 4px 0 var(--c-ink); cursor: pointer;
  transition: transform 0.14s var(--ease-pop), filter 0.15s; touch-action: manipulation;
}
.pcard__name { font-size: clamp(16px, 4.7vw, 22px); font-weight: 900; line-height: 1.2; letter-spacing: -0.04em; white-space: nowrap; }
.pcard__shape { flex: 1 1 0; min-height: 0; display: grid; place-items: center; width: 100%; }
.pcard__shape canvas { width: auto !important; height: 100% !important; max-width: 88%; aspect-ratio: 1; object-fit: contain; display: block; min-height: 0; }
.pcard__region { width: 100%; background: var(--rc); border-top: 2px solid var(--c-ink); font-size: 11px; font-weight: 800; line-height: 16px; text-align: center; white-space: nowrap; letter-spacing: -0.05em; }
.pcard__hint { position: absolute; right: 1px; bottom: 19px; display: grid; place-items: center; width: 25px; height: 25px; border: 2px solid var(--c-ink); border-radius: 50%; background: #fff; font-size: 15px; font-weight: 900; line-height: 1; }
.pcard__hint--great { background: var(--c-gold); }
.pcard__hint--good { background: #cdeec7; }
.pcard__hint--weak { background: #dfe6f2; }
.hand, .effects { overflow: visible; }
.pcard.is-selected { z-index: 4; transform: translateY(-9px); background: #fff; outline: 4px solid var(--c-shu); box-shadow: 0 13px 0 rgba(59, 47, 47, 0.25); }
.pcard.is-disabled, .pcard:disabled { filter: grayscale(0.8) brightness(0.93); cursor: default; }
.pcard.is-new { animation: draw 0.3s var(--ease-pop) both; animation-delay: calc(var(--i, 0) * 50ms); }
.pcard--empty { border-style: dashed; border-color: #c9b99a; background: none; box-shadow: none; pointer-events: none; }
.pcard:focus-visible, .ecard:focus-visible { outline: 4px solid var(--c-gold); }
.hand.is-choosing .pcard:not(.is-selected) { filter: brightness(0.93); }

.btn.fight { width: auto; }
.fight { min-height: 50px; padding: 4px 20px; margin: 4px 4px 4px; font-size: 22px; --btn-depth: 5px; }
.fight:not(:disabled).is-ready { animation: ready 1.2s ease-in-out infinite; }

.fx { position: absolute; inset: 0; z-index: 9; pointer-events: none; }
.screen--battle .skip { position: absolute; inset: 0; z-index: 20; border: 0; background: transparent; }
.foot { margin: 0; font-size: 10px; line-height: 12px; color: var(--c-ink-sub); text-align: center; }

/* ---------- テーマ発表・はじまり ---------- */

.cutin { position: absolute; inset: 0; z-index: 30; display: grid; place-content: center; justify-items: center; gap: 8px; background: rgba(255, 246, 228, 0.88); text-align: center; animation: fade 0.2s both; }
.cutin__face canvas { width: 150px !important; height: 150px !important; }
.cutin__name { font-size: 26px; font-weight: 900; }
.cutin__line { padding: 8px 18px; border: var(--border); border-radius: 18px; background: var(--c-paper); font-size: 16px; font-weight: 800; }

/* ---------- 勝敗（下からのシート。見せ場の上半分は隠さない） ---------- */

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 66%; overflow-y: auto; padding: 16px 16px calc(18px + var(--safe-bottom));
  border: var(--border); border-bottom: 0; border-radius: 26px 26px 0 0; background: var(--c-paper); text-align: center; animation: sheet 0.35s ease both;
}
.sheet__head { display: flex; align-items: center; justify-content: center; gap: 10px; }
.sheet__face { width: 64px; height: 64px; }
.sheet__face canvas { width: 64px !important; height: 64px !important; }
.sheet__title { margin: 0; font-size: 30px; font-weight: 900; line-height: 1.1; color: var(--c-shu); }
.sheet--lose .sheet__title { color: var(--c-ai); }
.sheet__sub { margin: 2px 0 0; font-size: 13px; font-weight: 800; }
.facts { display: grid; gap: 8px; margin: 12px 0; padding: 0; list-style: none; text-align: left; }
.fact { display: grid; grid-template-columns: 40px 1fr; gap: 8px; align-items: center; padding: 7px 10px; border: 2px solid var(--c-ink); border-radius: 14px; background: #fff4cc; font-size: 13px; font-weight: 700; line-height: 1.4; }
.fact--find { background: #d9f3ef; }
.fact__icon canvas { width: 40px !important; height: 40px !important; display: block; }
.fact b { display: block; font-size: 11px; color: var(--c-ink-sub); }
.streak { margin: 0 0 12px; font-size: 14px; font-weight: 800; }
.streak .num { font-size: 22px; color: var(--c-shu); }
.sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 10px; }
.sheet__actions .btn--main { grid-column: 1 / -1; }
.screen--battle.is-over > .tip, .screen--battle.is-over > .fight { visibility: hidden; }

/* ---------- 出典 ---------- */

.screen--sources { gap: 10px; }
.sources__note { margin: 0; font-size: 12px; color: var(--c-ink-sub); }
.sources__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.src { padding: 8px 12px; border: 2px solid var(--c-ink); border-radius: var(--radius-s); background: var(--c-paper); font-size: 12px; overflow-wrap: anywhere; }
.src b { display: block; font-size: 14px; }

.toast { position: absolute; left: 50%; bottom: 84px; z-index: 60; transform: translateX(-50%); padding: 8px 16px; border-radius: 999px; background: var(--c-ink); color: #fff; font-size: 13px; font-weight: 800; white-space: nowrap; animation: pop 0.25s both; }

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

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(0.8); } }
@keyframes bump { 40% { transform: scale(1.3); } }
@keyframes shake { 20% { transform: translateX(-7px); } 45% { transform: translateX(6px); } 70% { transform: translateX(-4px); } }
@keyframes dmg { 0% { opacity: 0; transform: translateY(12px) scale(0.5); } 25% { opacity: 1; transform: scale(1.25); } 45%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px); } }
@keyframes flip-x { 0% { transform: scaleX(1); } 50% { transform: scaleX(0.02); } 100% { transform: scaleX(1); } }
@keyframes flip-y { 50% { transform: scaleY(0.02); } }
@keyframes in-foe { from { transform: translateY(-60px) rotate(-8deg); opacity: 0; } }
@keyframes in-me { from { transform: translateY(80px) rotate(8deg); opacity: 0; } }
@keyframes win { 50% { transform: scale(1.06) rotate(-2deg); } 100% { transform: none; } }
@keyframes stamp { from { opacity: 0; transform: translate(-50%, -50%) scale(2) rotate(-14deg); } }
@keyframes draw { from { opacity: 0; transform: translateY(50px); } }
@keyframes ready { 50% { filter: brightness(1.12); transform: translateY(-2px); } }
@keyframes sheet { from { transform: translateY(100%); } }

/* ---------- 広い画面 ---------- */

@media (min-width: 420px) and (min-height: 800px) {
  .theme { min-height: 68px; }
  .theme__text { font-size: 20px; }
  .ecard { height: 52px; }
  .ecard__name { font-size: 14px; }
  .next { height: 26px; font-size: 14px; }
}

@media (min-height: 800px) {
  .screen--battle { gap: 9px; }
  .fight { min-height: 56px; }
  .fcard { max-height: 290px; }
  .side__face { width: 56px; height: 56px; }
  .side__face canvas { width: 46px !important; height: 46px !important; }
  .dmg, .bubble { left: 64px; }
}

@media (min-width: 700px) and (min-height: 600px) {
  .app { max-width: 760px; }
  .screen--battle { padding-left: 16px; padding-right: 16px; }
  .screen--select, .screen--rules, .screen--sources { padding-left: 80px; padding-right: 80px; }
  .theme { grid-template-columns: 52px auto; justify-content: center; }
  .theme__text { font-size: 24px; }
  .next { justify-content: center; font-size: 14px; }
  .hand { gap: 10px; }
  .pcard__name { font-size: 24px; }
  .pcard__region { font-size: 13px; line-height: 20px; letter-spacing: 0; }
  .pcard__hint { width: 34px; height: 34px; font-size: 20px; bottom: 25px; right: 4px; }
  .ecard { height: 52px; justify-content: center; gap: 8px; }
  .ecard__name { font-size: 16px; letter-spacing: 0; }
  .mid { grid-template-columns: 240px 60px 240px; justify-content: center; }
  .fcard { max-width: 240px; max-height: 320px; }
  .side__name { font-size: 15px; }
  .btn.fight { width: 340px; align-self: center; }
  .sheet { left: 100px; right: 100px; }
  .tip { font-size: 15px; }
}

/* スマホ横（.rotate-hint を .app の外に置く） */
.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; }
@keyframes rotate-phone { 0%, 30% { transform: rotate(-90deg); } 60%, 100% { transform: none; } }
@media (orientation: landscape) and (max-height: 480px) {
  .app { display: none; }
  .rotate-hint { display: flex; }
}

@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; }
  .dmg { animation: none !important; }
}
