/* --- style.css (v2.1 最適化版) --- */

/* --- 基本設定 --- */
body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: 'Share Tech Mono', 'Roboto Mono', 'Courier New', monospace;
    background-color: #000;
    color: #fff;
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* --- 広告エリア --- */
.anchor-ad {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: #333;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    z-index: 100;
}

/* --- アプリ本体（共通レイアウト） --- */
.app-container {
    display: flex;
    width: 100%;
    height: 100dvh; /* スマホのアドレスバー考慮 */
    padding-bottom: 50px; /* 広告分 */
    box-sizing: border-box;
}

.main-clock {
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 200;
    position: relative;
}

#analog-clock-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    aspect-ratio: 1 / 1;
    z-index: 0;
}

#main-clock-time {
    position: relative;
    z-index: 1;
}

.timer-module {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-color: #555;
    min-height: 0;
}

/* --- タイマー・ボタン・リスト（共通） --- */
.timer-display {
    font-weight: 500;
    user-select: none;
    transition: color 0.3s;
     /* v2.3追加 */
    letter-spacing: 0.12em; 
    margin-right: -0.12em;
    padding-top: 20px;
    padding-bottom: 20px;
    margin-bottom: 0;
}
.timer-display.negative { color: #FF4136; }
.timer-display.settable { 
    cursor: pointer;
    touch-action: none; /* v2.2追加 */
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border: 1px dashed #555;
}
.timer-display.settable:hover { 
    opacity: 0.8;
    background-color: rgba(255, 255, 255, 0.15);
}

#progress-container {
    position: relative;
    width: 90%;
    height: 6px;
    background-color: #222;
    border-radius: 3px;
    margin-bottom: 1.5rem;
    overflow: hidden;
    display: none;
}
#progress-bar {
    width: 100%;
    height: 100%;
    background-color: #2ecc71;
    transition: background-color 0.5s ease;
}
#progress-bar.warning {
    background-color: #e74c3c;
    box-shadow: 0 0 8px #e74c3c;
}
.lap-marker {
    position: absolute;
    top: 0; bottom: 0; width: 2px;
    background-color: #fff;
    z-index: 5;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
    pointer-events: none;
}

.controls {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 90%;
}

.control-btn {
    font-size: 1.2rem;
    padding: 10px 15px;
    margin: 0 3px;
    border: 1px solid #fff;
    background-color: #000;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}
.control-btn:disabled { opacity: 0.3; cursor: default; }

#btn-start { background-color: #1a3a1a; }
#btn-start.running { background-color: #4a1a1a; } /* Stop時は赤く */

#btn-reset { 
    background-color: #333; 
    margin-left: 15px; 
}

.mode-switch {
    display: flex;
    align-items: center;
    margin: 0.5rem 0;
}
.mode-switch span { font-size: 1rem; margin: 0 10px; }
.switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #3f8f3f; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: #cf6679; }
input:checked + .slider:before { transform: translateX(26px); }

.lap-list {
    width: 80%;
    overflow-y: scroll;
    font-size: 1.1rem;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #333;
    scrollbar-width: thin;
    scrollbar-color: #666 #222;
}
.lap-list ul { list-style: none; padding: 0; margin: 0; }
.lap-list li { padding: 2px 5px; display: flex; justify-content: space-between; white-space: nowrap; }
.gap-time { color: #aaa; }

/* スクロールバー装飾 */
.lap-list::-webkit-scrollbar { width: 8px; }
.lap-list::-webkit-scrollbar-track { background: #222; border-radius: 4px; }
.lap-list::-webkit-scrollbar-thumb { background: #666; border-radius: 4px; }
.lap-list::-webkit-scrollbar-thumb:hover { background: #888; }

/* --- 説明セクション --- */
.about-section {
    width: 100%;
    background-color: #111;
    color: #ccc;
    padding: 4rem 1rem 6rem;
    box-sizing: border-box;
    border-top: 1px solid #333;
}
.about-content { max-width: 800px; margin: 0 auto; line-height: 1.8; }
.about-section h2 { font-size: 1.8rem; color: #fff; margin-bottom: 1.5rem; border-bottom: 2px solid #4a4a4a; padding-bottom: 0.5rem; }
.about-section h3 { font-size: 1.4rem; color: #fff; margin-top: 2rem; margin-bottom: 1rem; }
.about-section ul { list-style: disc; padding-left: 1.5rem; margin-bottom: 1.5rem; }
.about-section li { margin-bottom: 0.5rem; }

.footer-links {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid #333;
    text-align: center;
    font-size: 0.9rem;
}
.footer-links a { color: #888; text-decoration: none; margin-left: 1rem; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
.version-info { text-align: right; font-size: 0.8rem; color: #666; margin: 0 0 10px 0; }


/* --- ★レスポンシブ切り替え（ここだけ変える） --- */

/* 縦表示 (Portrait) */
@media (orientation: portrait) {
    .app-container { flex-direction: column; }
    .main-clock {
        font-size: 16vw;
        padding: 10px 0;
        min-height: 200px;
    }
    #analog-clock-canvas {
        height: 100%;
        width: auto;
        max-width: 100%;
    }
    .timer-module {
        padding: 0;
        border-top: 1px solid #555;
    }
    .timer-display {
        font-size: 8vw;
        margin-bottom: 0.5rem;
    }
    .lap-list {
        flex-grow: 1; /* 残りスペースを埋める */
        height: auto;
        max-height: 200px;
    }
}

/* 横表示 (Landscape) */
@media (orientation: landscape) {
    .app-container { flex-direction: row; }
    .main-clock {
        font-size: 20vh;
    }
    #analog-clock-canvas {
        height: min(80vh, 400px);
        width: auto;
    }
    .timer-module {
        padding: 1rem;
        border-left: 1px solid #555;
    }
    .timer-display {
        font-size: 10vh;
        margin-bottom: 1rem;
    }
    .lap-list {
        height: 100px;
        flex-grow: 0;
    }
}

/* --- クリーンモード (HDMI出力用) --- */
body.clean-mode { background-color: #000; overflow: hidden; }
body.clean-mode .anchor-ad,
body.clean-mode .about-section,
body.clean-mode .controls,
body.clean-mode .mode-switch,
body.clean-mode .lap-list,
body.clean-mode .main-clock,
body.clean-mode .footer-links,
body.clean-mode #analog-clock-canvas { display: none !important; }

body.clean-mode .app-container { padding: 0; height: 100vh; justify-content: center; align-items: center; }
body.clean-mode .timer-module { border: none; flex: 1; width: 100%; height: 100%; justify-content: center; padding: 0; }
body.clean-mode .timer-display { font-size: 25vw; margin: 0; }
@media (orientation: landscape) {
    body.clean-mode .timer-display { font-size: 40vh; }
}