/* ==========================================
   1. 全体リセット & 画面固定 (dvh中央寄せ)
   ========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    text-align: center;     
    background-color: #121212; 
    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: 10px 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. メーターUI & 難易度セレクト & ネオン管ボタン
   ========================================== */
.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;  
}

.neon-text-red { color: #ff8a80; text-shadow: 0 0 4px #ff8a80; }
.neon-text-blue { color: #4fc3f7; text-shadow: 0 0 4px #4fc3f7; }

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

/* 難易度セレクトボックスのサイバーデザイン */
.diff-select {
    background-color: #1a1a1a;
    color: #00ffcc;
    border: 1px solid #00bfa5;
    padding: 6px 12px;
    font-weight: bold;
    font-size: 0.85rem;
    border-radius: 9999px;
    outline: none;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.1);
}

.reset-btn, .manual-btn {
    width: 90px;           
    padding: 8px 0;        
    font-size: 0.85rem;        
    font-weight: bold;      
    border: none; 
    border-radius: 9999px;    
    cursor: pointer;        
    display: inline-block;
    transition: all 0.2s ease, transform 0.1s ease;
}

.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);
}
.reset-btn:hover { background-color: #b71c1c; color: #ffffff; box-shadow: 0 0 20px #ff8a80; }

.manual-btn {
    background-color: rgba(0, 150, 136, 0.2); border: 1px solid #4db6ac; color: #4db6ac; 
    text-shadow: 0 0 5px rgba(77, 182, 172, 0.6);
    box-shadow: 0 0 10px rgba(77, 182, 172, 0.3);
}
.manual-btn:hover { background-color: #00796b; color: #ffffff; box-shadow: 0 0 20px #4db6ac; }

/* ==========================================
   4. フィールドエリア & 3x3境界線（太線）
   ========================================== */
.field-area {
    position: relative;
    width: min(640px, 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; 
}

.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: #1a1a1a; }

/* 💡 3x3ブロックの太い境界線を純粋なCSSグラデーションで完全再現 */
.line-layer {
    z-index: 2;
    pointer-events: none;
    background: 
        linear-gradient(to right, rgba(0, 255, 204, 0.4) 2px, transparent 2px) 0 0 / 33.333% 100%,
        linear-gradient(to bottom, rgba(0, 255, 204, 0.4) 2px, transparent 2px) 0 0 / 100% 33.333%,
        linear-gradient(to right, rgba(0, 255, 204, 0.08) 1px, transparent 1px) 0 0 / 11.111% 100%,
        linear-gradient(to bottom, rgba(0, 255, 204, 0.08) 1px, transparent 1px) 0 0 / 100% 11.111%,
        #070d0a; 
}

.piece-layer#stage-panel {
    z-index: 3;
    display: grid;          
    grid-template-rows: repeat(9, 1fr);
    grid-template-columns: repeat(9, 1fr); 
    padding: 6px;              
    gap: 2px; 
}

/* ==========================================
   5. ナンプレマスの極小ネオンデザイン
   ========================================== */
.cell {
    display: flex;          
    justify-content: center; 
    align-items: center;    
    border-radius: 4px;     
    font-size: clamp(0.95rem, 4.5vw, 1.6rem); /* 極小マスでもはみ出さない可変フォント */
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    
    background: rgba(0, 77, 64, 0.1);
    color: #00ffcc;
    border: 1px solid rgba(0, 255, 204, 0.1);
    box-shadow: inset 0 0 5px rgba(0, 255, 204, 0.05);
}

.cell:hover:not(.fixed) {
    background: rgba(0, 112, 92, 0.25);
    border-color: #00ffcc;
    box-shadow: 0 0 8px rgba(0, 255, 204, 0.4);
}

/* 💡 初期プロテクト数字（固定マス：変更不可） */
.cell.fixed {
    background: rgba(255, 255, 255, 0.04);
    color: #ffffff; /* パキッとした白 */
    border-color: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.4);
}

/* 💡 選択状態のマス（チャージ点滅） */
.cell.selected {
    background: radial-gradient(circle at 35% 35%, #00bfa5 0%, #004d40 100%);
    color: #ffffff;
    border-color: #ffffff;
    box-shadow: 0 0 10px #00ffcc, inset 0 0 5px #00ffcc;
}

/* 💡 間違えた数字（エラー発光） */
.cell.wrong {
    background: rgba(211, 47, 47, 0.2) !important;
    color: #ff8a80 !important;
    border-color: #ff8a80 !important;
    text-shadow: 0 0 6px #ff8a80 !important;
    box-shadow: inset 0 0 6px rgba(255, 138, 128, 0.3) !important;
}

/* ==========================================
   6. 下部10連ナンバーエリア（テンキー入力パッド）
   ========================================== */
.number-pad-area {
    display: grid;
    grid-template-columns: repeat(10, 1fr); /* 💡 10個のボタンが等幅並列 */
    gap: 6px;
    width: min(640px, 90vw);
    margin: 14px auto 0 auto;
}

.num-btn {
    padding: 10px 0;
    font-size: clamp(0.9rem, 4vw, 1.25rem);
    font-weight: bold;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    background-color: rgba(26, 115, 232, 0.15); 
    border: 1px solid #4fc3f7; 
    color: #4fc3f7; 
    text-shadow: 0 0 4px rgba(79, 195, 247, 0.6);
    box-shadow: 0 0 8px rgba(79, 195, 247, 0.2);
    transition: all 0.15s ease, transform 0.05s ease;
}

.num-btn:hover {
    background-color: #1557b0; 
    color: #ffffff;
    box-shadow: 0 0 15px #4fc3f7; 
}
.num-btn:active { transform: scale(0.92); }

/* 消去(C)ボタンだけテンションを変えて赤管発光 */
.num-btn.clear-action {
    background-color: rgba(211, 47, 47, 0.15);
    border-color: #ff8a80;
    color: #ff8a80;
    text-shadow: 0 0 4px #ff8a80;
    box-shadow: 0 0 8px rgba(255, 138, 128, 0.2);
}
.num-btn.clear-action:hover {
    background-color: #b71c1c;
    color: #ffffff;
    box-shadow: 0 0 15px #ff8a80;
}

/* ==========================================
   7. 多目的カードレイヤー (説明モーダル)
   ========================================== */
.card-layer#card {
    z-index: 4; background: rgba(0, 20, 10, 0.97); border: 2px solid #00ffcc; 
    box-shadow: inset 0 0 25px rgba(0, 255, 204, 0.25);
    display: flex; justify-content: center; align-items: center; padding: 24px; 
    opacity: 0; pointer-events: none; transform: scale(0.95);
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}
.card-layer#card.active { opacity: 1; pointer-events: auto; transform: scale(1); }
.content-card { text-align: left; width: 100%; }
.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;
}
.line-card { font-size: 0.85rem; color: #a7ffeb; margin: 12px 0; font-family: 'Courier New', Courier, monospace; line-height: 1.5; }
.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-transform: uppercase; }
.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; }

/* ==========================================
   8. スマホ専用コンパクトレスポンシブ
   ========================================== */
@media (max-width: 480px) {
    .status-area { grid-template-columns: 1fr; text-align: center; gap: 6px; margin: 6px 0; }
    .status-info { text-align: center; padding-left: 0; font-size: 0.75rem; }
    .btn-group { justify-content: center; width: 100%; }
    .diff-select { padding: 4px 8px; font-size: 0.75rem; }
    .title-area h1 { font-size: 0.8rem; padding: 6px 0; }
    .field-area { width: 95vw; border-width: 4px; }
    .piece-layer#stage-panel { padding: 3px; gap: 1px; }
    .cell { font-size: 1rem; border-radius: 2px; }
    .number-pad-area { gap: 3px; margin-top: 8px; width: 95vw; }
    .num-btn { padding: 8px 0; font-size: 0.95rem; border-radius: 4px; }
    .reset-btn, .manual-btn { font-size: 0.7rem; width: 80px; padding: 6px 0; }
    .title-card { font-size: 0.75rem; margin-bottom: 8px; padding-bottom: 4px; }
    .line-card { font-size: 0.6rem; margin: 6px 0; line-height: 1.4; }
    .powered-card { font-size: 0.5rem; margin-top: 12px; }
}