/* ==========================================
   1. 全体リセット & 画面固定 (dvh中央寄せ)
   ========================================== */
* {
    /* 🎯 【完全復活】すべてのレイアウト計算を根本から固定する共通リセット */
    box-sizing: border-box; 
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    text-align: center;     
    background-color: #212121;
    color: #ffffff;            
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100dvh;

    /* 画像のパスを指定します */
  background-image: url("/common/image01.webp"); 
  background-size: cover; 
  background-repeat: no-repeat; 
  background-position: center; 
  background-attachment: fixed; 
}

.ui-container {
    width: min(720px, 95vw);
    margin: 0 auto;
    position: relative; 
    padding: 20px 0; 
}

/* ==========================================
   2. タイトルエリア (緑ネオン管仕様)
   ========================================== */
.title-area h1 {
    font-size: 1.25rem;     
    font-weight: bold;      
    letter-spacing: 2px;    
    padding: 8px 0;        
    background-color: rgba(0, 32, 16, 0.85); 
    color: #00ffcc; 
    border-radius: 9999px;    
    text-shadow: 0 0 10px rgba(0, 255, 204, 0.6); 
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), 
                inset 0 0 15px rgba(0, 255, 204, 0.2); 
    border: 1px solid #00bfa5; 
}

/* ==========================================
   3. 左右2分割メーターUI (PC・スマホ共通整列)
   ========================================== */
.status-area {
    display: grid;
    grid-template-columns: 1fr auto; 
    align-items: center; 
    gap: 12px;
    margin: 12px 0;
}

.status-info {
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    font-weight: bold;
    color: #e0e0e0;
    text-align: left; 
    padding-left: 4px;
    white-space: pre-line;  
}

.btn-group {
    display: flex;
    gap: 8px; 
    align-items: center; 
}

/* ==========================================
   4. フィールドエリア & 4つの絶対配置レイヤー
   ========================================== */
.field-area {
    position: relative;
    width: min(720px, 90vw);            
    aspect-ratio: 1 / 1; 
    margin: 0 auto;
    border-radius: 14px;    
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8); 
    border: 6px solid #37474f; 
    overflow: hidden; 
}

/* CYCROSS 4-Layer Shell: 親の枠内に完全に閉じ込める100%シンクロ絶対配置 */
.bg-layer, .fx-layer, .piece-layer, .card-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* レイヤー1: 背景（チャコールグレーの土台） */
.bg-layer {
    z-index: 1;
    background-color: #212121; 
}

/* レイヤー2: ポインタースルー バックグラウンド緑 */
.fx-layer {
    z-index: 2;
    pointer-events: none;
}

/* レイヤー3: ピースレイヤー（動的等分割グリッド盤面） */
.piece-layer {
    z-index: 3;
    display: grid;          
    grid-template-rows: repeat(var(--rows), 1fr);
    grid-template-columns: repeat(var(--cols), 1fr); 
    padding: 6px;              
    gap: 0px;
    
    /* 💡 8桁の16進数で短く書くなら「background: #1e7a44d9;」と同じ意味 */
    /* background: ; */
}

/* ==========================================
   5. マス目 (セル) & ガイド (ネオン点灯)
   ========================================== */
.cell {
    position: relative;
    box-sizing: border-box;
    border: 1px solid #212121; 
    /* 💡 これを追加：中の石を強制的にマスのド真ん中へ固定する */
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell:hover { 
    background-color: rgba(52, 211, 153, 0.3); 
}

/* 置けるマスのガイド（ネオン点灯） */
/*
.cell.playable::after {
    content: "";            
    width: 7px;              
    height: 7px;             
    background-color: #00ffcc; 
    border-radius: 50%;     
    position: absolute;     
    z-index: 2;             
    box-shadow: 0 0 6px #00ffcc, 0 0 12px #00ffcc;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.cell.playable:hover::after {
    opacity: 1;
}
*/

/* ==========================================
   6. オセロ石 (リアルグラデーション)
   ========================================== */
.stone {
    width: 88%;             
    height: 88%;            
    border-radius: 50%;     
    position: relative;     
    z-index: 10;            
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    transform: scale(0);
}

/* ★修正：石が配置されたらスケール1で弾むように出現 ＆ 背景色と影を確実に適用 */
.stone.black { 
    transform: scale(1);
    background: radial-gradient(circle at 30% 30%, #555555 0%, #1a1a1a 50%, #000000 100%); 
    box-shadow: 2px 3px 6px rgba(0,0,0,0.55), inset -1px -1px 3px rgba(0,0,0,0.8); 
}

.stone.white { 
    transform: scale(1);
    background: radial-gradient(circle at 25% 25%, #ffffff 0%, #ffffff 20%, #ececec 55%, #c5c5c5 100%); 
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3), 2px 4px 6px rgba(0,0,0,0.45), inset -2px -2px 4px rgba(0,0,0,0.35); 
}

/* ===================================================
   7. 操作ボタン (常時発光ネオン管・1px枠)
   =================================================== */
/* 🎯 修正：.bgm-btn を合流させ、RESETやMANUALと全く同じサイズ・フォント・枠線・丸みに統一 */
.reset-btn, .manual-btn, .size-btn, .bgm-btn {
    width: 110px;           
    padding: 8px 0;        
    font-size: 0.95rem;        
    font-weight: bold;      
    border: none; 
    border-radius: 9999px;    
    cursor: pointer;        
    display: inline-block;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.2s, transform 0.1s, box-shadow 0.2s, text-shadow 0.2s;
}

.reset-btn:active, .manual-btn:active, .size-btn:active, .bgm-btn:active {
    transform: scale(0.95);
}

.reset-btn { 
    background-color: rgba(211, 47, 47, 0.2); 
    border: 1px solid #ff8a80; 
    color: #ff8a80; 
    text-shadow: 0 0 5px rgba(255, 138, 128, 0.6);
    box-shadow: 0 0 10px rgba(255, 138, 128, 0.3), inset 0 0 5px rgba(255, 138, 128, 0.2);
}
.reset-btn:hover { 
    background-color: #b71c1c; 
    color: #ffffff;
    box-shadow: 0 0 20px rgba(255, 138, 128, 0.8), 0 0 30px rgba(255, 138, 128, 0.4); 
}

.manual-btn {
    background-color: rgba(26, 115, 232, 0.2); 
    border: 1px solid #4fc3f7; 
    color: #4fc3f7; 
    text-shadow: 0 0 5px rgba(79, 195, 247, 0.6);
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.3), inset 0 0 5px rgba(79, 195, 247, 0.2);
}
.manual-btn:hover {
    background-color: #1557b0; 
    color: #ffffff;
    box-shadow: 0 0 20px rgba(79, 195, 247, 0.8), 0 0 30px rgba(79, 195, 247, 0.4); 
}

.size-btn {
    background-color: rgba(0, 191, 165, 0.15); 
    border: 1px solid #00ffcc; 
    color: #00ffcc; 
    text-shadow: 0 0 5px rgba(0, 255, 204, 0.6);
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.3), inset 0 0 5px rgba(0, 255, 204, 0.2);
}
.size-btn:hover {
    background-color: #00796b; 
    color: #ffffff;
    box-shadow: 0 0 20px rgba(0, 255, 204, 0.8), 0 0 30px rgba(0, 255, 204, 0.4); 
}

/* 🎯 1. 通常状態 (BGM: OFF) ―― 他のボタンと100%同じ透過度の「暗いオレンジ」 */
.bgm-btn {
    background-color: rgba(255, 145, 0, 0.2); 
    border: 1px solid #ff9100; 
    color: #ff9100; 
    text-shadow: 0 0 5px rgba(255, 145, 0, 0.6);
    box-shadow: 0 0 10px rgba(255, 145, 0, 0.3), inset 0 0 5px rgba(255, 145, 0, 0.2);
}

/* 🎯 2. マウスホバー時 ―― 💡 解決策：ベタ塗りをやめ、他のボタンと同じく「透過度0.8（rgba）」で色を濃くします。
   これにより、外枠の「1pxのボーダー線」が埋もれることなく、最後までクッキリと美しく見え続けます！ */
.bgm-btn:hover {
    background-color: rgba(255, 145, 0, 0.8); 
    border: 1px solid #ff9100;
    color: #ffffff; 
    box-shadow: 0 0 20px rgba(255, 145, 0, 0.8), 0 0 30px rgba(255, 145, 0, 0.4); 
}

/* ==========================================
   8. 多目的カードレイヤー・テキスト (CYCROSS GEAR 抽象化仕様)
   ========================================== */
.card-layer {
    position: absolute;
    z-index: 4;
    top: 50%;
    left: 50%;
    width: 80%;
    height: 80%;
    background: rgba(0, 20, 10, 0.75); 
    border: 2px solid #00ffcc; 
    padding: 24px; 
    border-radius: 8px;
    box-shadow: inset 0 0 25px rgba(0, 255, 204, 0.4), 
                0 0 30px rgba(0, 255, 204, 0.3);
    opacity: 0;
    pointer-events: none; 
    transform: translate(-50%, -50%) scale(0);    
    transition: opacity 0.3s ease, 
                transform 0.4s cubic-bezier(0.34, 1.8, 0.64, 1); 
}

.card-layer.active {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

.title-card {
    font-size: 1.1rem;
    font-weight: bold;
    color: #00ffcc;
    border-bottom: 2px dashed rgba(0, 255, 204, 0.5); 
    padding-bottom: 8px;
    margin-bottom: 16px;
    letter-spacing: 2px;
    font-family: 'Courier New', monospace;
    text-align: left;
}

.line-card {
    font-size: 0.85rem; 
    color: #a7ffeb;
    margin: 12px 0; 
    font-family: 'Courier New', Courier, monospace;
    line-height: 1.5;
    text-align: left;
}

.powered-card {
    font-size: 0.65rem;
    font-family: 'Courier New', monospace;
    letter-spacing: 3px;
    color: rgba(0, 255, 204, 0.4); 
    text-align: right;
    margin-top: 24px;
    text-shadow: 0 0 4px rgba(0, 255, 204, 0.3);
    text-transform: uppercase; 
}

.scanline-card {
    position: absolute;
    inset: 10%;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%);
    background-size: 100% 4px;
    border-radius: 10px;
    pointer-events: none;
    opacity: 0.3;
}

/* ==========================================
   9. スマホ専用レスポンシブ (文字1/2化＆隙間ゼロ)
   ========================================== */
@media (max-width: 480px) {
    .status-area {
        margin: 8px 0; 
    }

    .title-area h1 {
        font-size: 0.625rem;
        padding: 4px 0; 
    }

    .field-area {
        width: 95vw; 
    }

    .cell.playable::after {
        width: 3.5px;
        height: 3.5px;
        box-shadow: 0 0 3px #00ffcc, 0 0 6px #00ffcc;
    }

    /* 🎯 修正：BGMボタンを含めた4つのボタン全てを55pxに均等縮小。スマホの横並びを完全に死守 */
    .reset-btn, .manual-btn, .size-btn, .bgm-btn {
        font-size: 0.5rem;
        width: 55px;
        min-width: 55px;
        padding: 5px 0;
    }

    .status-info {
        font-size: 0.5rem;
    }

    .title-card {
        font-size: 0.55rem;
        border-bottom-width: 1px;
        margin-bottom: 8px;
        padding-bottom: 4px;
    }
    
    .line-card {
        font-size: 0.425rem;
        margin: 6px 0;
        line-height: 1.3;
    }

    .powered-card {
        font-size: 0.4rem;
        margin-top: 12px;
    }
}