/* ==========================================
   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; 
}

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

/* ==========================================
   2. タイトルエリア (チェス色・ゴールドアンバー固定)
   ========================================== */
.title-area h1 {
    font-size: clamp(0.9rem, 4vw, 1.25rem); 
    font-weight: bold;      
    letter-spacing: 2px;    
    padding: 6px 0;        
    background-color: rgba(32, 24, 12, 0.85); 
    color: #ffb300; 
    border-radius: 9999px;    
    text-shadow: 0 0 10px rgba(255, 179, 0, 0.6); 
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.8), inset 0 0 15px rgba(255, 179, 0, 0.2); 
    border: 1px solid #ff8f00; 
}

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

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

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

/* ==========================================
   4. フィールドエリア & 4つの絶対配置レイヤー
   ========================================== */
.field-area {
    position: relative;
    width: min(720px, 92vw);            
    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 */
.bg-layer, .line-layer, .piece-layer, .card-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
}

.bg-layer { z-index: 1; background-color: #212121; }

.line-layer {
    z-index: 2;
    pointer-events: none;
    box-shadow: inset 0 0 60px rgba(64, 48, 24, 0.35); 
    background-color: transparent;
}

.piece-layer#piece {
    z-index: 3;
    display: grid;          
    grid-template-rows: repeat(8, 1fr);
    grid-template-columns: repeat(8, 1fr); 
    padding: 6px;              
    background-color: transparent; 
    gap: 1px; 
}

/* ==========================================
   5. マス目 (セル) & ガイド 
   ========================================== */
.cell {
    display: flex;          
    justify-content: center; 
    align-items: center;    
    cursor: pointer;        
    position: relative;     
}

/* 2色オークウッドのベタ塗り */
.cell:nth-child(-n+8):nth-child(odd), .cell:nth-child(n+9):nth-child(-n+16):nth-child(even),
.cell:nth-child(n+17):nth-child(-n+24):nth-child(odd), .cell:nth-child(n+25):nth-child(-n+32):nth-child(even),
.cell:nth-child(n+33):nth-child(-n+40):nth-child(odd), .cell:nth-child(n+41):nth-child(-n+48):nth-child(even),
.cell:nth-child(n+49):nth-child(-n+56):nth-child(odd), .cell:nth-child(n+57):nth-child(even) { background-color: #e6c280; }

.cell:nth-child(-n+8):nth-child(even), .cell:nth-child(n+9):nth-child(-n+16):nth-child(odd),
.cell:nth-child(n+17):nth-child(-n+24):nth-child(even), .cell:nth-child(n+25):nth-child(-n+32):nth-child(odd),
.cell:nth-child(n+33):nth-child(-n+40):nth-child(even), .cell:nth-child(n+41):nth-child(-n+48):nth-child(odd),
.cell:nth-child(n+49):nth-child(-n+56):nth-child(even), .cell:nth-child(n+57):nth-child(odd) { background-color: #a07840; }

/* ホバー時は上品でクリアな「白（ホワイト）」のライトがじわっと灯る */
.cell:hover { 
    background-color: rgba(255, 255, 255, 0.25) !important; 
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.4);
    transition: all 0.15s ease;
}

/* 移動可能マス（playable）の中央には純粋な「白い点」だけを灯す */
.cell.playable::after {
    content: "";            
    width: clamp(5px, 1.5vw, 8px); 
    height: clamp(5px, 1.5vw, 8px);             
    background-color: #ffffff; 
    border-radius: 50%;     
    position: absolute;     
    z-index: 12;             
    box-shadow: 0 0 8px #ffffff;
    opacity: 0.9;
}

/* ==========================================
   6. 駒 (💡 味方の真っ黒バグを完全修正版)
   ========================================== */
.stone {
    width: 90%; height: 90%;            
    position: relative; z-index: 10;            
    display: flex; justify-content: center; align-items: center;
    font-size: clamp(1.2rem, 6vw, 2.5rem); 
    user-select: none;
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.2);
    transform: scale(0);
}

.stone.black, .stone.white { transform: scale(1); }

/* AI側（黒駒）：光を吸収する漆黒の影 */
.black { 
    color: #1a1a1a; 
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)); 
    text-shadow: 0 0 5px rgba(255,255,255,0.1); 
}

/* プレイヤー側（白駒・味方）：💡 ついに濁りのない美しい純白ネオンとして大復活！ */
.white { 
    color: #ffffff; 
    text-shadow: 0 0 8px #ffffff, 0 0 15px rgba(255, 255, 255, 0.5); 
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.45)); 
}

/* ===================================================
   7. 操作ボタン
   =================================================== */
.reset-btn, .manual-btn {
    width: clamp(70px, 15vw, 110px); 
    padding: 6px 0;        
    font-size: clamp(0.6rem, 2vw, 0.95rem); 
    font-weight: bold;      
    border: none; border-radius: 9999px; cursor: pointer;        
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s;
}

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

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

.manual-btn {
    background-color: rgba(43, 34, 16, 0.4); border: 1px solid #ffb300; color: #ffb300; 
    text-shadow: 0 0 5px rgba(255, 179, 0, 0.6); box-shadow: 0 0 10px rgba(255, 179, 0, 0.3);
}
.manual-btn:hover { background-color: #b56c00; color: #ffffff; box-shadow: 0 0 20px rgba(255, 179, 0, 0.8); }

/* ==========================================
   8. 多目的カードレイヤー・テキスト (チェス色・ゴールドアンバー固定)
   ========================================== */
.card-layer#card {
    z-index: 4;
    background: rgba(26, 18, 10, 0.96); 
    border: 2px solid #ffb300; 
    box-shadow: inset 0 0 25px rgba(255, 179, 0, 0.25);
    display: flex; justify-content: center; align-items: center;
    padding: clamp(12px, 4vw, 24px); 
    opacity: 0; pointer-events: none; 
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); transform: scale(0.95);
}

.card-layer#card.active { opacity: 1; pointer-events: auto; transform: scale(1); }
.content-card { text-align: left; width: 100%; }

.title-card {
    font-size: clamp(0.75rem, 3.5vw, 1.1rem);
    font-weight: bold; color: #ffb300;
    border-bottom: 2px dashed rgba(255, 179, 0, 0.5); 
    padding-bottom: 6px; margin-bottom: 12px; letter-spacing: 2px;
    font-family: 'Courier New', monospace;
}

.line-card {
    font-size: clamp(0.55rem, 2.5vw, 0.85rem); 
    color: #ffe0b2; margin: 8px 0; 
    font-family: 'Courier New', Courier, monospace; line-height: 1.4;
}

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

.scanline-card {
    position: absolute; 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; pointer-events: none; opacity: 0.3;
}

/* ==========================================
   9. スマホ専用レスポンシブ
   ========================================== */
@media (max-width: 480px) {
    .field-area { width: 95vw; }
}