/* =========================================
   基本レイアウト
   ========================================= */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #eee;
    text-align: center;
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
}

/* 強制非表示（JSでの切り替え用） */
.hidden { 
    display: none !important; 
}

h1 { 
    font-size: 2.5rem; 
    color: #ffcc00; 
    text-shadow: 2px 2px 4px #000; 
    margin-bottom: 10px;
}

.subtitle {
    color: #aaa;
    margin-bottom: 30px;
}

/* =========================================
   ロビー (TOP画面)
   ========================================= */
#lobby {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 80vh;
    gap: 20px;
}

/* スライドバー周り：コンパクト & 浮かせる */
.slider-container {
    width: 250px; 
    text-align: center;
    /* margin の左右を auto にすることで、250pxの箱を中央に寄せます */
    margin: 20px auto; 
    /* 念のため中身の配置を整える */
    display: flex;
    flex-direction: column;
    align-items: center;
}

.size-label {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: #ffcc00; /* テキストカラーを調整 */
}

#size-select {
    width: 100%;
    cursor: pointer;
    accent-color: #007bff; /* ゲージの色 */
    background: transparent;
    outline: none;
}

/* =========================================
   ゲーム画面 UI
   ========================================= */
#ui-panel {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 500px;
    margin: 0 auto 15px;
    background: #333;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#status { font-size: 1.5rem; font-weight: bold; color: #ff4444; }
#room-info { font-size: 0.8rem; color: #aaa; font-family: monospace; }

/* 盤面コンテナ（巨大化対応） */
#grid-container {
    display: flex;
    justify-content: center;
    overflow: auto;
    padding: 10px;
    max-height: 70vh;
    margin-bottom: 20px;
}

#grid {
    display: grid;
    /* grid-template-columns は JS で動的に上書きされます */
    gap: 2px;
    background: #444;
    padding: 8px;
    border: 4px solid #555;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

/* =========================================
   セル (マス目) のスタイル
   ========================================= */
.cell {
    width: 35px; 
    height: 35px;
    background: #444; /* 少し明るいグレー */
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    border: 1px solid #222; /* 立体感を消して線にする */
    transition: background 0.1s;
}
.cell:hover:not(.open) {
    filter: brightness(1.2);
    background: #888;
}

/* オープン状態 */
.cell.open {
    background: #47627e; 
    color: #ecf0f1;
    border: 1px solid #34495e;
    cursor: default;
    animation: popIn 0.2s ease-out;
}

/* 旗 */
.cell.flag { color: #ff4444 !important; }

/* 爆弾関連 */
.cell.open.bomb {
    background: #7b1f1f;
    border-color: #ff4444;
}

.cell.bomb-hit {
    background-color: #ff0000 !important;
    animation: shake 0.4s;
    z-index: 5;
}

/* =========================================
   ボタン
   ========================================= */
button {
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px;
    border: none;
    transition: all 0.2s;
}

#btn-new { 
    background: #ffcc00; 
    color: #1a1a1a; 
}

#btn-new:hover { 
    background: #ffd633;
    transform: translateY(-2px);
}

#btn-exit { 
    background: #444; 
    color: #ccc;
    margin-top: 10px;
}

#btn-exit:hover { background: #555; }

/* =========================================
   演出・アニメーション
   ========================================= */

/* ライフ減少 */
#life.damage {
    color: #ff0000;
    animation: heartBeat 0.5s;
}

/* CPU爆弾追加トースト */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(219, 182, 59, 0.9);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.5rem;
    box-shadow: 0 0 20px rgba(255,0,0,0.5);
    z-index: 1000;
    pointer-events: none;
    animation: fadeUp 2s forwards;
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    30% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

@keyframes fadeUp {
    0% { opacity: 0; transform: translate(-50%, 20%); }
    20% { opacity: 1; transform: translate(-50%, -50%); }
    80% { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -120%); }
}

/* ズームのためのコンテナ調整 */
#grid-container {
    display: flex;
    justify-content: center;
    align-items: flex-start; /* 上詰め */
    overflow: auto;
    padding: 40px;
    max-height: 75vh;
    /* background: #000; 背景を黒にして盤面を浮かせる */
    cursor: grab; /* 掴める感を出す */
}

#grid-container:active {
    cursor: grabbing;
}

#grid {
    transform-origin: top center; /* ズームの支点 */
    transition: transform 0.1s ease-out; /* ズームを滑らかに */
}