/**
 * Tango Puzzle Game - Base Layout & Controls CSS
 * 
 * 機能概要:
 * - ページ全体およびコンテナのレイアウト (body, .container, header)
 * - スコア・タイマー・タイムバーの表示スタイル
 * - ドロップダウン選択、ボタンUIスタイル (select, button, .primary, .accent)
 * - ボトム操作パネルとステータスメッセージ表示 (.bottom-controls, .status)
 * - モバイル向けレスポンシブスタイル (@media)
 */

body {
    font-family: 'Nunito', 'Segoe UI', sans-serif;
    background-color: var(--bg-color);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    touch-action: manipulation;
}

.container {
    background: var(--panel-bg);
    padding: 1.5rem;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    text-align: center;
    max-width: 95vw;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden; /* For time bar */
}

header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 10px;
    position: relative;
    z-index: 2;
}

h1 {
    margin: 0;
    font-weight: 800;
    color: var(--primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.status-panel {
    display: flex;
    gap: 10px;
    align-items: center;
}

.timer {
    font-family: 'Nunito', monospace;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    background: var(--control-border);
    padding: 4px 12px;
    border-radius: 8px;
    min-width: 60px;
}

.score-box {
    font-family: 'Nunito', sans-serif;
    font-size: 1.2rem;
    font-weight: 900;
    color: #fff;
    background: var(--accent);
    padding: 4px 12px;
    border-radius: 8px;
    display: none; /* Hidden in normal mode */
}

.best-score-box {
    font-family: 'Nunito', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    background: var(--control-border);
    padding: 4px 10px;
    border-radius: 8px;
    display: none;
    align-items: center;
    gap: 6px;
}

.best-score-box .reset-best {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
}

.best-score-box .reset-best:hover {
    color: var(--danger);
}

/* Time Bar */
.time-bar-container {
    width: 100%;
    height: 6px;
    background: var(--control-border);
    border-radius: 3px;
    margin-bottom: 1rem;
    overflow: hidden;
    display: none; /* Hidden in normal mode */
}

.time-bar {
    height: 100%;
    background: var(--accent);
    width: 100%;
    transition: width 0.1s linear, background-color 0.3s;
}

.controls {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

select, button {
    padding: 10px 16px;
    border-radius: 12px;
    border: 2px solid var(--control-border);
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    background: var(--control-bg);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

select:hover, button:hover {
    border-color: var(--primary);
}

button.primary {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 6px rgba(108, 92, 231, 0.2);
}

button.primary:active {
    transform: translateY(2px);
    box-shadow: none;
}

button.accent {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 6px rgba(0, 184, 148, 0.2);
}

button.accent:active {
    transform: translateY(2px);
    box-shadow: none;
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
    transform: none;
}

/* ヒントモード有効時のボタン */
button#hint-btn.active {
    background-color: var(--accent);
    color: white;
    border-color: var(--accent);
}

.bottom-controls {
    margin-top: 1rem;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.status {
    margin-top: 0.5rem;
    font-size: 1rem;
    color: var(--text-muted);
    height: 1.5em;
    font-weight: 700;
}

.status.win {
    color: var(--hint-eq);
    animation: bounce 0.5s;
}

.status.gameover {
    color: var(--danger);
    animation: shake 0.4s;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

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

@media (max-width: 600px) {
    html, body {
        height: 100%;
        height: 100dvh;
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
    }
    body {
        justify-content: flex-start;
    }
    .container {
        padding: 0.3rem 0.4rem;
        border-radius: 0;
        height: 100%;
        height: 100dvh;
        max-height: 100dvh;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
        box-shadow: none;
        justify-content: space-between;
        overflow: hidden;
    }
    header {
        margin-bottom: 0.15rem;
        gap: 4px;
        flex-wrap: wrap;
        justify-content: space-between;
        width: 100%;
    }
    h1 {
        font-size: 1.15rem;
    }
    .status-panel {
        gap: 4px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .timer, .score-box, .best-score-box {
        font-size: 0.85rem;
        padding: 2px 6px;
        white-space: nowrap;
    }
    .time-bar-container {
        margin-bottom: 0.2rem;
        height: 4px;
    }
    .controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px;
        width: 100%;
        max-width: 320px;
        margin-bottom: 0.2rem;
    }
    .controls select, .controls button {
        width: 100%;
        padding: 4px 6px;
        font-size: 0.82rem;
        border-radius: 8px;
        text-align: center;
        box-sizing: border-box;
    }
    .bottom-controls {
        margin-top: 0.2rem;
        gap: 8px;
    }
    .bottom-controls button {
        padding: 4px 16px;
        font-size: 0.85rem;
        border-radius: 8px;
    }
    .status {
        margin-top: 0.1rem;
        min-height: 1.5em;
        font-size: 0.82rem;
    }
}

@media (max-height: 750px) {
    .container {
        padding: 0.35rem 0.6rem;
    }
    .controls {
        margin-bottom: 0.3rem;
    }
    .time-bar-container {
        margin-bottom: 0.25rem;
    }
    .bottom-controls {
        margin-top: 0.25rem;
    }
}

