:root { font-family: system-ui, sans-serif; color: #17314a; --gold: #ffc438; --gold-deep: #c98a00;
  --gold-soft: #fff1bd; --tag-new: #ff5a4f; --star: #ffdc38; }
* { box-sizing: border-box; }
html, body, #app, #game { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { background: #9edcff; }
#game canvas { display: block; touch-action: none; }
#hud, #overlay { position: fixed; inset: 0; pointer-events: none; }
.instruction, .stars, .meter, .debug, .stopped { position: absolute; z-index: 2; }
.instruction { top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); }
.instruction-card { min-width: 136px; padding: 9px 17px; border: 3px solid #fff; border-radius: 18px;
  background: #fff9; }
.instruction-card span { display: block; white-space: nowrap; font-size: clamp(19px, 4vw, 34px);
  font-weight: 900; text-align: center; }
.stop-sign { color: #d92d35; }
.arrow { color: #1873d1; font-size: 1.25em; }
.stars { top: max(15px, env(safe-area-inset-top)); left: 16px; font-size: clamp(22px, 4vw, 32px); font-weight: 900; }
.meter { right: 16px; top: 22%; width: 25px; height: 45%; max-height: 380px; border: 3px solid #fff;
  border-radius: 20px; background: #18334a55; }
.meter-fill { position: absolute; bottom: 2px; left: 2px; width: calc(100% - 4px); border-radius: 15px;
  background: #ffd83d; }
.meter.glow { animation: meter-glow var(--meter-glow-ms) ease-out; }
.debug { right: 50px; bottom: 15px; padding: 7px; border-radius: 8px; background: #001a; color: #fff;
  font: 12px ui-monospace, monospace; }
.debug div { white-space: nowrap; }
.stopped { top: 43%; left: 50%; transform: translateX(-50%); color: #fff; font-size: 44px; font-weight: 900;
  text-shadow: 0 3px 0 #bd7a10, 0 0 14px #fff; z-index: 4; }
.panel { pointer-events: auto; position: absolute; inset: 0; display: grid; place-content: center; gap: 14px;
  padding: 24px; background: #eaf8ffdd; text-align: center; }
.panel-card { width: min(390px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow-y: auto;
  padding: 22px; border: 4px solid #fff; border-radius: 24px; background: #ffffffeb; }
.panel h1 { margin: 0 0 12px; font-size: clamp(25px, 6vw, 38px); }
.panel p { white-space: pre-line; font-weight: 700; line-height: 1.6; }
button { min-height: 45px; margin: 5px; padding: 8px 16px; border: 0; border-radius: 14px; background: #d8e9f6;
  color: #17314a; font: inherit; font-weight: 800; }
button.primary { background: #ffce48; }
.setting { margin: 13px 0; text-align: left; }
.setting h2 { margin: 0 0 6px; font-size: 17px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { flex: 1 1 96px; margin: 0; white-space: nowrap; }
.choices .selected { outline: 4px solid #2d91d7; background: #c8ebff; }
.camera-preview { width: min(320px, 78vw); aspect-ratio: 4 / 3; background: #243344; object-fit: cover; }
.camera-preview.mirror { transform: scaleX(-1); }
.flash { position: absolute; z-index: 3; inset: 0; background: #fff; opacity: 0; pointer-events: none;
  transition: opacity var(--flash-ms) ease-out; }
.star-burst { position: absolute; z-index: 4; top: 50%; left: 50%; width: 1px; height: 1px; pointer-events: none; }
.star-burst span { position: absolute; color: #ffdc38; font-size: 28px; font-weight: 900; opacity: 0;
  transform: rotate(var(--burst-angle)) translateY(0) rotate(calc(-1 * var(--burst-angle))); }
.star-burst.play span { animation: star-burst 700ms ease-out forwards; }
@keyframes star-burst {
  0% { opacity: 1;
    transform: rotate(var(--burst-angle)) translateY(0) rotate(calc(-1 * var(--burst-angle))) scale(.4); }
  100% { opacity: 0;
    transform: rotate(var(--burst-angle)) translateY(-100px) rotate(calc(-1 * var(--burst-angle))) scale(1.2); }
}
@keyframes meter-glow {
  0%, 45% { box-shadow: 0 0 0 5px #fff8, 0 0 25px 11px #ffd83d; }
  100% { box-shadow: none; }
}
@media (min-width: 700px) { .meter { right: 28px; } .stars { left: 28px; } }

/* 遊んでいる間もカメラを止めないための置き場（見せない） */
.camera-keep { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }
@media (max-height: 680px) {
  .panel { place-content: start center; overflow-y: auto; padding-block: 12px; }
  .panel-card { padding: 16px; }
  .setting { margin: 8px 0; }
  .panel h1 { margin-bottom: 7px; }
}

/* v2 演出: 紙吹雪・飛ぶ★・れんぞく・横切るものの名前 */
.confetti { position: absolute; inset: 0; z-index: 4; overflow: hidden; pointer-events: none; }
.confetti span { position: absolute; top: -24px; left: var(--x); width: 10px; height: 16px; opacity: 0;
  background: var(--color); animation: confetti-fall var(--confetti-ms) ease-in var(--delay) forwards; }
@keyframes confetti-fall {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  85% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--drift), 105vh) rotate(var(--spin)); }
}
.fly-star { position: fixed; z-index: 6; top: 0; left: 0; color: var(--star); font-size: 34px; font-weight: 900;
  text-shadow: 0 2px 0 #bd7a10; pointer-events: none; }
.stars { transform-origin: left center; }
.stars.bump { animation: star-bump var(--bump-ms) ease-out; }
@keyframes star-bump { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.6); } }
.combo-badge { position: absolute; z-index: 2; left: 16px; padding: 1px 11px; border: 2px solid var(--gold);
  border-radius: 12px; background: #fffc; color: #b36b00; font-size: clamp(15px, 3vw, 20px); font-weight: 900;
  top: calc(max(15px, env(safe-area-inset-top)) + 44px); }
@media (min-width: 700px) { .combo-badge { left: 28px; } }
.combo-big { position: absolute; z-index: 5; top: 24%; left: 50%; white-space: nowrap; color: var(--gold);
  font-size: clamp(38px, 9vw, 76px); font-weight: 900; transform: translateX(-50%);
  -webkit-text-stroke: 3px #fff; paint-order: stroke fill; text-shadow: 0 5px 0 #bd7a10, 0 0 18px #fff; }
.combo-big.play { animation: combo-big var(--combo-ms) ease-out forwards; }
@keyframes combo-big {
  0% { opacity: 0; transform: translateX(-50%) scale(.4); }
  18% { opacity: 1; transform: translateX(-50%) scale(1.25); }
  32% { transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateX(-50%) scale(1) translateY(-18px); }
}
.crosser-banner { position: absolute; z-index: 3; left: 50%; bottom: max(26px, env(safe-area-inset-bottom));
  /* left:50% のままだと幅が画面の半分に縮み、札が1文字ずつ折れる */
  width: max-content; max-width: calc(100vw - 32px); text-align: center; transform: translateX(-50%); }
.crosser-banner.play { animation: banner-in 260ms ease-out; }
@keyframes banner-in {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  100% { opacity: 1; transform: translateX(-50%) scale(1); }
}
.crosser-name { display: inline-block; padding: 7px 22px; border: 3px solid #fff; border-radius: 18px;
  background: #fffc; font-size: clamp(22px, 5vw, 36px); font-weight: 900; word-break: keep-all; }
.crosser-tags { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px; margin-top: 6px;
  white-space: nowrap;
  font-weight: 900; text-shadow: 0 0 6px #fff, 0 0 6px #fff; }
.crosser-tags:empty { display: none; }
.tag { display: inline-block; padding: 2px 11px; border-radius: 999px; color: #fff; background: var(--tag-new);
  font-size: 15px; font-weight: 900; line-height: 1.4; }
.tag-rare { color: #5b3a00; background: linear-gradient(var(--gold-soft), var(--gold) 55%, var(--gold-deep)); }

/* v2 クリア画面・図鑑 */
.panel .best-combo { margin: 4px 0; color: #b36b00; font-size: 21px; font-weight: 900; }
.section-title { margin: 8px 0 4px; font-size: 15px; }
.seen-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-bottom: 6px; }
.seen { position: relative; width: 74px; margin: 0; }
.seen-img { display: block; width: 100%; aspect-ratio: 4 / 3; border-radius: 10px; background: #cfeaf9;
  object-fit: contain; }
.seen .tag { position: absolute; top: -6px; right: -6px; padding: 0 6px; font-size: 11px; }
.no-icon { display: grid; place-items: center; font-size: 11px; font-weight: 800; }
.stamp-card { margin: 10px 0; padding: 8px 10px 10px; border: 3px dashed var(--gold-deep); border-radius: 16px;
  background: var(--gold-soft); }
.stamp-card h2 { margin: 0 0 6px; font-size: 15px; }
.stamp-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.stamp { display: grid; place-items: center; aspect-ratio: 1; border: 2px dashed #d3b86a; border-radius: 50%;
  background: #fff8; color: #d3b86a; font-size: 14px; font-weight: 800; }
.stamp.done { border: 3px solid var(--gold-deep); background: var(--gold); color: #fff; font-size: 24px;
  text-shadow: 0 1px 0 var(--gold-deep); }
.stamp.fresh { opacity: 0; animation: stamp-press var(--stamp-ms) cubic-bezier(.2, 1.4, .4, 1)
  var(--stamp-delay) forwards; }
@keyframes stamp-press {
  0% { opacity: 0; transform: translateY(-46px) scale(1.9) rotate(-14deg); }
  55% { opacity: 1; transform: translateY(0) scale(.88); }
  100% { opacity: 1; transform: none; }
}
.panel .card-done { margin: 8px 0 0; opacity: 0; color: #b36b00; font-size: 20px; font-weight: 900;
  animation: card-done 400ms ease-out calc(var(--stamp-delay) + var(--stamp-ms)) forwards; }
@keyframes card-done {
  0% { opacity: 0; transform: scale(.5); }
  70% { opacity: 1; transform: scale(1.2); }
  100% { opacity: 1; transform: scale(1); }
}
.zukan-layer { z-index: 10; padding: 12px; background: #eaf8ffee; }
.zukan-wrap { width: min(780px, calc(100vw - 24px)); padding: 14px; }
.zukan-wrap h1 small { margin-left: 8px; font-size: .55em; color: #4a6a85; }
.zukan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 4px; }
.zukan-item { padding: 5px; border: 3px solid #fff; border-radius: 14px; background: #e6f4fc;
  box-shadow: 0 0 0 2px #cfe3f1; }
.zukan-item.rare { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-deep), inset 0 0 12px var(--gold-soft); }
.zukan-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: contain; }
.zukan-item.unseen .zukan-img { filter: brightness(0); opacity: .3; }
.zukan-item h3 { display: grid; place-items: center; min-height: 2.5em; margin: 2px 0 0; font-size: 12px;
  line-height: 1.25; word-break: keep-all; overflow-wrap: anywhere; }
.zukan-item p { margin: 0; font-size: 12px; font-weight: 800; line-height: 1.3; color: #4a6a85; }
@media (min-width: 700px) {
  .zukan-grid { grid-template-columns: repeat(4, 1fr); gap: 12px; }
  .zukan-item h3 { font-size: 16px; }
  .zukan-item p { font-size: 15px; }
}
