/* ================================================================
   OT-Buddy: TMT Style Sheet (Fixed & Compact)
================================================================ */

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: 'Noto Sans JP', sans-serif; overflow: hidden; }

/* 背景 */
.app-bg {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #e0f7fa 0%, #80deea 100%);
    z-index: -1;
}

/* ゲームレイヤー */
.game-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1;
}

/* UIレイヤー */
.ui-layer {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    z-index: 10; pointer-events: none; /* 下のゲームを操作可能に */
}
/* UI内の操作可能要素のみポインター復活 */
.header-bar, .overlay-screen { pointer-events: auto; }

/* ヘッダー */
.header-bar {
    position: absolute; top: 0; left: 0; width: 100%; height: 60px;
    padding: 0 15px; display: flex; justify-content: space-between; align-items: center;
    background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(5px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.game-status { display: flex; gap: 15px; align-items: baseline; }
.status-item .label { font-size: 0.7rem; color: #666; font-weight: bold; margin-right: 4px; }
.status-item .value { font-family: 'Orbitron', sans-serif; font-size: 1.2rem; color: #333; font-weight: 700; }
.btn-menu {
    background: #fff; border: 1px solid #ccc; padding: 5px 12px; border-radius: 20px;
    display: flex; align-items: center; gap: 4px; cursor: pointer; color: #555; font-weight: bold; font-size: 0.85rem;
}

/* --- オーバーレイ画面 (設定・結果) --- */
.overlay-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex; justify-content: center; align-items: center;
    padding: 15px;
}
.overlay-screen.hidden { display: none; }

/* --- 設定カード (AIミラーセラピー風) --- */
.setup-card {
    background: white; width: 100%; max-width: 420px;
    border-radius: 20px; padding: 25px 20px;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    text-align: center; margin: 0 auto;
    max-height: 95vh; overflow-y: auto;
}

.card-header { position: relative; margin-bottom: 15px; display: flex; justify-content: center; align-items: center; }
.btn-icon-back {
    position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: #555; padding: 5px;
}
.card-title { font-size: 1.3rem; color: #333; margin: 0; font-weight: 800; letter-spacing: 0.05em; }
.card-desc { 
    font-size: 0.85rem; color: #666; margin-bottom: 20px; 
    line-height: 1.5; text-align: left; background: #f5f5f5;
    padding: 10px; border-radius: 8px;
}

/* --- グリッドレイアウト (ズレ防止・幅一杯) --- */
.settings-grid { 
    display: grid; 
    grid-template-columns: 1fr 1fr; /* 2列 */
    gap: 12px; 
    margin-bottom: 20px; 
    text-align: left;
    width: 100%;
}
.s-item { width: 100%; }
.s-item.full-width { grid-column: 1 / -1; } /* 全幅 */

.s-item label { 
    display: block; font-weight: bold; font-size: 0.8rem; color: #444; 
    margin-bottom: 5px; margin-left: 2px;
}

/* --- 連結ボタンスタイル (AIミラーセラピー風) --- */
.radio-group {
    display: flex; width: 100%;
    background: #eceff1; border-radius: 8px; padding: 3px;
}
.radio-group input { display: none; }
.radio-group label {
    flex: 1; text-align: center;
    padding: 8px 0; font-size: 0.85rem; color: #607d8b;
    cursor: pointer; border-radius: 6px;
    transition: all 0.2s; font-weight: 500;
}
.radio-group input:checked + label {
    background: white; color: #00838f; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); font-weight: bold;
}

select {
    width: 100%; padding: 8px; border-radius: 8px; border: 1px solid #cfd8dc;
    font-size: 0.9rem; background: #fff; color: #333; height: 38px;
}

/* スタートボタン */
.start-btn {
    width: 100%; padding: 14px; background: linear-gradient(135deg, #26c6da, #00acc1);
    color: white; border: none; border-radius: 50px; 
    font-size: 1.1rem; font-weight: bold; letter-spacing: 0.05em;
    cursor: pointer; box-shadow: 0 5px 15px rgba(0,172,193,0.4);
    transition: transform 0.1s; margin-top: 5px;
}
.start-btn:active { transform: scale(0.98); }

/* --- ゲーム要素 --- */
#countdown-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.4); backdrop-filter: blur(3px);
    display: flex; justify-content: center; align-items: center; z-index: 40;
}
#countdown-text {
    font-family: 'Orbitron', sans-serif; font-size: 7rem; color: #00838f;
    font-weight: 900; text-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

.tmt-droplet {
    position: absolute; width: 55px; height: 55px;
    display: flex; justify-content: center; align-items: center;
    border-radius: 50% 50% 50% 5%; transform: rotate(-45deg);
    box-shadow: 2px 4px 10px rgba(0,0,0,0.15), inset -2px -2px 5px rgba(0,0,0,0.1);
    cursor: pointer; font-family: 'Orbitron', sans-serif; 
    user-select: none; z-index: 5; transition: transform 0.1s;
}
.tmt-droplet span {
    transform: rotate(45deg); font-size: 1.3rem; font-weight: 700; color: white;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
}
.tmt-droplet:active { transform: rotate(-45deg) scale(0.9); }

.drop-color-0 { background: linear-gradient(135deg, #29b6f6, #0288d1); }
.drop-color-1 { background: linear-gradient(135deg, #66bb6a, #43a047); }
.drop-color-2 { background: linear-gradient(135deg, #ffa726, #fb8c00); }
.drop-color-3 { background: linear-gradient(135deg, #ab47bc, #8e24aa); }
.drop-color-4 { background: linear-gradient(135deg, #ef5350, #e53935); }

.tmt-droplet.correct { animation: correctPop 0.3s forwards; pointer-events: none; }
@keyframes correctPop { 0% { transform: rotate(-45deg) scale(1); opacity: 1; } 100% { transform: rotate(-45deg) scale(0); opacity: 0; } }

#feedback-msg {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: rgba(211, 47, 47, 0.9); color: white;
    padding: 15px 30px; border-radius: 40px; font-size: 1.8rem; font-weight: 900; 
    z-index: 30; pointer-events: none; white-space: nowrap;
    animation: fadeOut 0.8s forwards;
}
@keyframes fadeOut { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } 10% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.0); } }

/* --- 結果表示 --- */
.result-stats { background: #f1f8e9; padding: 15px; border-radius: 12px; margin-bottom: 15px; text-align: left; }
.res-main { text-align: center; font-size: 1.4rem; font-weight: 900; color: #33691e; margin-bottom: 10px; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.res-row { background: white; padding: 8px; border-radius: 8px; text-align: center; border: 1px solid #dcedc8; }
.res-label { display: block; font-size: 0.75rem; color: #666; }
.res-val { font-size: 1.1rem; font-weight: bold; color: #333; font-family: 'Orbitron', sans-serif; }
.res-desc { font-size: 0.85rem; line-height: 1.5; color: #555; border-top: 1px solid #c5e1a5; padding-top: 8px; }
.btn-sub { flex: 1; padding: 10px; background: white; border: 1px solid #ccc; border-radius: 30px; font-weight: bold; color: #555; cursor: pointer; }