* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; background: #0b0616; overflow: hidden; touch-action: manipulation;
  overscroll-behavior: none; -webkit-touch-callout: none;
  font-family: "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif; color: #fff; }
/* キーボード操作時のフォーカスを明示する */
:focus-visible { outline: 3px solid #00e0ff; outline-offset: 2px; border-radius: 6px; }
#app { position: relative; height: 100%; height: 100dvh; max-width: 480px; margin: 0 auto;
  background: #0b0616; }

/* ===== ステージ(動画)エリア: 全画面 ===== */
#stage { position: absolute; inset: 0; overflow: hidden; }
#stage video, #stage img.poster {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  transition: filter .3s, opacity .3s; }
.dimmed { filter: brightness(.45) saturate(.6); }
#stage.shake { animation: stageShake .5s ease-out; }
@keyframes stageShake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-9px) rotate(-.6deg); }
  40% { transform: translateX(8px) rotate(.5deg); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
/* おしゃれオーラ(装備Styleに応じてstartBattleでshadow強度を設定) */
#aura { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
/* フィーバー(ダンス技発動中) */
#stage.fever #aura { animation: feverPulse .8s ease-in-out infinite alternate;
  box-shadow: inset 0 0 70px rgba(255,224,102,.65) !important; }
@keyframes feverPulse { from { opacity: .55; } to { opacity: 1; } }
#feverBanner { position: absolute; top: 22%; left: 50%; transform: translateX(-50%);
  font-size: 22px; font-weight: 900; color: #ffe066; letter-spacing: .08em;
  text-shadow: 0 0 16px rgba(255,224,102,.9); opacity: 0; pointer-events: none;
  white-space: nowrap; }
#feverBanner.on { animation: feverIn 1.2s ease-out; }
@keyframes feverIn { 0% {opacity:0; transform:translateX(-50%) scale(1.6);}
  20% {opacity:1;} 80% {opacity:1;} 100% {opacity:0;} }

#turnBanner { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  padding: 6px 18px; border-radius: 999px; font-weight: 800; font-size: 15px;
  background: rgba(255,45,150,.85); box-shadow: 0 0 14px rgba(255,45,150,.8);
  letter-spacing: .1em; white-space: nowrap; pointer-events: none; }
#turnBanner.cpu { background: rgba(0,170,255,.85); box-shadow: 0 0 14px rgba(0,170,255,.8); }
#scores { position: absolute; top: calc(44px + env(safe-area-inset-top, 0px)); left: 0; right: 0;
  display: flex; justify-content: space-between; padding: 0 12px; font-size: 13px;
  pointer-events: none; }
.scoreBox { background: rgba(0,0,0,.5); border-radius: 10px; padding: 5px 10px; min-width: 108px; }
.scoreBox .name { font-size: 10px; opacity: .8; }
.scoreBox .val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.scoreBox .gear { font-size: 10px; letter-spacing: .1em; min-height: 13px; }
#p1Box { border: 1px solid #ff2d96; } #cpuBox { border: 1px solid #00aaff; text-align: right; }
#judge { position: absolute; bottom: 21%; left: 50%; transform: translateX(-50%);
  font-size: 30px; font-weight: 900; letter-spacing: .06em; opacity: 0;
  text-shadow: 0 0 12px currentColor; pointer-events: none; }
#judge.pop { animation: judgePop .45s ease-out; }
@keyframes judgePop { 0% {opacity:0; transform:translateX(-50%) scale(.6);}
  25% {opacity:1; transform:translateX(-50%) scale(1.15);} 70% {opacity:1;}
  100% {opacity:0; transform:translateX(-50%) scale(1);} }
#combo { position: absolute; bottom: 27%; left: 50%; transform: translateX(-50%);
  font-size: 16px; font-weight: 800; color: #ffe066; text-shadow: 0 0 10px rgba(255,224,102,.8);
  pointer-events: none; }

/* ===== ノーツレーン(動画に重ねる全画面オーバーレイ、画面自体がタップパッド) ===== */
#laneWrap { position: absolute; inset: 0; z-index: 3; }
canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#hud { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#missFlash { position: absolute; inset: 0; opacity: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, rgba(255,32,56,0) 35%, rgba(255,32,56,.5) 100%); }
#missFlash.on { animation: missFlash .5s ease-out; }
@keyframes missFlash { 0% { opacity: 1; } 100% { opacity: 0; } }
#judge.miss { font-size: 46px; }
#countdown { position: absolute; top: 38%; left: 50%; transform: translate(-50%,-50%);
  font-size: 96px; font-weight: 900; color: #fff; opacity: 0; pointer-events: none;
  text-shadow: 0 0 26px rgba(255,45,150,.95), 0 0 60px rgba(0,224,255,.6); }
#countdown.pop { animation: countPop .42s ease-out forwards; }
@keyframes countPop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(1.7); }
  30% { opacity: 1; }
  100% { opacity: .92; transform: translate(-50%,-50%) scale(1); }
}

/* ===== オーバーレイ(メニュー各種) ===== */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; gap: 12px; text-align: center;
  background: rgba(8,4,18,.9); backdrop-filter: blur(4px); overflow-y: auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px
           calc(18px + env(safe-area-inset-bottom, 0px)); }
/* 安全な中央寄せ: 収まる時は中央、あふれる時は上からスクロール
   (justify-content:centerだと上端がスクロール不能領域に切れるため使わない) */
.overlay > :first-child { margin-top: auto; }
.overlay > :last-child { margin-bottom: auto; }
.overlay h1 { font-size: 24px; line-height: 1.4; flex-shrink: 0;
  background: linear-gradient(90deg,#ff2d96,#ffe066,#00e0ff);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.overlay h2 { font-size: 18px; letter-spacing: .1em; flex-shrink: 0; }
.overlay p { font-size: 12px; opacity: .85; line-height: 1.7; }
.selLabel { font-size: 11px; letter-spacing: .2em; opacity: .7; margin-top: 2px; }
.selRow { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.selBtn { padding: 9px 14px; font-size: 13px; font-weight: 800; color: #fff;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.25);
  border-radius: 12px; cursor: pointer; letter-spacing: .05em; min-height: 44px; }
.selBtn.sel { border-color: #ffe066; background: rgba(255,224,102,.18);
  box-shadow: 0 0 12px rgba(255,224,102,.5); }
.selBtn.lock { opacity: .35; pointer-events: none; }
.btn { padding: 13px 40px; font-size: 17px; font-weight: 800; color: #fff;
  background: linear-gradient(90deg,#ff2d96,#b84dff); border: none; border-radius: 999px;
  box-shadow: 0 0 18px rgba(255,45,150,.6); cursor: pointer; margin-top: 4px; }
.btn:active { transform: scale(.96); }
.btnSub { padding: 9px 22px; font-size: 13px; font-weight: 800; color: #fff;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px; cursor: pointer; min-height: 44px; }
.statusLine { font-size: 13px; font-weight: 800; color: #ffe066; }
.creditLine { font-size: 10px !important; opacity: .6 !important; line-height: 1.8; }
.legalLink { color: #5ad1ff; font-weight: 700; text-decoration: underline;
  display: inline-block; padding: 6px 4px; }
#vsInfo { font-size: 13px; font-weight: 800; color: #ffe066; min-height: 18px; }

/* ステージカード */
.stageCard { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 340px;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.2);
  border-radius: 14px; padding: 8px 12px; cursor: pointer; text-align: left; color: #fff; }
.stageCard img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; }
.stageCard .sc-main { flex: 1; }
.stageCard .sc-title { font-size: 14px; font-weight: 800; }
.stageCard .sc-sub { font-size: 11px; opacity: .8; }
.stageCard .sc-state { font-size: 18px; }
.stageCard.cleared { border-color: #8dff70; }
.stageCard.locked { opacity: .4; pointer-events: none; }

/* ショップ */
#shopList { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 6px; }
.shopSlotHead { font-size: 11px; letter-spacing: .2em; opacity: .7; margin-top: 6px; text-align: left; }
.itemRow { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.18); border-radius: 10px; padding: 6px 10px;
  font-size: 12px; cursor: pointer; color: #fff; text-align: left; min-height: 44px; }
.itemRow .it-emoji { font-size: 18px; }
.itemRow .it-name { flex: 1; font-weight: 700; }
.itemRow .it-meta { font-size: 11px; opacity: .85; text-align: right; }
.itemRow.equipped { border-color: #ffe066; background: rgba(255,224,102,.15); }
.itemRow.cantBuy { opacity: .45; }

/* ===== 設定画面 ===== */
.settingBox { width: 100%; max-width: 340px; background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18); border-radius: 14px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; }
.settingHead { font-size: 12px; font-weight: 800; letter-spacing: .15em; opacity: .8;
  text-align: left; }
.settingRow { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 13px; }
.settingRow label { font-weight: 700; white-space: nowrap; }
.settingRow input[type="range"] { flex: 1; min-width: 120px; accent-color: #ff2d96; height: 28px; }
.settingRow input[type="checkbox"] { width: 22px; height: 22px; accent-color: #ff2d96; }
.settingNote { font-size: 11px; opacity: .7; line-height: 1.6; text-align: left; }
.btnSub.danger { border-color: rgba(255,32,56,.7); color: #ff9aa8; }

/* キャリブレーション */
#calibratePad { width: 200px; height: 200px; border-radius: 50%; cursor: pointer;
  border: 4px solid #ff2d96; display: flex; align-items: center; justify-content: center;
  font-size: 28px; font-weight: 900; letter-spacing: .1em; color: #ff2d96;
  background: rgba(255,45,150,.12); user-select: none; -webkit-user-select: none; }
#calibratePad.beat { animation: calibBeat .18s ease-out; }
@keyframes calibBeat { 0% { box-shadow: 0 0 0 0 rgba(255,45,150,.9); transform: scale(1.06); }
  100% { box-shadow: 0 0 0 26px rgba(255,45,150,0); transform: scale(1); } }

/* 一時停止ボタン(バトル中のみ表示。HUDはpointer-events:noneなので個別に有効化) */
#pauseBtn { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); left: 10px;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,.4);
  background: rgba(0,0,0,.5); color: #fff; font-size: 18px; cursor: pointer;
  pointer-events: auto; z-index: 6; }

/* ローディング */
#loadingList { display: flex; flex-direction: column; gap: 8px; min-width: 220px; }
.loadRow { font-size: 14px; font-weight: 700; text-align: left; }
.loadRow .loadIcon { display: inline-block; width: 22px; }

/* 通知トースト */
#toast { position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%);
  z-index: 30; background: rgba(8,4,18,.92); border: 1px solid rgba(255,224,102,.6);
  color: #ffe066; font-size: 13px; font-weight: 700; border-radius: 999px;
  padding: 10px 20px; opacity: 0; pointer-events: none; transition: opacity .3s;
  max-width: 86%; text-align: center; }
#toast.on { opacity: 1; }

#resultOverlay { display: none; }
#resultTitle { font-size: 38px; font-weight: 900; }
.coin { color: #ffe066; font-weight: 900; font-size: 18px; line-height: 1.6; }
.hidden { display: none !important; }

/* ===== 横画面の案内(縦画面専用) ===== */
#rotateHint { display: none; position: fixed; inset: 0; z-index: 50;
  background: rgba(8,4,18,.96); color: #fff; font-size: 18px; font-weight: 800;
  align-items: center; justify-content: center; text-align: center; padding: 24px; }
@media (orientation: landscape) and (max-height: 520px) {
  #rotateHint { display: flex; }
}

/* ===== 視差・点滅を抑える設定の尊重 ===== */
@media (prefers-reduced-motion: reduce) {
  #stage.shake, #stage.fever #aura, #missFlash.on, #feverBanner.on, #calibratePad.beat {
    animation: none !important; }
  #judge.pop, #countdown.pop { animation: none !important; opacity: 1; }
  #stage video, #stage img.poster { transition: none; }
}

/* ===== オープニングムービー ===== */
#opOverlay { position: absolute; inset: 0; z-index: 40; background: #000; }
#opVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#opStart { position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; cursor: pointer;
  background: radial-gradient(ellipse at 50% 38%, #2a1a4a 0%, #0a0618 70%); }
#opStart h1 { font-size: 26px; font-weight: 900; letter-spacing: .06em;
  background: linear-gradient(90deg, #ff4d88, #ffe066);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
#opStartHint { font-size: 15px; font-weight: 800; color: #ffe066;
  animation: opPulse 1.2s ease-in-out infinite; }
@keyframes opPulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
#opSkipHint { position: absolute; right: 14px; font-size: 11px; font-weight: 700;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  color: rgba(255,255,255,.75); background: rgba(0,0,0,.45);
  border-radius: 999px; padding: 6px 12px; pointer-events: none; }

/* ===== チュートリアル(遊び方) ===== */
#tutorialOverlay { position: absolute; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(4,2,12,.88); }
#tutorialCard { width: 100%; max-width: 340px; background: #140b28;
  border: 1px solid rgba(255,224,102,.35); border-radius: 16px;
  padding: 20px 18px calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 14px; }
#tutorialBody { min-height: 240px; display: flex; flex-direction: column;
  gap: 10px; justify-content: flex-start; }
#tutorialBody h2 { font-size: 17px; letter-spacing: .06em; color: #ffe066; }
#tutorialBody p { font-size: 13px; line-height: 1.8; opacity: .92; }
#tutorialBody .tutLanes { display: flex; gap: 8px; justify-content: center; }
#tutorialBody .tutLane { width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; border: 2px solid currentColor; }
#tutorialBody .tutBig { font-size: 26px; text-align: center; }
#tutorialDots { display: flex; gap: 6px; justify-content: center; }
#tutorialDots span { width: 8px; height: 8px; border-radius: 50%;
  background: rgba(255,255,255,.25); }
#tutorialDots span.on { background: #ffe066; }
#tutorialOverlay .selRow { display: flex; gap: 10px; justify-content: center; }

/* ===== ブランドフォント(OPと同じDela Gothic One + Anton / OFLライセンス) ===== */
@font-face {
  font-family: 'Dela Gothic One';
  src: url('../fonts/DelaGothicOne-sub.ttf') format('truetype');
  font-display: swap;
}
@font-face {
  font-family: 'Anton';
  src: url('../fonts/Anton-Regular.ttf') format('truetype');
  font-display: swap;
}
:root { --font-display: 'Dela Gothic One', 'Segoe UI', 'Hiragino Sans', sans-serif;
        --font-latin: 'Anton', 'Dela Gothic One', sans-serif; }

/* 見出し・ボタン・バナー類をブランドフォントへ */
.overlay h1, .overlay h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: .04em; }
.overlay h1 { background: linear-gradient(90deg, #ff4d88 0%, #ffe066 55%, #29e6ff 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.btn, .btnSub { font-family: var(--font-display); font-weight: 400; }
.btn { font-size: 15px; letter-spacing: .06em; }
.btnSub { font-size: 12px; }
#turnBanner, #resultTitle { font-family: var(--font-display); font-weight: 400; }
#judge, #countdown, #combo, #feverBanner { font-family: var(--font-latin); font-weight: 400; letter-spacing: .05em; }
.selBtn { font-family: var(--font-display); font-weight: 400; font-size: 11px; }
.stageCard .sc-title { font-family: var(--font-display); font-weight: 400; }

/* モード選択の2大ボタンは同じ幅に揃える */
#modeOverlay .btn { width: min(270px, 82%); text-align: center; padding: 14px 10px; }

/* ===== チュートリアル新デザイン(キャラ背景+タイポグラフィ) ===== */
#tutorialCard { background-size: cover; background-position: center 22%;
  border-color: rgba(255,255,255,.22); box-shadow: 0 8px 40px rgba(0,0,0,.6); }
#tutorialBody h2 { font-family: var(--font-display); font-weight: 400; font-size: 19px;
  color: #ffe066; text-shadow: 0 2px 12px rgba(0,0,0,.8); }
#tutorialBody p { text-shadow: 0 1px 6px rgba(0,0,0,.9); font-weight: 600; }
.tutLogo { font-family: var(--font-display); font-size: 34px; line-height: 1.25; text-align: center;
  background: linear-gradient(160deg, #ff4d88 0%, #ffe066 60%, #29e6ff 110%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 10px rgba(0,0,0,.7)); margin: 6px 0 4px; }
.tutJudge { font-family: var(--font-latin); font-size: 46px; text-align: center; color: #ffe066;
  text-shadow: 0 0 22px rgba(255,224,102,.75), 0 3px 8px rgba(0,0,0,.8); letter-spacing: .06em; }
.tutJudgeSub { display: flex; gap: 14px; justify-content: center; font-family: var(--font-latin);
  font-size: 19px; letter-spacing: .08em; }
.tutJudgeSub .jGood { color: #5ad1ff; text-shadow: 0 0 12px rgba(90,209,255,.6); }
.tutJudgeSub .jMiss { color: #8899bb; }
.tutTurn { display: flex; gap: 12px; justify-content: center; align-items: baseline;
  font-family: var(--font-latin); font-size: 38px; color: #fff;
  text-shadow: 0 0 18px rgba(90,209,255,.55), 0 3px 8px rgba(0,0,0,.8); }
.tutTurn .tutVs { font-size: 20px; color: #ff5470; text-shadow: 0 0 14px rgba(255,84,112,.7); }
.tutGrow { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap;
  font-family: var(--font-display); font-size: 15px; color: #ffe066;
  text-shadow: 0 2px 8px rgba(0,0,0,.85); }
.tutGrow .tutArrow { color: #ff5470; font-size: 12px; }
#tutorialBody .tutLane { width: 52px; height: 52px; font-size: 24px;
  background: rgba(8,4,18,.55); }
