* { 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; }
}
