/* ======================================================= */
/* 🔑 1. ベーススタイル (重複を解消し、一つに統合) */
/* ======================================================= */
:root {
    --neon-shadow: rgb(255, 255, 255); /* レーン用の共通変数 */
}

/* ① 横はみ出し完全防止 */
html, body {
    width: 100%;
    max-width: 100vw;
    height: 100%;
    margin: 0;
    overflow-x: hidden;
}

/* ② 背景を画面に完全フィット */
.fullscreen-bg {
    width: 100%;
    max-width: 100vw;
    min-height: 100dvh;
    background: center / cover no-repeat #111;
    overflow: hidden;
}

/* ③ boxモデル安定化 */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    background: url('background1.png') center / cover no-repeat;
    min-height: 100dvh;
    overflow: hidden;
}

/* ======================================================= */
/* 🔑 2. 横向き/縦向き 警告の共通スタイル */
/* ======================================================= */

#orientation-alert {
    display: none; /* デフォルトで非表示 */
    position: fixed !important; 
    top: 0 !important; left: 0 !important;
    width: 100% !important; 
    height: 100% !important;
    background-color: #000 !important;
    color: #fff !important;
    font-size: 1.5em !important;
    z-index: 9999 !important; /* 最前面に表示 */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* ======================================================= */
/* 🔑 3. 画面向き制御のコアロジック (縦向きを許可する修正版) */
/* ======================================================= */

/* 縦向きの警告要素は常に非表示にする (縦向きプレイを許可) */
#orientation-alert {
    display: none !important;
}

/* 🟢 ゲーム画面は常に表示する (縦・横・PCすべてで表示) */
/* JSでリサイズされる親要素。子要素のabsolute配置の基準点となる。 */
@media screen {
    #game-container {
        /* ゲーム画面を強制的に表示 */
        display: block !important; 
        position: relative; /* 💡 重要な修正：UI要素の基準点となる */
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
}

/* ======================================================= */
/* UI/画面のスタイル */
/* ======================================================= */

/* ★★★ main-menu: 画面横幅いっぱいで中央配置 ★★★ */
#main-menu {
    position: fixed; 
    width: 100%;
    left: 0;
    top: 50%; 
    transform: translateY(-50%); 
    z-index: 500;
}

#main-menu > ul,
#main-menu > ol {
    width: 100%;
    padding: 0;
    margin: 0;
    text-align: center;
}

/* ★★★ screen-song-select: 画面横幅いっぱいで中央配置 ★★★ */
#screen-song-select {
    position: fixed; 
    width: 100%;
    left: 0;
    top: 50%; 
    transform: translateY(-50%); 
    z-index: 500;
}

#screen-song-select > ul,
#screen-song-select > ol {
    width: 100%;
    padding: 0;
    margin: 0;
    text-align: center;
}

#screen-song-select li {
    text-align: center;
}

.game-screen {
    padding: 20px;
    border: 1px solid #333;
    margin-top: 10px;
    background-color: #1a1a1a;
    color: #fff;
}

/* ★★★ 判定文字のCSS ★★★ */
#judgment-display-container {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    width: 100%;
    text-align: center;
    z-index: 50;
}

.judgment-text {
    font-size: 50px;
    font-weight: 900;
    position: absolute;
    width: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    transform: scale(0.5);
    animation: judgmentPop 0.8s ease-out forwards;
}
    
/* 判定ごとのネオンカラー */
.judgment-Perfect { color: #ffeb3b; text-shadow: 0 0 15px #ffeb3b, 0 0 5px #000; }
.judgment-Good { color: #00ffff; text-shadow: 0 0 15px #00ffff, 0 0 5px #000; }
.judgment-Miss { color: #ff0077; text-shadow: 0 0 15px #ff0077, 0 0 5px #000; }

@keyframes judgmentPop {
    0% { opacity: 0; transform: scale(0.5) translateY(20px); }
    20% { opacity: 1; transform: scale(1.1) translateY(0); }
    80% { opacity: 1; transform: scale(1.0) translateY(-10px); }
    100% { opacity: 0; transform: scale(1.0) translateY(-20px); }
}

/* ★★★ プレイ画面のネオンCSS ★★★ */
#screen-play {
    width: 100%;
    min-height: 100vh;
    height: auto;
    
    background-image: url('background2.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    background-color: #111;

    margin: 0;
    display: flex; 
    flex-direction: column; 
    justify-content: center;
    align-items: center;
    color: #fff;
    overflow: hidden;
    transform-style: preserve-3d;
    z-index: 1; 
}

/* ノーツの通り道（奥行きタイプ） */
#note-path-container {
    display: flex;
    justify-content: center;
    perspective: 800px;
    height: 50vh;
    margin-top: 50px;
    perspective-origin: center bottom;
}

.note-lane {
    width: 80px;
    height: 100%;
    margin: 0 5px;
    border-left: 1px solid rgba(255, 157, 0);
    border-right: 1px solid rgb(255, 157, 0);

    transform: rotateX(45deg);
    transform-origin: bottom;
    position: relative;
    transform-style: preserve-3d;

    box-shadow: 
    inset 0 0 5px var(--neon-shadow),
    0 0 10px var(--neon-shadow),
    0 0 20px var(--neon-shadow),
    0 0 40px rgba(0, 224, 255, 0.5);
}

/* ３つのデザインボタン */
#hit-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
}
.design-button {
    width: 80px;
    height: 80px;
    font-size: 30px;
    border-radius: 50%;
    background: #ff8c00;
    border: 3px solid #ffffff;
    box-shadow: 0 0 10px #ff8c00;
    cursor: pointer;
}
/* ノーツの動き */
.note {
    
  position: absolute;
  left: 0;
  right: 0;
  margin: 0 auto;
  border-radius: 5px;
  z-index: 10;
  /* top: 0; ← 削除 */
    
    transform:
    scale(calc(0.1 + var(--progress) * 0.80))
    translateY(calc(var(--progress) * var(--note-distance)));
    
    transform-origin: center bottom;
}

:root {
  --note-distance: 500px;
}

/* タップノーツの見た目 */
.note-tap {
    width: 70px;
    height: 15px;
    background: #ffaa00;
    border: 2px solid #fff;
    box-shadow: 0 0 8px #ffaa00;
}
/* 判定ライン */
.note-lane::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: -5px;
    right: -5px;
    height: 22.5px;
    
    background-color: #39ff14;
    
    box-shadow: 
        0 0 5px rgba(255, 255, 255, 0.8), 
        0 0 15px #406f38, 
        0 0 30px #406f38, 
        0 0 50px rgba(57, 255, 20, 0.6);
        
    z-index: 20;
}

/* その他の汎用スタイル */
.song-item {
    padding: 10px;
    margin: 5px 0;
    background: #222;
    cursor: pointer;
    list-style: none;
    border-radius: 5px;
    transition: background 0.2s;
}
.song-item:hover {
    background: #333;
}
#play-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
#popup-content {
    background: #222;
    color: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 20px #0ff;
    width: 80%;
    max-width: 400px;
    text-align: center;
}
#play-popup button {
    padding: 10px 20px;
    margin: 5px;
    cursor: pointer;
}

/* 🔑 修正箇所: スコア、コンボ、ライフバーをabsoluteに変更し、#game-containerを基準にする */
/* ライフバーの親コンテナ */
#life-bar-container {
    width: 200px;
    position: absolute; /* 💡 fixed -> absoluteに変更 */
    top: 20px; 
    left: 0; right: 0; 
    margin: 0 auto; 
    z-index: 1000; 
}

/* ライフポイントバー（変更なし） */
#life-point { 
    width: 100%; 
    height: 20px;
    position: static;
    transform: none;
    margin: 0;
}

/* コンボ数表示 */
#combo-counter {
    position: absolute; /* 💡 fixed -> absoluteに変更 */
    top: 20px;
    right: 50px;
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 5px 15px;
    border-radius: 8px;
    z-index: 1000;
    color: #ff00ae; 
    text-shadow: 
        0 0 5px #ff00b3,
        0 0 10px #ff00b3,
        0 0 20px #ff00b3,
        0 0 40px #ff00b3;
    font-size: 20px;
    font-weight: 800;
}

#score-display {
    position: absolute; /* 💡 fixed -> absoluteに変更 */
    top: 20px;
    left: 20px;
    color: #fffb00;
    text-shadow: 
        0 0 5px #fffb00,
        0 0 10px #fffb00,
        0 0 20px #ff9900,
        0 0 40px #ff9900; 
    font-weight: 800; 
    z-index: 1010;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 5px 15px;
    border-radius: 8px;
}
/* 🔑 修正ここまで */


/* ステータスバー（変更なし） */
#status-bar { 
    padding: 10px 0; 
}

/* プレイコントロール（変更なし） */
#play-controls { 
    text-align: center; 
    margin-top: 30px; 
}

/* 難易度ボタンのCSS */
#difficulty-selection {
    margin: 20px 0;
}
.difficulty-btn {
    padding: 10px 15px;
    margin: 0 5px;
    cursor: pointer;
    font-size: 14px;
    border: 2px solid #333;
    background: #1a1a1a;
    color: #fff;
    border-radius: 5px;
    transition: all 0.2s;
}

/* 選択されたボタンの可視化 */
.difficulty-btn.selected {
    border: 2px solid #ffeb3b;
    background: #444;
    color: #ffeb3b;
    box-shadow: 0 0 10px rgba(255, 235, 59, 0.5);
    font-weight: bold;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.overlay.is-active {
  display: flex;
}

/* 一時停止画面のCSS */
#pause-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

#pause-content {
    background: #333;
    padding: 40px 60px;
    border-radius: 10px;
    box-shadow: 0 0 30px #ffeb3b;
    color: #fff;
    text-align: center;
}

#pause-content h2 {
    font-size: 40px;
    color: #ffeb3b;
    margin-bottom: 20px;
}

#pause-content button {
    padding: 10px 20px;
    margin: 10px;
    cursor: pointer;
    font-size: 16px;
    border-radius: 5px;
    border: none;
}

#resume-button {
    background-color: #ddd;
    color: #000;
}

#quit-button {
    background-color: #ffaa44;
    color: #fff;
}

/* タイトル画面、結果ポップアップ、ガイド、プレイヤー名ポップアップなどのスタイルはそのまま維持 */

.corner-image {
    position: absolute;
    bottom: 0;
    width: 100px;
    height: auto;
}

.left {
    left: 0;
}

.right {
    right: 0;
}

#result-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
#result-content {
    background: #222;
    color: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 0 30px #0ff;
    width: 80%;
    max-width: 500px;
    text-align: center;
}
#result-score {
    font-size: 36px;
    color: #ffeb3b;
    margin: 15px 0;
}
#result-popup button {
    padding: 10px 20px;
    margin-top: 20px;
    cursor: pointer;
}

/* 操作の確認ボタン */
#guide-button {
    position: absolute; /* 💡 fixed -> absoluteに変更 */
    top: 20px;
    right: 20px;
    z-index: 1000;
    padding: 8px 15px;
    font-size: 14px;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* ガイドポップアップ */
#guide-popup {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1100;
}

#guide-content {
    position: absolute;
    top: 30px;
    right: 30px;
    background: #fff;
    color: #000;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 0 40px rgba(255, 255, 255, 0.8);
    width: 90%;
    max-width: 380px;
    text-align: left;
    overflow-y: auto;
    max-height: 90vh;
}
#guide-content h3 {
    color: #2b00ff;
    text-align: center;
}
#guide-content hr {
    border-color: #ddd;
    margin: 15px 0;
}
#guide-content button {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 20px;
    background: #ff8c00;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

#player-name-popup {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#player-name-content {
    background: #222;
    color: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 0 30px #0ff;
    width: 80%;
    max-width: 400px;
    text-align: center;
}

/* 操作ボタンの視覚化CSS */
#control-guide {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    gap: 10px;
}
.lane-button-visual {
    flex-grow: 1;
    text-align: center;
    padding: 15px 5px;
    background-color: #ffaa44;
    color: white;
    font-weight: bold;
    border-radius: 8px;
    box-shadow: 0 4px #cc8833;
    cursor: default;
    line-height: 1.4;
    font-size: 14px;
}

/* キーボード説明の枠のスタイル */
.key-description {
    margin-top: 10px;
    padding: 10px;
    border: 1px solid #ddd;
    border-left: 5px solid #ff8c00;
    border-radius: 4px;
    background-color: #f9f9f9;
}
.key-description ul {
    list-style-type: none;
    padding-left: 0;
    margin: 5px 0 0 0;
}
.key-description ul li {
    margin-bottom: 5px;
}

/* index.html の <style> ブロックに追加 */

/* レーンボタンのベーススタイル (仮定) */
.lane-button {
    /* (元のボタンデザインのCSSをここに記述) */
    background-color: #ff8c00; /* 例 */
    box-shadow: 0 0 50px #ff8c00; /* 例 */
    transition: background-color 0.05s, box-shadow 0.05s; /* フィードバックをスムーズにする */
}

/* ★★★ キーが押されたときのフィードバック ★★★ */
.lane-button.hit-feedback {
    background-color: #fff !important; /* 強調色 */
    box-shadow: 0 0 20px #fff !important; /* 強調のシャドウ */
}

/* プレイ画面が relative であることを確認 */
#screen-play {
  position: relative;
}

/* wrapper は JS で生成されるのでここは基本なし */

/* twinkle の基本アニメーション */
.twinkle-effect {
  display: inline-block;
  transform-origin: center;
  opacity: 0;
  font-size: 22px; /* テンプレート無し用の fallback サイズ */
}

/* 再生用クラス */
.twinkle-effect.twinkle-play {
  animation-name: twinkle-pop, twinkle-fade;
  animation-timing-function: cubic-bezier(.2,.8,.2,1);
  animation-fill-mode: forwards;
}

/* ポップ（拡大） */
@keyframes twinkle-pop {
  0%   { transform: scale(0.2) rotate(0deg); }
  50%  { transform: scale(1.10) rotate(20deg); }
  100% { transform: scale(1.0) rotate(40deg); }
}

/* フェードアウト */
@keyframes twinkle-fade {
  0%   { opacity: 1; }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.0); }
}

.twinkle-effect {
  transition: opacity 140ms linear, transform 220ms cubic-bezier(.2,.8,.2,1);
  will-change: opacity, transform;
}

.twinkle-effect {
  width: 48px;     /* ← ここが超重要 */
  height: 48px;
  pointer-events: none;
  will-change: transform, opacity;
}

.twinkle-wrapper {
  width: 0;
  height: 0;
}

/* 通常ヒットで光る */
.note-lane.glow-line::after {
    background-color: #bfff9c; /* 黄緑を少し明るく */
    box-shadow:
        0 0 180px rgba(255, 255, 255, 5),
        0 0 200px rgba(255, 255, 255, 4.8);
}

/* Perfect 用（豪華） */
.note-lane.glow-perfect-line::after {
    background-color: #fff3a0;
    box-shadow:
        0 0 250px rgba(255,255,255,5),
        0 0 300px rgba(255,255,255,4.8);
}

/* ふわっと戻るためのトランジション */
.note-lane::after {
    transition:
        box-shadow 120ms ease,
        background-color 120ms ease;
}

/* レーン内部の発光レイヤー */
.note-lane::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at center,
        rgba(180,255,180,0.35) 0%,
        rgba(180,255,180,0.18) 35%,
        rgba(180,255,180,0.05) 60%,
        rgba(180,255,180,0.0) 75%
    );
    opacity: 0;
    pointer-events: none;
    transition: opacity 120ms ease;
    z-index: 1; /* ノーツより下、判定ラインより下が理想 */
}

/* 通常ヒット */
.note-lane.glow-lane::before {
    opacity: 1;
}

/* Perfect 用（少し強め） */
.note-lane.glow-perfect-lane::before {
    opacity: 1;
    background: radial-gradient(
        ellipse at center,
        rgba(255,255,200,0.45) 0%,
        rgba(255,240,170,0.25) 40%,
        rgba(255,240,170,0.08) 65%,
        rgba(255,240,170,0.0) 80%
    );
}

/* レーン本体 */
.note-lane {
    position: relative;
    z-index: 0;
    overflow: hidden;
}

/* レーン内部発光 */
.note-lane::before {
    z-index: 5;
}

/* 判定ライン */
.note-lane::after {
    z-index: 10;
}

/* ノーツ */
.note {
    position: absolute;
    z-index: 20;
}

.note-lane::before {
    outline: 1px solid red;
}

/* レーン内部発光をド派手にする（テスト用） */
.note-lane::before {
    background: rgba(255, 255, 255, 0.304) !important;
}

#start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6); /* 周りを暗く */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

#start-button {
  font-size: 28px;
  padding: 20px 40px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  background: #ff8c00;
  color: #ffffff;
  font-weight: bold;
  box-shadow: 0 6px 0 #ff8c00;
}

#start-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #cc9f00;
}

#start-overlay {
  backdrop-filter: blur(4px);

}

#start-overlay {
  display: none !important;
}

/* ボタンが押されている時の状態 */
.design-button.is-pressed {
    transform: scale(0.9) !important; /* 強制的にサイズを小さくする */
}

/* 元に戻る動きを滑らかにしたい場合（任意） */
.design-button {
    transition: transform 0.05s ease-out;
}

/* 最初は非表示にしておく */
#maintenance-screen {
    display: none; 
}

/* 「is-maintenance」というクラスがついている時だけ表示する */
#maintenance-screen.is-maintenance {
    display: flex; /* これで表示される */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    font-family: sans-serif;
}

.maint-text {
    color: #000000;
    font-size: 24px;
    font-weight: bold;
    margin-bottom: 10px;
}

.maint-subtext {
    color: #666666;
    font-size: 16px;
}