/* 撮れ！ベストショット style.css — 構造は docs/design.md */
:root {
  --c-ink: #3b2f2f;
  --c-ink-sub: #6f6a7a;
  --c-paper: #fffdf7;
  --c-cream: #fff6e2;
  --c-wood: #b98355;
  --c-line: #e6d8bd;
  --c-red: #e8413b;
  --c-red-deep: #b8302c;
  --c-blue: #3f86e8;
  --c-blue-deep: #2a5fb0;
  --c-sky: #bfe6ff;
  --c-green: #3fa66a;
  --c-green-deep: #2b7a4b;
  --c-gold: #ffc83d;
  --c-gold-deep: #d99a00;
  --c-lock: #a7a9b8;
  --c-night: #3c4a63;
  --c-bg: #f3dfb8;
  --c-bg-stripe: #f8e9ca;

  --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: 12px;
  --radius-m: 18px;
  --radius-l: 28px;
  --btn-depth: 6px;
  --dur-fast: 0.12s;
  --dur-mid: 0.25s;

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

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: var(--font-base);
  color: var(--c-ink);
  background: var(--c-bg);
}
button { font: inherit; color: inherit; touch-action: manipulation; }

.app {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, rgba(255,255,255,.9) 0 3px, transparent 4px) 0 0 / 64px 64px,
    radial-gradient(circle at 70% 75%, rgba(255,255,255,.8) 0 2px, transparent 3px) 0 0 / 48px 48px,
    repeating-linear-gradient(135deg, var(--c-bg) 0 28px, var(--c-bg-stripe) 28px 56px);
}

/* ---------- 画面 ---------- */
.screen {
  position: absolute; inset: 0;
  display: none; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(16px + var(--safe-top)) calc(16px + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(16px + var(--safe-left));
  overflow-y: auto;
}
.screen.is-active { display: flex; animation: screen-in var(--dur-mid) ease both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--c-paper);
  border: 4px solid var(--c-ink);
  border-radius: var(--radius-l);
  box-shadow: 0 8px 0 var(--c-ink);
  padding: 20px 22px;
}

/* ---------- ボタン ---------- */
.btn {
  --btn-bg: var(--c-red);
  --btn-edge: var(--c-red-deep);
  --btn-fg: #fff;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 28px;
  border: 3px solid var(--c-ink); border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: 20px; font-weight: 800; letter-spacing: 0.04em;
  cursor: pointer;
  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);
  margin-bottom: var(--btn-depth);
}
.btn::after {
  content: ""; position: absolute; top: 5px; left: 18%; right: 18%; height: 6px;
  border-radius: 999px; background: rgba(255,255,255,.35); pointer-events: none;
}
.btn:hover { filter: brightness(1.05); }
.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:disabled { filter: grayscale(.8) opacity(.6); cursor: not-allowed; }
.btn--block { display: flex; width: 100%; }
.btn--blue { --btn-bg: var(--c-blue); --btn-edge: var(--c-blue-deep); }
.btn--green { --btn-bg: var(--c-green); --btn-edge: var(--c-green-deep); }
.btn--gold { --btn-bg: var(--c-gold); --btn-edge: var(--c-gold-deep); --btn-fg: var(--c-ink); }
.btn--ghost { --btn-bg: var(--c-paper); --btn-edge: var(--c-line); --btn-fg: var(--c-ink); }
.btn--small { min-height: 40px; padding: 6px 16px; font-size: 15px; --btn-depth: 4px; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; padding: 0;
  border: 3px solid var(--c-ink); border-radius: 50%;
  background: var(--c-paper);
  font-size: 20px; font-weight: 900; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--c-ink);
  transition: transform .08s ease, box-shadow .08s ease;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 0 0 var(--c-ink); }
.icon-btn--pause::before { content: ""; width: 12px; height: 14px; border-left: 4px solid var(--c-ink); border-right: 4px solid var(--c-ink); }
.icon-btn--back::before { content: "‹"; font-size: 26px; margin-top: -3px; }
.icon-btn--help::before { content: "?"; }
.icon-btn--sound::before { content: "♪"; }
.icon-btn--sound.is-off { opacity: .55; }
.btn:focus-visible, .icon-btn:focus-visible, .time-card:focus-visible, .zukan-cell:focus-visible { outline: 4px solid var(--c-gold); outline-offset: 3px; }


.icon-btn { flex: none; }
.row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
[hidden] { display: none !important; }

/* ---------- 舞台（390:760 を中央に内接） ---------- */
.stage { position: absolute; inset: 0; overflow: hidden; background: #4d3a34; }
.stage canvas { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: block; touch-action: none; }
.title-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------- タイトル ---------- */
.screen--title { justify-content: space-between; gap: 8px; background: linear-gradient(rgba(255,250,235,.25), rgba(255,250,235,0) 40%, rgba(60,40,30,.35)); }
.logo { margin: 34px 0 0; text-align: center; font-weight: 900; line-height: 1.02; transform: rotate(-3deg); color: var(--c-paper); paint-order: stroke fill; -webkit-text-stroke: 10px var(--c-ink); filter: drop-shadow(0 5px 0 var(--c-ink)); }
.logo__a { display: block; font-size: clamp(38px, 13vw, 58px); color: var(--c-gold); }
.logo__b { display: block; font-size: clamp(34px, 11.4vw, 50px); letter-spacing: -.04em; }
.tagline { display: inline-block; margin: 14px 0 0; padding: 5px 14px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-paper); font-size: 14px; font-weight: 800; }
.title-menu { width: min(100%, 340px); display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.title-menu .btn { width: 100%; }
.title-menu .row .btn { flex: 1; width: auto; }
.hiscore { text-align: center; font-weight: 900; font-size: 15px; color: #fff; -webkit-text-stroke: 5px var(--c-ink); paint-order: stroke fill; }
.screen > a.back-to-games, .back-to-games { align-self: center; padding: 8px 14px; border-radius: 999px; background: rgba(255,253,247,.9); border: 2px solid var(--c-ink); color: var(--c-ink); font-size: 13px; font-weight: 800; text-decoration: none; }

/* ---------- 時間帯 ---------- */
.time-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.time-card { position: relative; min-height: 64px; padding: 6px 4px; border: 3px solid var(--c-ink); border-radius: var(--radius-m); background: var(--tc, #bfe6ff); font-weight: 900; font-size: 15px; box-shadow: 0 4px 0 var(--c-ink); cursor: pointer; }
.time-card small { display: block; font-size: 11px; font-weight: 800; }
.time-card[data-time="asa"], .time-card[data-time="morning"] { --tc: linear-gradient(#a8def8, #fff3cf); }
.time-card[data-time="yugata"], .time-card[data-time="evening"] { --tc: linear-gradient(#f4968a, #ffd991); }
.time-card[data-time="yoru"], .time-card[data-time="night"] { --tc: linear-gradient(#26316a, #5d6aa8); color: #fff3bd; }
.time-card.is-selected { box-shadow: 0 0 0 4px var(--c-gold), 0 5px 0 4px var(--c-ink); transform: translateY(-2px); }
.time-card:disabled, .time-card.is-locked { filter: grayscale(.85) brightness(.9); cursor: not-allowed; }

/* ---------- ルール・シート ---------- */
.overlay { position: absolute; inset: 0; z-index: 40; display: none; align-items: center; justify-content: center; padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom)); background: rgba(45,32,28,.55); }
.overlay.is-active { display: flex; }
.overlay .card { width: min(100%, 360px); max-height: 100%; overflow-y: auto; touch-action: pan-y; animation: pop .22s ease both; }
.card h2 { margin: 0 0 12px; font-size: 23px; text-align: center; }
.rules { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 10px; }
.rules li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; font-size: 15px; font-weight: 700; line-height: 1.45; }
.rules canvas, .rules .ico { width: 64px; height: 56px; border: 3px solid var(--c-ink); border-radius: 12px; background: #cfe9b8; }
.rules b { color: var(--c-red-deep); }
@keyframes pop { from { transform: scale(.86); opacity: 0; } }

/* ---------- HUD ---------- */
.hud { position: absolute; z-index: 10; inset: 0 0 auto; padding: calc(8px + var(--safe-top)) calc(10px + var(--safe-right)) 0 calc(10px + var(--safe-left)); max-width: 520px; margin: 0 auto; display: flex; gap: 7px; align-items: center; pointer-events: none; }
.hud button { pointer-events: auto; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 42px; padding: 3px 11px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-paper); box-shadow: 0 3px 0 var(--c-ink); font: 900 19px/1 var(--font-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.chip small { font: 800 10px/1 var(--font-base); color: var(--c-ink-sub); }
.chip--time.is-warn { background: var(--c-red); color: #fff; animation: throb .6s infinite alternate; }
.chip--time.is-warn small { color: #fff; }
.chip--film::before { content: ""; width: 20px; height: 17px; border: 3px solid var(--c-ink); border-radius: 4px; background: radial-gradient(circle, #8fd3f7 0 4px, transparent 4.5px), #57505f; }
.chip--film.is-low { background: #ffd3cc; }
.chip--score { flex: 1; min-width: 0; justify-content: center; }
.hud .icon-btn { width: 40px; height: 40px; }
@keyframes throb { to { transform: scale(1.06); } }
.combo { position: absolute; z-index: 9; top: calc(60px + var(--safe-top)); left: 50%; transform: translateX(-50%) rotate(-3deg); pointer-events: none; font-size: 24px; font-weight: 900; color: var(--c-gold); -webkit-text-stroke: 7px var(--c-ink); paint-order: stroke fill; opacity: 0; white-space: nowrap; }
.combo.is-on { opacity: 1; animation: pop .2s ease; }
.banner { position: absolute; z-index: 12; left: 0; right: 0; top: 40%; padding: 12px; text-align: center; background: var(--c-red); color: #fff; border: solid var(--c-ink); border-width: 4px 0; font-size: 30px; font-weight: 900; pointer-events: none; animation: banner .35s ease both; }
.banner--fever { background: repeating-linear-gradient(135deg, #ffc83d 0 22px, #ffd86f 22px 44px); color: var(--c-ink); }
@keyframes banner { from { transform: scaleY(0); } }
.flash { position: absolute; inset: 0; z-index: 8; background: #fff; opacity: 0; pointer-events: none; }
.flash.is-on { animation: flash .22s ease-out; }
@keyframes flash { from { opacity: .75; } to { opacity: 0; } }
.pop { position: absolute; z-index: 9; transform: translate(-50%, -100%); pointer-events: none; font: 900 26px/1.05 var(--font-num); text-align: center; color: #fff; -webkit-text-stroke: 6px var(--c-ink); paint-order: stroke fill; animation: rise .95s ease-out both; white-space: nowrap; }
.pop--best { color: var(--c-gold); font-size: 32px; }
.pop--miss { color: #c9ccd6; font-size: 20px; }
.pop small { display: block; font: 900 14px/1.2 var(--font-base); }
@keyframes rise { 0% { opacity: 0; translate: 0 12px; scale: .6; } 20% { opacity: 1; translate: 0 0; scale: 1.1; } 75% { opacity: 1; } 100% { opacity: 0; translate: 0 -26px; } }

/* ---------- 現像 ---------- */
.screen--develop { background: radial-gradient(circle at 50% 35%, #7c2f2b, #35171c 75%); color: #fff; gap: 14px; z-index: 20; }
.develop-title { font-size: 20px; font-weight: 900; }
.print { width: min(82vw, 340px); max-width: calc((100dvh - 260px) * 1.15); padding: 12px 12px 10px; background: #fffdf7; border: 3px solid var(--c-ink); border-radius: 5px; color: var(--c-ink); box-shadow: 0 10px 0 rgba(0,0,0,.3); transform: rotate(var(--tilt, -2deg)); }
.print img, .print canvas { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 2px solid var(--c-ink); background: #e9dcc6; }
.print__cap { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 8px 2px 0; font-size: 16px; font-weight: 800; }
.print__score { font: 900 26px/1 var(--font-num); color: var(--c-red-deep); white-space: nowrap; }
.print.is-developing { animation: drop .4s cubic-bezier(.2,1.4,.5,1) both; }
.print.is-developing img, .print.is-developing canvas { animation: develop 1.3s ease-out both; }
@keyframes drop { from { transform: translateY(-40px) rotate(9deg) scale(.9); opacity: 0; } }
@keyframes develop { from { filter: sepia(1) brightness(2.6) contrast(.2) blur(5px); } 55% { filter: sepia(.8) brightness(1.25) contrast(.7) blur(1px); } to { filter: none; } }
.dots { display: flex; gap: 8px; } .dots i { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #fff; } .dots i.is-on { background: var(--c-gold); }

/* ---------- 額装 ---------- */
.screen--best { background: repeating-linear-gradient(90deg, #efe0bd 0 40px, #f4e7c9 40px 80px); gap: 12px; z-index: 20; justify-content: safe center; }
.frame { position: relative; width: min(88vw, 370px); max-width: calc((100dvh - 330px) * 1.2); min-width: 200px; padding: 16px; border: 4px solid var(--c-ink); border-radius: 8px; background: linear-gradient(135deg, #ffe08a, #d99a2b 45%, #f7cf6b 60%, #b87b1c); box-shadow: inset 0 0 0 3px rgba(255,255,255,.45), 0 9px 0 var(--c-ink); animation: drop .5s cubic-bezier(.2,1.4,.5,1) both; }
.frame img, .frame canvas { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 8px solid #fffdf7; outline: 3px solid var(--c-ink); }
.ribbon { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-2deg); padding: 4px 16px; border: 3px solid var(--c-ink); border-radius: 8px; background: var(--c-red); color: #fff; font-weight: 900; font-size: 16px; white-space: nowrap; }
.nameplate { width: min(88vw, 350px); padding: 10px 16px 12px; border: 4px solid var(--c-ink); border-radius: var(--radius-m); background: var(--c-paper); text-align: center; animation: pop .35s .5s ease both; }
.nameplate small { font-size: 12px; font-weight: 800; color: var(--c-ink-sub); }
.nameplate__name { display: block; font-size: 30px; font-weight: 900; line-height: 1.2; }
.nameplate p { margin: 4px 0 0; font-size: 13.5px; font-weight: 600; line-height: 1.55; }
.nameplate .is-new, .badge-new { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--c-red); color: #fff; font-size: 12px; font-weight: 900; }

/* ---------- 結果 ---------- */
.screen--result { background: linear-gradient(#ffeec6, #f3dfb8); gap: 12px; z-index: 20; justify-content: safe center; touch-action: pan-y; }
.result-score { font: 900 clamp(46px, 15vw, 64px)/1 var(--font-num); color: var(--c-red); -webkit-text-stroke: 8px var(--c-ink); paint-order: stroke fill; }
.result-rank { padding: 6px 18px; border: 3px solid var(--c-ink); border-radius: 999px; background: var(--c-gold); font-size: 20px; font-weight: 900; }
.result-next { font-size: 14px; font-weight: 800; color: var(--c-red-deep); }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; width: min(100%, 370px); }
.thumb { padding: 3px; border: 2px solid var(--c-ink); background: #fff; font: 900 13px/1.4 var(--font-num); text-align: center; }
.thumb img, .thumb canvas { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.thumb:nth-child(odd) { transform: rotate(-2deg); } .thumb:nth-child(even) { transform: rotate(2deg); }
.actions { width: min(100%, 340px); display: grid; gap: 10px; }
.actions .row { flex-wrap: nowrap; } .actions .row .btn { flex: 1; padding-inline: 8px; }

/* ---------- 図鑑 ---------- */
.screen--zukan { justify-content: flex-start; background: #f4e7c9; gap: 12px; z-index: 20; touch-action: pan-y; }
.bar { width: min(100%, 420px); display: flex; align-items: center; gap: 12px; font-size: 21px; font-weight: 900; }
.bar span { margin-left: auto; font: 900 16px var(--font-num); }
.zukan { width: min(100%, 420px); display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-bottom: 16px; }
.zukan-cell { min-width: 0; padding: 6px; border: 3px solid var(--c-ink); border-radius: 14px; background: var(--c-paper); box-shadow: 0 4px 0 var(--c-ink); font-size: 14px; font-weight: 900; text-align: center; cursor: pointer; }
.zukan-cell img, .zukan-cell canvas { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 8px; background: #dceccb; margin-bottom: 4px; }
.zukan-cell.is-unknown { background: #e8dcc2; color: #8a7a66; }
.zukan-cell.is-rare { background: #ffeeb0; }
.zukan-cell small { display: block; font: 800 12px var(--font-num); color: var(--c-ink-sub); }

/* ---------- 横向き・トースト・低い画面 ---------- */
.rotate { position: fixed; inset: 0; z-index: 90; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #f3dfb8; font-size: 22px; font-weight: 900; text-align: center; }
.rotate::before { content: ""; width: 44px; height: 74px; border: 5px solid var(--c-ink); border-radius: 10px; background: var(--c-paper); animation: turn 1.8s ease-in-out infinite; }
@keyframes turn { 0%, 20% { transform: rotate(90deg); } 60%, 100% { transform: none; } }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) { .rotate { display: flex; } }
.toast { position: fixed; z-index: 80; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%); padding: 10px 18px; border-radius: 999px; background: var(--c-ink); color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap; opacity: 0; transition: opacity .2s; pointer-events: none; }
.toast.is-on { opacity: 1; }
@media (max-width: 374px) { .chip { padding: 3px 7px; font-size: 16px; } .hud { gap: 4px; } .hud .icon-btn { width: 38px; height: 38px; } }
@media (max-height: 700px) { .logo { margin-top: 12px; } .btn { min-height: 48px; font-size: 18px; padding-block: 8px; } .screen { padding-top: calc(10px + var(--safe-top)); } .time-card { min-height: 52px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } .flash.is-on { animation: none; } }

