/* ジュースでっぽうバトル style.css
   シリーズ共通: ポップ・太い墨枠・押すと沈むボタン・丸ゴシック（外部フォントなし）＋夏の公園 */
:root {
  --ink: #33302e;
  --ink-sub: #6f665e;
  --paper: #fffdf6;
  --sky: #bfe9ff;
  --sky-line: #a9dcf5;
  --grass: #8fd86b;
  --r: #ff5470;  --r-deep: #c9304b;  --r-light: #ffd3dc;
  --g: #5fcf4a;  --g-deep: #36962a;  --g-light: #d6f6cc;
  --b: #33b6f5;  --b-deep: #1a7fb5;  --b-light: #cdeeff;
  --me: #ffcf33; --me-deep: #d79c00;
  --foe: #8a63e8; --foe-deep: #5b3cb0;
  --gold: #ffc83d;
  --font: "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", ui-rounded, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-w: min(100vw, 480px);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); color: var(--ink); background: #8fd0f0;
  overflow: hidden; position: fixed; inset: 0;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; line-height: 1.5;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
}
button { font: inherit; color: inherit; }
canvas { display: block; touch-action: none; }
.num { font-family: var(--font-num); font-weight: 900; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.app {
  position: relative; width: var(--app-w); height: 100dvh; margin: 0 auto; overflow: hidden;
  background-color: var(--sky);
  background-image: linear-gradient(var(--sky-line) 1px, transparent 1px), linear-gradient(90deg, var(--sky-line) 1px, transparent 1px);
  background-size: 22px 22px;
  box-shadow: 0 0 0 3px var(--ink);
}

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

.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); color: var(--ink); text-decoration: none; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 3px 0 var(--ink); }
.screen--title > a.back-to-games:active { transform: translateY(3px); box-shadow: none; }
.screen--title:has(> a.back-to-games:not([hidden])) { padding-top: calc(52px + var(--safe-top)); }

/* ボタン */
.btn {
  --bg: var(--r); --edge: var(--r-deep); --fg: #fff;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 52px; padding: 10px 22px; border: 3px solid var(--ink); border-radius: 999px;
  background: var(--bg); color: var(--fg); font-weight: 900; font-size: 19px; letter-spacing: .04em;
  box-shadow: 0 6px 0 var(--ink); cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(6px); box-shadow: 0 0 0 var(--ink); }
.btn--block { width: 100%; }
.btn--sub { --bg: var(--b); }
.btn--ghost { --bg: var(--paper); --fg: var(--ink); }
.btn--small { min-height: 40px; font-size: 15px; padding: 6px 16px; box-shadow: 0 4px 0 var(--ink); }
.btn--small:active { transform: translateY(4px); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* タイトル */
.screen--title { align-items: center; justify-content: safe center; gap: 10px; }
.logo { margin: 0; text-align: center; line-height: 1.1; }
.logo__sub { display: inline-block; font-size: 13px; font-weight: 800; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 12px; margin-bottom: 8px; }
.logo__main { display: block; font-size: clamp(34px, 11vw, 50px); font-weight: 900; letter-spacing: .02em; color: var(--paper); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.logo__main--2 { font-size: clamp(40px, 13vw, 60px); color: var(--me); }
.logo__c { display: inline-block; animation: bob 1.8s ease-in-out infinite; animation-delay: calc(var(--d, 0) * 1s); }
.logo__c:nth-child(2n) { --d: .15; } .logo__c:nth-child(3n) { --d: .3; }
.c-r { color: var(--r); } .c-g { color: var(--g); } .c-b { color: var(--b); }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.title__art { width: 100%; flex: 1 1 auto; min-height: 150px; max-height: 340px; position: relative; }
.title__art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.title__actions { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 14px; padding-bottom: 6px; }
.title__sub { display: flex; gap: 10px; justify-content: center; }

/* ステージ選択 */
.select__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.select__title { flex: 1; margin: 0; font-size: 24px; font-weight: 900; }
.select__total { font-weight: 900; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 3px 12px; }
.select__total, .stage__stars { color: var(--ink); }
.stage-list { display: flex; flex-direction: column; gap: 12px; padding-bottom: 12px; }
.stage {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: var(--paper); border: 3px solid var(--ink); border-radius: 18px;
  box-shadow: 0 5px 0 var(--ink); cursor: pointer;
}
.stage:active { transform: translateY(5px); box-shadow: none; }
.stage__no { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); background: var(--me); display: grid; place-items: center; font-size: 22px; }
.stage__body { flex: 1; min-width: 0; }
.stage__name { display: block; font-weight: 900; font-size: 18px; }
.stage__sub { display: block; font-size: 13px; color: var(--ink-sub); }
.stage__stars { flex: none; font-size: 18px; letter-spacing: 1px; }
.stage__stars .on { color: var(--gold); -webkit-text-stroke: 1px var(--ink); }
.stage__stars .off { color: #d8d0c4; }
.stage.is-locked { background: #e8e4dc; color: #9a928a; pointer-events: none; box-shadow: 0 5px 0 #9a928a; border-color: #9a928a; }
.stage.is-locked .stage__no { background: #cfc8be; border-color: #9a928a; }

/* プレイ */
.screen--play { padding: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom)); gap: 6px; overflow: hidden; }
.hud { display: flex; align-items: center; gap: 8px; flex: none; }
.hud__menu { flex: none; width: 42px; height: 42px; border: 3px solid var(--ink); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; padding: 0; cursor: pointer; }
.hud__menu i { display: block; width: 18px; height: 3px; border-radius: 2px; background: var(--ink); }
.hud__menu:active { transform: translateY(3px); box-shadow: none; }
.hud__orb { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; background: var(--paper); border: 3px solid var(--ink); border-radius: 999px; padding: 4px 10px; height: 42px; }
.hud__orb small { font-size: 12px; font-weight: 900; flex: none; }
.hud__orb .num { flex: none; min-width: 2.2em; text-align: right; font-size: 17px; }
.hpbar { flex: 1; height: 14px; border: 2px solid var(--ink); border-radius: 99px; background: #e9e3d8; overflow: hidden; }
.hpbar i { display: block; height: 100%; width: 100%; transition: width .25s; }
.hud__orb--enemy .hpbar i { background: var(--foe); }
.hud__orb--me .hpbar i { background: var(--me); }
.hud__orb--enemy small { color: var(--foe-deep); }
.hud__orb--me small { color: var(--me-deep); }
.hud__orb.is-hit { animation: shake .25s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.hud__turn { flex: none; background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 2px 8px; height: 42px; display: flex; align-items: baseline; gap: 2px; line-height: 34px; }
.hud__turn small { font-size: 11px; font-weight: 800; }
.hud__turn .num { font-size: 20px; }
.hud__msg { flex: none; margin: 0; font-weight: 900; font-size: 14px; max-width: 48%; text-align: right; line-height: 1.25; }
.hud__msg.is-warn { color: var(--r-deep); }

.board { position: relative; flex: 1 1 auto; min-height: 0; }
.board canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%);
  padding: 8px 22px; background: var(--paper); border: 4px solid var(--ink); border-radius: 999px;
  font-weight: 900; font-size: 22px; white-space: nowrap; box-shadow: 0 5px 0 var(--ink);
  pointer-events: none; animation: pop .35s cubic-bezier(.34, 1.56, .64, 1);
}
.banner.is-big { font-size: 30px; }
@keyframes pop { from { transform: translate(-50%, -50%) scale(.4); opacity: 0; } }
.speed { position: absolute; right: 4px; top: 4px; height: 34px; padding: 0 10px !important; border: 3px solid var(--ink); border-radius: 10px; background: var(--paper); font-weight: 900; font-size: 13px; box-shadow: 0 3px 0 var(--ink); cursor: pointer; }
.speed.is-on { background: var(--me); }
.speed:active { transform: translateY(3px); box-shadow: none; }
.board__pause { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255, 253, 246, .6); font-weight: 900; font-size: 20px; }

.hand { flex: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; height: clamp(96px, 15dvh, 122px); }
.hcard {
  --c: var(--r); --cl: var(--r-light);
  position: relative; border: 3px solid var(--ink); border-radius: 16px; background: var(--cl);
  box-shadow: 0 5px 0 var(--ink); display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 0 0 4px; touch-action: none; cursor: grab; overflow: hidden; transition: transform .12s, opacity .2s;
}
.hcard[data-a="1"] { --c: var(--g); --cl: var(--g-light); }
.hcard[data-a="2"] { --c: var(--b); --cl: var(--b-light); }
.hcard canvas { position: absolute; left: 0; right: 0; top: 2px; bottom: 26px; width: 100%; height: calc(100% - 28px); pointer-events: none; }
.hcard__name { position: relative; font-size: 12px; font-weight: 900; line-height: 1.1; text-align: center; }
.hcard__name b { color: var(--c); -webkit-text-stroke: .6px var(--ink); }
.hcard__adv { position: absolute; top: 4px; right: 4px; font-size: 11px; font-weight: 900; background: var(--gold); border: 2px solid var(--ink); border-radius: 99px; padding: 0 5px; line-height: 16px; }
.hcard.is-empty { background: #e9e3d8; box-shadow: 0 5px 0 #b8ae9f; border-color: #b8ae9f; }
.hand.is-locked .hcard:not(.is-empty) { opacity: .55; }
.hand.is-ready .hcard:not(.is-empty) { animation: ready 1.2s ease-in-out infinite; }
@keyframes ready { 50% { transform: translateY(-6px); } }
.hcard.is-drag { opacity: .35; animation: none; }

/* モーダル */
.modal { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(51, 48, 46, .45); opacity: 0; visibility: hidden; transition: opacity .2s, visibility 0s linear .2s; overflow-y: auto; }
.modal.is-open { opacity: 1; visibility: visible; transition: opacity .2s, visibility 0s; }
.card { width: 100%; max-width: 360px; background: var(--paper); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 7px 0 var(--ink); padding: 18px 18px 20px; max-height: calc(100dvh - 32px); overflow-y: auto; }
.card__title { margin: 0 0 10px; text-align: center; font-size: 22px; font-weight: 900; }
.card__actions { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 14px; }
.card__row { display: flex; gap: 10px; justify-content: center; }
.rules__list { margin: 0; padding-left: 1.3em; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.rules__attr { margin: 12px 0 8px; padding: 8px; background: #fff3d8; border: 3px solid var(--ink); border-radius: 14px; text-align: center; font-size: 14px; }
.rules__attr p { margin: 4px 0 0; font-size: 13px; }
.chip { display: inline-block; padding: 1px 8px; border: 2px solid var(--ink); border-radius: 99px; font-weight: 900; font-size: 13px; color: #fff; -webkit-text-stroke: 0; }
.chip--r { background: var(--r); } .chip--g { background: var(--g); } .chip--b { background: var(--b); }
.rules__roles { margin: 0; padding-left: 1.2em; font-size: 13px; }
.rules__tip { font-size: 13px; margin: 8px 0 0; }
.intro { text-align: center; }
.intro__no { margin: 0; font-size: 14px; color: var(--ink-sub); }
.intro__sub { margin: -6px 0 8px; font-weight: 800; }
.intro__tip { margin: 0; padding: 10px; background: #fff3d8; border: 3px dashed var(--ink-sub); border-radius: 14px; font-size: 14px; }
.result { text-align: center; }
.result__label { margin: 0; font-size: 40px; font-weight: 900; color: var(--me); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.result__label.is-lose { color: var(--foe); }
.result__label.is-draw { color: var(--b); }
.result__stars { display: flex; justify-content: center; gap: 8px; margin: 4px 0; }
.result__stars i { width: 40px; height: 40px; background: #ddd5c8; clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.result__stars i.on { background: var(--gold); animation: pop2 .4s cubic-bezier(.34, 1.56, .64, 1) both; }
.result__stars i.on:nth-child(2) { animation-delay: .15s; } .result__stars i.on:nth-child(3) { animation-delay: .3s; }
@keyframes pop2 { from { transform: scale(0); } }
.result__note { margin: 0 0 8px; font-weight: 800; font-size: 15px; }
.result__stats { list-style: none; margin: 0; padding: 8px 10px; background: #fff3d8; border: 3px solid var(--ink); border-radius: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; font-size: 13px; text-align: left; }
.result__stats b { float: right; font-family: var(--font-num); }

.rotate { position: absolute; inset: 0; z-index: 50; display: none; place-items: center; background: var(--sky); font-weight: 900; font-size: 22px; }
.rotate p { background: var(--paper); border: 4px solid var(--ink); border-radius: 20px; padding: 16px 24px; }
@media (orientation: landscape) and (max-height: 500px) { .rotate { display: grid; } }

.toast { position: absolute; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 99px; font-weight: 800; font-size: 14px; }

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