/* ========================================
   モダンタイマー - スタイルシート
   シンプル＆スマホ対応バージョン
   ======================================== */

/* CSS変数 */
:root {
    --bg-primary: #0f0f1a;
    --bg-card: rgba(25, 25, 45, 0.95);
    --text-primary: #ffffff;
    --text-secondary: #8888aa;
    --accent-color: #667eea;
    --success-gradient: linear-gradient(90deg, #00f260, #0575e6);
    --warning-gradient: linear-gradient(90deg, #f7971e, #ffd200);
    --danger-gradient: linear-gradient(90deg, #ed213a, #93291e);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --border-radius: 16px;
    --transition-speed: 0.3s;
}

/* リセット */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* ベーススタイル */
body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* アプリコンテナ */
.app-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    position: relative;
}

/* 背景エフェクト - シンプル化 */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at 50% 30%, rgba(102, 126, 234, 0.12) 0%, transparent 60%);
    z-index: -1;
}

.bg-particles {
    display: none;
    /* モバイルでパフォーマンス向上 */
}

/* タイマーカード */
.timer-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius);
    padding: 24px;
    width: 100%;
    max-width: 500px;
}

/* タイトル */
.title {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.title-icon {
    font-size: 1.6rem;
}

/* アプリ説明文 */
.app-description {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    opacity: 0.8;
}

/* デジタル時計 */
.digital-clock-container {
    text-align: center;
    margin-bottom: 20px;
}

/* 現在のセクション表示 */
.current-section {
    min-height: 36px;
    margin-bottom: 8px;
}

.current-section:empty {
    display: none;
}

.current-section .section-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.95rem;
    font-weight: 600;
    animation: sectionPulse 2s ease-in-out infinite;
}

@keyframes sectionPulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.9;
        transform: scale(1.02);
    }
}

.section-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: dotBlink 1s ease-in-out infinite;
}

@keyframes dotBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.digital-clock {
    font-family: Arial, sans-serif;
    font-size: 4rem;
    font-weight: 700;
    letter-spacing: 4px;
    background: var(--success-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.digital-clock.warning {
    background: var(--warning-gradient);
    -webkit-background-clip: text;
    background-clip: text;
}

.digital-clock.danger {
    background: var(--danger-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    animation: clockPulse 0.5s ease-in-out infinite;
}

@keyframes clockPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.clock-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* 次の区切りカウントダウン */
.next-marker-countdown {
    margin-top: 12px;
    min-height: 24px;
}

.next-marker-countdown:empty {
    display: none;
}

.next-marker-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.next-marker-info .next-label {
    color: var(--text-secondary);
}

.next-marker-info .next-name {
    font-weight: 600;
}

.next-marker-info .next-time {
    font-family: 'Orbitron', monospace;
    font-weight: 700;
    font-size: 0.9rem;
}

/* プログレスバー */
.progress-container {
    margin-bottom: 24px;
}

.progress-bar {
    height: 20px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 100%;
    background: var(--success-gradient);
    border-radius: 10px;
    transition: width 0.1s linear, background 0.5s ease;
    position: relative;
}

.progress-fill.warning {
    background: var(--warning-gradient);
}

.progress-fill.danger {
    background: var(--danger-gradient);
}

/* 区切りマーカー表示 */
.progress-markers {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.progress-marker-line {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 2px;
    transform: translateX(-50%);
}

.progress-time-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: 'Orbitron', monospace;
}

/* コントロールボタン */
.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 24px;
}

.btn {
    padding: 14px 12px;
    border: none;
    border-radius: 12px;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1rem;
}

.btn-start {
    background: var(--success-gradient);
    color: white;
}

.btn-pause {
    background: var(--warning-gradient);
    color: white;
}

.btn-reset {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
}

/* シンプルモード切り替えボタン */
.simple-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 16px;
    margin-top: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
}

.simple-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.simple-toggle-icon {
    font-size: 1rem;
}

.simple-toggle-text {
    font-family: 'Noto Sans JP', sans-serif;
}

body.simple-mode .simple-toggle {
    background: rgba(102, 126, 234, 0.2);
    border-color: rgba(102, 126, 234, 0.5);
    color: var(--accent-color);
}

.btn-add {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    font-size: 0.85rem;
}

/* 設定パネル */
.settings-panel,
.markers-panel {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.settings-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.settings-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.setting-row:last-child {
    margin-bottom: 0;
}

.setting-row label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group input[type="number"],
.input-group input[type="text"] {
    width: 70px;
    padding: 10px 8px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: 'Orbitron', monospace;
    font-size: 1rem;
    text-align: center;
}

.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.input-suffix {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* フォント選択 */
.font-select {
    padding: 8px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 160px;
}

.font-select:focus {
    outline: none;
    border-color: var(--accent-color);
}

.font-select option {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* トグルスイッチ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--success-gradient);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(22px);
}

/* マーカー入力 */
.marker-input-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.marker-label-input {
    flex: 1;
    min-width: 100px;
    padding: 10px 12px;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 0.85rem;
}

.marker-label-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

/* カラーパレット */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.color-btn {
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.selected {
    border-color: white;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* マーカーリスト */
.markers-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.marker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
}

.marker-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.marker-color-badge {
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.marker-time {
    font-family: 'Orbitron', monospace;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.marker-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.marker-delete {
    background: transparent;
    border: none;
    color: #ff6b6b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    -webkit-tap-highlight-color: transparent;
}

/* フッター */
.footer {
    margin-top: 16px;
    padding-bottom: 80px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

/* ========================================
   スマホ向けレスポンシブ
   ======================================== */
@media (max-width: 480px) {
    .app-container {
        padding: 12px;
        justify-content: flex-start;
        padding-top: 20px;
    }

    .timer-card {
        padding: 20px 16px;
    }

    .title {
        font-size: 1.2rem;
        margin-bottom: 16px;
    }

    .title-icon {
        font-size: 1.4rem;
    }

    .digital-clock {
        font-size: 3.2rem;
        letter-spacing: 2px;
    }

    .current-section .section-badge {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .progress-bar {
        height: 16px;
    }

    .control-buttons {
        gap: 8px;
    }

    .btn {
        padding: 12px 8px;
        font-size: 0.8rem;
    }

    .btn-icon {
        font-size: 0.9rem;
    }

    .settings-panel,
    .markers-panel {
        padding: 14px;
    }

    .marker-input-row {
        gap: 6px;
    }

    .marker-input-row .input-group {
        flex: 1;
    }

    .marker-input-row .input-group input {
        width: 100%;
    }

    .marker-label-input {
        width: 100%;
        min-width: unset;
    }

    .btn-add {
        width: 100%;
        margin-top: 4px;
    }
}

/* 完了アニメーション */
@keyframes timerComplete {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

.timer-complete {
    animation: timerComplete 0.5s ease-in-out 3;
}

/* ========================================
   シンプルモード（PCでも横向き風表示）
   ======================================== */
body.simple-mode .app-container {
    padding: 16px;
}

body.simple-mode .timer-card {
    background: transparent;
    border: none;
    max-width: 100%;
    width: 100%;
}

body.simple-mode .title,
body.simple-mode .app-description,
body.simple-mode .settings-panel,
body.simple-mode .markers-panel,
body.simple-mode .footer,
body.simple-mode .ad-container {
    display: none;
}

body.simple-mode .digital-clock {
    font-size: 10rem;
    letter-spacing: 10px;
}

body.simple-mode .current-section .section-badge {
    font-size: 1.2rem;
    padding: 8px 20px;
}

body.simple-mode .progress-container {
    max-width: 800px;
    margin: 0 auto 20px;
}

body.simple-mode .progress-bar {
    height: 16px;
}

body.simple-mode .control-buttons {
    justify-content: center;
}

/* シンプルモード時は戻るボタンを右上に固定 */
body.simple-mode .simple-toggle {
    display: flex !important;
    position: fixed;
    top: 16px;
    right: 16px;
    width: auto;
    z-index: 100;
    margin: 0;
    background: rgba(30, 30, 50, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    body.simple-mode .digital-clock {
        font-size: 5rem;
        letter-spacing: 5px;
    }
}

/* 広告スペース */
.ad-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 8px;
    pointer-events: none;
    z-index: 10;
}

.ad-space {
    background: rgba(20, 20, 35, 0.9);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 8px 16px;
    min-width: 320px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.ad-placeholder {
    color: var(--text-secondary);
    font-size: 0.75rem;
    opacity: 0.5;
}

/* ========================================
   スマホ横向き（Landscape）モード
   タイマーをメインに大きく表示
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    body {
        overflow: hidden;
    }

    .app-container {
        padding: 8px 20px;
        justify-content: center;
    }

    .timer-card {
        background: transparent;
        border: none;
        padding: 0;
        max-width: 100%;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    /* タイトル非表示 */
    .title {
        display: none;
    }

    /* デジタル時計をさらに大きく - メイン表示 */
    .digital-clock-container {
        margin-bottom: 8px;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .digital-clock {
        font-size: 6rem;
        letter-spacing: 6px;
        line-height: 1;
    }

    .clock-label {
        display: none;
    }

    /* 現在のセクション - タイマーの上に小さく表示 */
    .current-section {
        order: -1;
        margin-bottom: 4px;
    }

    .current-section .section-badge {
        font-size: 0.85rem;
        padding: 4px 12px;
    }

    .section-dot {
        width: 6px;
        height: 6px;
    }

    /* 次の区切りカウントダウン - 小さく表示 */
    .next-marker-countdown {
        margin-top: 4px;
    }

    .next-marker-info {
        font-size: 0.7rem;
        padding: 3px 10px;
    }

    /* プログレスバー - コンパクトに表示 */
    .progress-container {
        width: 100%;
        max-width: 600px;
        margin-bottom: 8px;
    }

    .progress-bar {
        height: 12px;
    }

    .progress-time-labels {
        font-size: 0.65rem;
        margin-top: 2px;
    }

    /* コントロールボタン - コンパクトに表示 */
    .control-buttons {
        gap: 8px;
        margin-bottom: 0;
    }

    .btn {
        padding: 8px 16px;
        font-size: 0.75rem;
        min-width: 70px;
    }

    .btn-icon {
        font-size: 0.8rem;
    }

    /* 設定パネル・広告・説明文を非表示 */
    .settings-panel,
    .markers-panel,
    .footer,
    .ad-container,
    .app-description {
        display: none;
    }

    /* 背景をシンプルに */
    .bg-gradient {
        background: radial-gradient(ellipse at 50% 50%, rgba(102, 126, 234, 0.08) 0%, transparent 70%);
    }
}