/* 色は元のゲームと同じ：紺 #1B2A4A・橙 #F08A24・金 #FFC46B・青 #1F5FA8・生成り #FFF8EC */
:root { --navy:#1B2A4A; --panel:#2A3B63; --orange:#F08A24; --gold:#FFC46B; --blue:#1F5FA8; --cream:#FFF8EC; --sky:#F2F7FC; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--navy); color: var(--navy); font-family: 'Noto Sans JP', sans-serif; font-size: 16px; line-height: 1.6; overscroll-behavior: none; }
.px { font-family: 'DotGothic16', 'Noto Sans JP', monospace; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }

#app { height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); }
#head { background: var(--sky); padding: 8px max(12px, env(safe-area-inset-left)) 6px; border-bottom: 3px solid var(--navy); }
.head-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
#head h1 { font-size: 18px; }
.head-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.hbtn { min-height: 44px; padding: 6px 12px; background: #fff; border: 2px solid var(--navy); border-radius: 8px; box-shadow: 0 3px 0 var(--navy); font-size: 14px; }
.hbtn:active { transform: translateY(3px); box-shadow: none; }
.hbtn[aria-pressed="true"] { background: var(--gold); }
.counts { font-size: 13px; margin-top: 4px; }
.counts b { font-size: 16px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
#head :focus-visible, #win :focus-visible { outline-color: var(--blue); }

#stage-wrap { position: relative; min-height: 0; overflow: hidden; background: #3A2A1E; }
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; }
#pad { position: absolute; left: 10px; bottom: 10px; display: grid; grid-template-areas: ". u ." "l . r" ". d ."; gap: 2px; }
.pad-btn { width: 50px; height: 50px; background: rgba(255,255,255,.9); border: 2px solid var(--navy); border-radius: 10px; font-size: 20px; user-select: none; -webkit-user-select: none; touch-action: none; }
.pad-btn:active { background: var(--gold); }
#hop { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
#sound { position: absolute; right: 10px; top: 10px; display: flex; gap: 6px; }
#sound .hbtn { font-size: 13px; padding: 4px 9px; background: rgba(255,255,255,.92); }
#sound .hbtn[aria-pressed="true"] { background: var(--gold); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.date { font-size: .78em; white-space: nowrap; margin-left: .4em; }
#toasts { position: fixed; z-index: 20; top: 10px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: var(--navy); color: #fff; border: 3px solid var(--gold); border-radius: 10px; padding: 8px 16px; display: flex; flex-direction: column; align-items: center; animation: pop .3s ease-out; }
.toast strong { color: var(--gold); font-size: 18px; }

#panel { background: var(--panel); color: #fff; border-top: 4px solid var(--gold); padding: 10px max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom)); max-height: 46dvh; overflow-y: auto; }
.p-top { display: flex; gap: 10px; align-items: center; }
#p-tag { color: var(--gold); font-size: 13px; }
#p-title { font-size: 18px; line-height: 1.35; }
#p-who { font-size: 13px; opacity: .9; }
#p-desc { margin-top: 8px; min-height: 3.2em; }
#p-how { font-size: 13px; color: #E3ECF8; margin-top: 4px; }
#p-how:empty, #p-links:empty { display: none; }
#p-cmds { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cmd { min-height: 44px; padding: 6px 14px; background: transparent; color: #fff; border: 2px solid #fff; border-radius: 8px; font-size: 15px; }
.cmd.primary { background: var(--orange); color: var(--navy); border-color: var(--orange); }
.cmd:hover { filter: brightness(1.12); }
.links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.link { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 14px; background: #fff; color: var(--blue); border: 2px solid var(--gold); border-radius: 8px; font-weight: 700; text-decoration: underline; }
#win .link { border-color: var(--blue); }

.keeper { flex: 0 0 auto; background-image: url(../assets/keepers.png); background-repeat: no-repeat; background-size: 700% 200%; }
#p-face .keeper { background-color: var(--navy); border: 3px solid var(--gold); border-radius: 6px; }
.face-blank { width: 72px; height: 72px; display: grid; place-items: center; background: var(--navy); border: 3px solid var(--gold); border-radius: 6px; font-size: 32px; color: var(--gold); }

/* 窓（ミニゲーム・スタンプ帳など） */
#win { position: fixed; inset: 0; background: rgba(27,42,74,.72); display: flex; align-items: center; justify-content: center; padding: 12px; z-index: 10; }
#win[hidden] { display: none; }
.win-box { width: min(560px, 100%); max-height: calc(100dvh - 24px); display: flex; flex-direction: column; background: var(--cream); border: 4px solid var(--navy); border-radius: 12px; box-shadow: 0 6px 0 var(--navy); }
.win-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--blue); color: #fff; border-radius: 7px 7px 0 0; }
.win-bar h2 { font-size: 17px; }
.win-bar .hbtn { color: var(--navy); flex: 0 0 auto; white-space: nowrap; }
#win-body { padding: 14px; overflow-y: auto; }
#win-body h3 { font-size: 16px; margin: 14px 0 6px; }
.note { font-size: 13px; color: #44506B; margin-top: 8px; }

.game { position: relative; display: flex; flex-direction: column; gap: 10px; }
.game-head { display: flex; align-items: center; gap: 10px; }
.say { background: #fff; border: 2px solid var(--navy); border-radius: 8px; padding: 2px 10px; }
.game-icon { margin-left: auto; font-size: 30px; }
.game-big { font-size: 34px; text-align: center; min-height: 1.4em; }
.game-cmds { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.game-cmds.col { flex-direction: column; align-items: stretch; }
.gbtn { min-height: 48px; padding: 8px 16px; background: #fff; border: 2px solid var(--navy); border-radius: 8px; box-shadow: 0 4px 0 var(--navy); font-size: 16px; text-align: left; }
.gbtn.primary { background: var(--orange); }
.gbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }
.cells { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 300px; width: 100%; margin: 0 auto; }
.cell { aspect-ratio: 1; background: #B9D3EE; border: 2px solid var(--navy); border-radius: 10px; font-size: 34px; touch-action: none; }
.cell.on { background: #fff; border-width: 4px; }
.tbar { height: 12px; background: #D7DEEA; border: 2px solid var(--navy); border-radius: 6px; overflow: hidden; }
.tbar-in { height: 100%; background: var(--blue); }
.meter-row { display: flex; align-items: center; justify-content: center; gap: 20px; }
.meter { position: relative; width: 84px; height: 220px; background: #fff; border: 3px solid var(--navy); border-radius: 10px; overflow: hidden; }
.meter-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--blue); }
/* ねらう帯は、色ではなく「しま模様＋太い枠＋文字」で示す */
.meter-target { position: absolute; left: 0; right: 0; height: 18%; border-top: 3px solid var(--navy); border-bottom: 3px solid var(--navy); background: repeating-linear-gradient(45deg, rgba(27,42,74,.55) 0 5px, rgba(255,255,255,.75) 5px 10px); display: grid; place-items: center; }
.meter-target span { background: #fff; border: 2px solid var(--navy); border-radius: 4px; padding: 0 4px; font-size: 13px; line-height: 1.3; }
.cards { display: flex; justify-content: center; gap: 12px; }
.card { width: 84px; height: 116px; display: grid; place-items: center; background: var(--blue); color: #fff; border: 3px solid var(--navy); border-radius: 10px; font-size: 26px; }
.card.open { background: var(--gold); color: var(--navy); }
.card.off { background: #B8C6DA; }
.confs { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.conf { position: absolute; top: -30px; font-size: 22px; animation: fall 1.6s linear infinite; }

/* スタンプ帳・一覧 */
.rank-line { font-size: 18px; }
.stamps { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin-top: 10px; }
.stamp { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; background: #fff; border: 2px dashed #8A96AD; border-radius: 10px; font-size: 12px; }
.stamp .keeper { filter: grayscale(1) opacity(.35); }
.stamp.on { border: 3px solid var(--navy); background: #FFF1D6; }
.stamp.on .keeper { filter: none; }
.quests { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.quests li { display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid #8A96AD; border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.quests li.done { border: 3px solid var(--navy); background: #FFF1D6; }
.q-mark { flex: 0 0 64px; text-align: center; }
.info-box { background: #fff; border: 2px solid var(--navy); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px; }
.info-box h3 { margin-top: 0 !important; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.chip { display: flex; gap: 10px; align-items: center; text-align: left; min-height: 56px; padding: 6px 10px; background: #fff; border: 2px solid var(--navy); border-radius: 8px; font-size: 14px; line-height: 1.4; }
.chip-no { flex: 0 0 32px; height: 32px; display: grid; place-items: center; background: var(--gold); border: 2px solid var(--navy); border-radius: 50%; }
.chip-cat { font-size: 12px; color: #44506B; }

/* じっくり体験：公式LINEメニュー */
.phone { width: min(300px, 100%); margin: 0 auto; background: #fff; border: 4px solid var(--navy); border-radius: 18px; overflow: hidden; }
.phone-top { background: var(--navy); color: #fff; text-align: center; padding: 4px; font-size: 14px; }
.phone-talk { background: #C9DCF2; padding: 14px 10px; min-height: 70px; }
.talk-bubble { display: inline-block; background: #fff; border-radius: 12px; padding: 4px 10px; font-size: 13px; }
.rich { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; background: var(--navy); }
.rich-slot.big { grid-column: span 2; grid-row: span 2; font-size: 16px; }
.rich-slot { min-height: 52px; padding: 4px; background: #E7ECF4; color: #44506B; border: 2px dashed #8A96AD; border-radius: 4px; font-size: 13px; line-height: 1.3; }
.rich-slot.filled { background: var(--gold); color: var(--navy); border: 2px solid var(--navy); }
.hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; min-height: 52px; }
.hand-card { min-height: 48px; padding: 6px 12px; background: #fff; border: 2px solid var(--navy); border-radius: 8px; box-shadow: 0 4px 0 var(--navy); font-size: 15px; }
.hand-card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--navy); }

/* じっくり体験：撮影 */
.finder { position: relative; width: min(320px, 100%); aspect-ratio: 4 / 3; margin: 0 auto; background: #E9DCC6; border: 4px solid var(--navy); border-radius: 10px; overflow: hidden; }
.finder-grid { position: absolute; inset: 0; background: linear-gradient(90deg, transparent 33%, rgba(27,42,74,.35) 33% calc(33% + 1px), transparent calc(33% + 1px) 66.6%, rgba(27,42,74,.35) 66.6% calc(66.6% + 1px), transparent calc(66.6% + 1px)), linear-gradient(transparent 33%, rgba(27,42,74,.35) 33% calc(33% + 1px), transparent calc(33% + 1px) 66.6%, rgba(27,42,74,.35) 66.6% calc(66.6% + 1px), transparent calc(66.6% + 1px)); }
.finder-center { position: absolute; left: 50%; top: 50%; width: 30%; height: 44%; transform: translate(-50%, -50%); border: 3px dashed var(--navy); border-radius: 8px; }
.subj { position: absolute; top: 50%; left: 0; font-size: 56px; line-height: 1; transform: translate(-50%, -50%); }
.subj.ang0 { transform: translate(-50%, -50%) scale(1.15); }
.subj.ang1 { transform: translate(-50%, -50%) perspective(200px) rotateX(28deg); }
.subj.ang2 { transform: translate(-50%, -50%) scaleY(.92); }
.finder.flash { animation: flash .35s ease-out; }
.prints { display: flex; justify-content: center; gap: 8px; }
.print { background: #fff; border: 2px solid var(--navy); padding: 5px 5px 2px; text-align: center; font-size: 12px; box-shadow: 0 3px 0 var(--navy); }
.print-img { position: relative; width: 84px; aspect-ratio: 4 / 3; background: #E9DCC6; overflow: hidden; }
.print-img .subj { font-size: 30px; }

/* じっくり体験：AIへの指示 */
.prompt-out { background: #fff; border: 3px solid var(--navy); border-radius: 8px; padding: 10px 12px; font-weight: 700; user-select: text; -webkit-user-select: text; }
.parts { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 6px; font-size: 13px; }
.parts li { background: #fff; border: 2px dashed #8A96AD; border-radius: 8px; padding: 4px 8px; display: flex; flex-direction: column; }
.parts li.ok { border: 2px solid var(--navy); background: #FFF1D6; }
.parts li.now { border: 3px solid var(--blue); }
.part-key { font-size: 12px; color: #44506B; }
.copied { font-size: 13px; }

@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes fall { from { transform: translateY(0) rotate(0); } to { transform: translateY(300px) rotate(220deg); } }
@keyframes flash { 0% { filter: brightness(3); } 100% { filter: none; } }
.pop { animation: pop .3s ease-out; }
.bob { animation: bob 1.2s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .conf { display: none; } .pop, .bob, .toast, .finder.flash { animation: none !important; } }

/* 本物のカメラで撮る体験（全画面） */
#ar { position: fixed; inset: 0; z-index: 15; background: var(--navy); display: flex; align-items: center; justify-content: center; overflow-y: auto; }
#ar[hidden] { display: none; }
.ar-card { width: min(520px, 100%); max-height: 100%; overflow-y: auto; background: var(--cream); padding: 16px max(14px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; border-radius: 12px; }
.ar-card h2 { font-size: 20px; }
.ar-view { position: absolute; inset: 0; overflow: hidden; background: #000; touch-action: none; }
.ar-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ar-cup { position: absolute; touch-action: none; cursor: grab; filter: drop-shadow(0 2px 3px rgba(0,0,0,.18)); }
.ar-grid { position: absolute; inset: 0; pointer-events: none; background:
  linear-gradient(90deg, transparent calc(33.33% - 1px), rgba(255,255,255,.7) calc(33.33% - 1px) calc(33.33% + 1px), transparent calc(33.33% + 1px) calc(66.66% - 1px), rgba(255,255,255,.7) calc(66.66% - 1px) calc(66.66% + 1px), transparent calc(66.66% + 1px)),
  linear-gradient(transparent calc(33.33% - 1px), rgba(255,255,255,.7) calc(33.33% - 1px) calc(33.33% + 1px), transparent calc(33.33% + 1px) calc(66.66% - 1px), rgba(255,255,255,.7) calc(66.66% - 1px) calc(66.66% + 1px), transparent calc(66.66% + 1px)); }
.ar-grid[hidden] { display: none; }
.ar-top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ar-top .gbtn { min-height: 44px; padding: 4px 12px; font-size: 14px; box-shadow: 0 3px 0 var(--navy); }
.ar-chip { background: rgba(27,42,74,.85); color: #fff; border: 2px solid var(--gold); border-radius: 999px; padding: 4px 14px; font-size: 15px; }
.ar-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.ar-hint { color: #fff; font-size: 13px; text-align: center; text-shadow: 0 1px 3px #000; }
.ar-slide { display: flex; align-items: center; gap: 8px; width: min(320px, 100%); color: #fff; font-size: 13px; }
.ar-slide input { flex: 1; height: 30px; accent-color: var(--gold); }
.ar-slide:not(.show):first-of-type { display: none; } /* 角度のつまみは、傾きセンサーが無いときだけ出す */
.ar-shutter { width: 74px; height: 74px; border-radius: 50%; background: #fff; border: 5px solid var(--navy); box-shadow: 0 0 0 4px #fff; }
.ar-shutter:active { transform: scale(.92); background: var(--gold); }
.ar-photo { align-self: center; max-width: 100%; max-height: 46dvh; border: 4px solid #fff; box-shadow: 0 3px 0 var(--navy), 0 0 0 2px var(--navy); }
.ar-stars { font-size: 28px; text-align: center; }
.ar-angle { background: #fff; border: 2px solid var(--navy); border-radius: 8px; padding: 8px 12px; }
.ar-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ar-notes li { display: flex; flex-direction: column; background: #fff; border: 2px dashed #8A96AD; border-radius: 8px; padding: 6px 10px; font-size: 14px; }
.ar-notes li.ok { border: 2px solid var(--navy); background: #FFF1D6; }
.ar-mark { font-size: 13px; }

.ar-mv { width: 100%; height: min(38dvh, 320px); background: radial-gradient(#fff, #EADFCB); border: 3px solid var(--navy); border-radius: 12px; --poster-color: transparent; }
.ar-steps { margin: 0; padding-left: 1.4em; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.gbtn.ar-go { font-size: 19px; min-height: 56px; }
.gbtn:disabled { opacity: .45; box-shadow: none; }
label.gbtn { display: inline-flex; align-items: center; cursor: pointer; }
.ar-tapbox { position: relative; align-self: center; line-height: 0; cursor: crosshair; }
.ar-tapmark { position: absolute; width: 56px; height: 56px; margin: -28px 0 0 -28px; border: 4px solid #fff; border-radius: 50%; box-shadow: 0 0 0 3px var(--navy), inset 0 0 0 3px var(--navy); pointer-events: none; }
.ar-tapmark[hidden] { display: none; }

/* 算命学 */
.sm-date { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.sm-select { min-height: 48px; padding: 6px 10px; font-size: 17px; background: #fff; color: var(--navy); border: 2px solid var(--navy); border-radius: 8px; }
.sm-wheel, .sm-card { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--navy); color: #fff; border: 3px solid var(--gold); border-radius: 12px; padding: 14px; }
.sm-big { font-size: 72px; line-height: 1.1; }
.sm-sub { text-align: center; }
.sm-kan { font-size: 20px; }
.sm-kanji { font-size: 34px; color: var(--gold); margin-right: 2px; }
.sm-day { font-size: 13px; opacity: .9; }

/* スマホ・小さい画面 */
@media (max-width: 899px) {
  #head { padding-top: 6px; padding-bottom: 4px; }
  #head h1 { font-size: 15px; width: 100%; }
  .head-btns { width: 100%; flex-wrap: nowrap; }
  .head-btns .hbtn { flex: 1 1 0; padding: 4px 6px; font-size: 13px; box-shadow: 0 2px 0 var(--navy); }
  .counts { font-size: 12px; margin-top: 4px; white-space: nowrap; }
  .counts b { font-size: 14px; }
  .rank-wrap { display: none; } /* 称号はスタンプ帳と達成のお知らせで見せる */
  #panel { max-height: 46dvh; padding-top: 8px; }
  #p-face .keeper, .face-blank { width: 56px !important; height: 56px !important; }
  #p-title { font-size: 16px; }
  #p-desc { font-size: 15px; margin-top: 6px; min-height: 0; }
  #p-how { font-size: 12px; }
  /* ブース前のメニューでは、補足文を1行にたたんでコマンドを全部見せる */
  #panel.is-menu #p-how { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #p-cmds { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
  .cmd { padding: 4px 8px; font-size: 14px; }
  .pad-btn { width: 44px; height: 44px; background: rgba(255,255,255,.8); }
  #hop .hbtn { font-size: 12px; padding: 4px 8px; background: rgba(255,255,255,.9); }
  #sound .hbtn { font-size: 12px; padding: 4px 7px; }
}
/* 横に広い画面・スマホの横向き：マップを左、案内を右に */
@media (min-width: 900px) and (min-height: 520px), (orientation: landscape) and (min-width: 600px) {
  #app { grid-template-columns: minmax(0, 1fr) min(380px, 42vw); grid-template-rows: auto minmax(0, 1fr); }
  #head { grid-column: 1 / -1; }
  #panel { max-height: none; border-top: 0; border-left: 4px solid var(--gold); }
  #p-cmds { display: flex; }
}
@media (min-width: 900px) and (min-height: 520px) {
  #panel { padding: 16px; }
  #head h1 { font-size: 22px; }
}
/* スマホの横向きは高さが足りないので、見出しを1行に詰める */
@media (orientation: landscape) and (max-height: 519px) {
  #head h1 { width: auto; }
  .head-btns { width: auto; }
  .head-btns .hbtn { flex: 0 0 auto; }
  .head-row { flex-wrap: nowrap; }
  .counts { display: none; }
  .pad-btn { width: 40px; height: 40px; }
  #hop { flex-direction: row; }
}
