/* ============================================
   深海テーマ + 泡アニメーション
   ============================================ */
html, body {
    height: 100%;
}
body {
    font-family: 'Noto Sans JP', 'Segoe UI', 'Meiryo', sans-serif;
    color: #e6f4f8;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    background: linear-gradient(
        180deg,
        #051c2c 0%,
        #062b45 25%,
        #073858 55%,
        #03101c 100%
    );
    background-attachment: fixed;
}

/* 海面側からのほのかな光（光芒） */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 20% -10%, rgba(120, 200, 230, 0.18), transparent 55%),
        radial-gradient(ellipse at 80% -10%, rgba(80, 160, 210, 0.12), transparent 60%);
    z-index: 0;
}
/* 水底の暗がり */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(circle at 50% 120%, rgba(0, 30, 50, 0.65), transparent 60%);
    z-index: 0;
}

/* --- 泡アニメーション --- */
.bubbles {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.bubbles span {
    position: absolute;
    bottom: -80px;
    display: block;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle at 30% 30%,
        rgba(255, 255, 255, 0.85),
        rgba(180, 230, 245, 0.35) 40%,
        rgba(120, 200, 230, 0.05) 70%,
        transparent 100%);
    border-radius: 50%;
    box-shadow: inset 0 0 6px rgba(255, 255, 255, 0.4);
    opacity: 0;
    animation: bubble-rise linear infinite;
}
@keyframes bubble-rise {
    0%   { transform: translateY(0) translateX(0) scale(0.8); opacity: 0; }
    10%  { opacity: 0.9; }
    50%  { transform: translateY(-50vh) translateX(20px) scale(1); }
    100% { transform: translateY(-110vh) translateX(-15px) scale(1.1); opacity: 0; }
}
.bubbles span:nth-child(1)  { left:  4%; width: 14px; height: 14px; animation-duration: 12s; animation-delay:  0s; }
.bubbles span:nth-child(2)  { left: 11%; width: 22px; height: 22px; animation-duration: 16s; animation-delay:  3s; }
.bubbles span:nth-child(3)  { left: 18%; width:  8px; height:  8px; animation-duration:  9s; animation-delay:  1s; }
.bubbles span:nth-child(4)  { left: 26%; width: 28px; height: 28px; animation-duration: 18s; animation-delay:  6s; }
.bubbles span:nth-child(5)  { left: 33%; width: 12px; height: 12px; animation-duration: 11s; animation-delay:  2s; }
.bubbles span:nth-child(6)  { left: 41%; width: 18px; height: 18px; animation-duration: 14s; animation-delay:  5s; }
.bubbles span:nth-child(7)  { left: 49%; width: 10px; height: 10px; animation-duration: 10s; animation-delay:  0.5s; }
.bubbles span:nth-child(8)  { left: 56%; width: 24px; height: 24px; animation-duration: 17s; animation-delay:  4s; }
.bubbles span:nth-child(9)  { left: 64%; width: 16px; height: 16px; animation-duration: 13s; animation-delay:  7s; }
.bubbles span:nth-child(10) { left: 71%; width:  9px; height:  9px; animation-duration:  9.5s; animation-delay:  1.5s; }
.bubbles span:nth-child(11) { left: 78%; width: 26px; height: 26px; animation-duration: 19s; animation-delay:  8s; }
.bubbles span:nth-child(12) { left: 86%; width: 13px; height: 13px; animation-duration: 12.5s; animation-delay:  2.5s; }
.bubbles span:nth-child(13) { left: 93%; width: 11px; height: 11px; animation-duration: 11s; animation-delay:  9s; }
.bubbles span:nth-child(14) { left: 47%; width: 30px; height: 30px; animation-duration: 21s; animation-delay: 10s; }
.bubbles span:nth-child(15) { left: 73%; width: 15px; height: 15px; animation-duration: 14.5s; animation-delay:  6.5s; }
.bubbles span:nth-child(16) { left:  8%; width: 10px; height: 10px; animation-duration: 13s; animation-delay: 11s; }
.bubbles span:nth-child(17) { left: 30%; width: 17px; height: 17px; animation-duration: 15s; animation-delay:  4.5s; }
.bubbles span:nth-child(18) { left: 60%; width: 12px; height: 12px; animation-duration: 11.5s; animation-delay:  3.5s; }
.bubbles span:nth-child(19) { left: 82%; width: 20px; height: 20px; animation-duration: 16.5s; animation-delay:  7.5s; }
.bubbles span:nth-child(20) { left: 22%; width: 14px; height: 14px; animation-duration: 13s; animation-delay:  8.5s; }

@media (prefers-reduced-motion: reduce) {
    .bubbles span { animation: none; opacity: 0; }
}

/* --- メインコンテナ（深海ガラス） --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 420px;
    margin: 60px auto;
    padding: 36px 28px;
    text-align: center;
    background: rgba(8, 30, 48, 0.45);
    backdrop-filter: blur(16px) saturate(140%);
    -webkit-backdrop-filter: blur(16px) saturate(140%);
    border: 1px solid rgba(140, 220, 240, 0.18);
    border-radius: 18px;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(80, 180, 220, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.container > * {
    position: relative;
    z-index: 1;
}

/* --- タイトル --- */
h1 {
    font-family: 'Fredoka', 'Zen Maru Gothic', 'Noto Sans JP', sans-serif;
    font-size: 2.3em;
    font-weight: 600;
    margin: 0 0 4px;
    letter-spacing: 0.05em;
    color: #cfeef7;
    text-shadow:
        0 0 14px rgba(120, 220, 240, 0.55),
        0 0 28px rgba(80, 180, 220, 0.35);
}
.version {
    font-size: 0.75em;
    color: #7fb3c2;
    letter-spacing: 0.1em;
    margin-bottom: 22px;
    opacity: 0.85;
}

/* --- JST 時刻 --- */
#jst-time {
    font-size: 1em;
    margin-bottom: 18px;
    color: #9fcfdc;
    letter-spacing: 0.05em;
}

/* --- 上段タイマー枠（未使用領域だが保持） --- */
.timer {
    font-size: 2.4em;
    margin-bottom: 16px;
    color: #aef0ff;
    letter-spacing: 0.04em;
    font-family: 'Noto Sans Mono', 'Consolas', 'Menlo', monospace;
    text-shadow: 0 0 12px rgba(120, 220, 240, 0.45);
}

/* --- カウントダウンエリア --- */
#countdown-timer {
    margin-bottom: 24px;
    padding: 20px 12px;
    background: rgba(4, 22, 36, 0.55);
    border: 1px solid rgba(140, 220, 240, 0.12);
    border-radius: 14px;
    box-shadow:
        inset 0 0 30px rgba(0, 30, 50, 0.5),
        0 1px 8px rgba(0, 0, 0, 0.3);
}

#countdown-timer button {
    margin: 4px;
    padding: 9px 20px;
    font-size: 1.02em;
    border: 1px solid rgba(140, 220, 240, 0.3);
    border-radius: 999px;
    background: rgba(20, 70, 100, 0.45);
    color: #e6f4f8;
    cursor: pointer;
    letter-spacing: 0.06em;
    transition: background 0.25s ease, box-shadow 0.25s ease, transform 0.15s ease;
    font-family: 'Noto Sans JP', 'Segoe UI', 'Meiryo', sans-serif;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
#countdown-timer button:hover {
    background: rgba(60, 140, 180, 0.55);
    box-shadow: 0 0 14px rgba(120, 220, 240, 0.4);
}
#countdown-timer button:active {
    transform: scale(0.97);
}

#countdown-timer input {
    font-size: 1.05em;
    padding: 7px 6px;
    border: 1px solid rgba(140, 220, 240, 0.25);
    border-radius: 8px;
    margin-right: 6px;
    text-align: right;
    background: rgba(4, 22, 36, 0.65);
    color: #e6f4f8;
    font-family: 'Noto Sans Mono', 'Consolas', 'Menlo', monospace;
}
#countdown-timer input:focus {
    outline: none;
    border-color: rgba(140, 220, 240, 0.55);
    box-shadow: 0 0 10px rgba(120, 220, 240, 0.3);
}

#countdown-display {
    color: #aef0ff;
    font-family: 'Noto Sans Mono', 'Consolas', 'Menlo', monospace;
    letter-spacing: 0.04em;
    text-shadow:
        0 0 12px rgba(120, 220, 240, 0.55),
        0 0 28px rgba(80, 180, 220, 0.3);
}

/* --- アラーム停止ボタン --- */
#play-sound-btn {
    background: rgba(255, 220, 100, 0.95) !important;
    color: #052032 !important;
    font-size: 1.2em !important;
    font-weight: bold;
    border: 2px solid rgba(255, 230, 0, 0.85);
    box-shadow: 0 0 18px rgba(255, 230, 0, 0.55);
    padding: 13px 32px;
    margin: 8px 0;
    border-radius: 999px;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
#play-sound-btn:hover {
    background: rgba(255, 240, 130, 1) !important;
    color: #000 !important;
    box-shadow: 0 0 26px rgba(255, 230, 0, 0.85);
}

/* --- イヤホンモードトグル --- */
#earphone-mode-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
    padding: 8px 0;
}
#earphone-mode-label {
    font-size: 0.92em;
    color: #9fcfdc;
    user-select: none;
    letter-spacing: 0.04em;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.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(20, 50, 70, 0.8);
    border: 1px solid rgba(140, 220, 240, 0.2);
    border-radius: 26px;
    transition: background 0.3s, box-shadow 0.3s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    bottom: 2px;
    background: #cfeef7;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 0 6px rgba(120, 220, 240, 0.5);
}
.toggle-switch input:checked + .toggle-slider {
    background: rgba(80, 180, 220, 0.65);
    box-shadow: 0 0 12px rgba(120, 220, 240, 0.5);
}
.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* --- Wake Lock 状態表示 --- */
#wakelock-status {
    color: #7fb3c2;
    letter-spacing: 0.04em;
}

/* --- 旧 .buttons（互換用） --- */
.buttons button {
    font-size: 1em;
    padding: 10px 24px;
    margin: 0 8px;
    border: 1px solid rgba(140, 220, 240, 0.3);
    border-radius: 999px;
    background: rgba(20, 70, 100, 0.45);
    color: #e6f4f8;
    cursor: pointer;
    transition: background 0.2s;
}
.buttons button:hover {
    background: rgba(60, 140, 180, 0.55);
}

/* ============================================
   ユーザー設定プリセット
   ============================================ */
#preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 10px;
}
.preset-item {
    display: inline-flex;
    align-items: center;
}
#countdown-timer .preset-item button {
    margin: 0;
}
#countdown-timer .preset-item .preset-delete {
    margin-left: -6px;
    padding: 9px 11px;
    font-size: 0.9em;
    line-height: 1;
    color: #ffd0d0;
    border-color: rgba(255, 140, 140, 0.45);
    background: rgba(120, 30, 40, 0.5);
}
#countdown-timer .preset-item .preset-delete:hover {
    background: rgba(180, 50, 60, 0.7);
    box-shadow: 0 0 12px rgba(255, 120, 120, 0.4);
}
#preset-empty {
    font-size: 0.9em;
    color: #8fb4c6;
}
#preset-tools {
    margin-top: 6px;
}
#countdown-timer #preset-tools button {
    font-size: 0.88em;
    padding: 6px 14px;
}
#preset-message {
    min-height: 1.2em;
    margin-top: 6px;
    font-size: 0.85em;
    color: #ffb74d;
}

/* ============================================
   ミニタイマー表示中のトップバー
   ============================================ */
#top-bar {
    display: none;
    position: fixed;
    inset: 0;
    /* ウィンドウが縮まないとき（最大化中など）もバーの見た目を保つ */
    max-height: 72px;
    z-index: 100;
    align-items: center;
    justify-content: center;
    gap: 14px;
    cursor: pointer;
    overflow: hidden;
    background: linear-gradient(
        100deg,
        #03141f 0%,
        #0a3f63 28%,
        #14719e 50%,
        #0a3f63 72%,
        #03141f 100%
    );
    background-size: 220% 100%;
    animation: bar-sheen 9s linear infinite;
    box-shadow:
        inset 0 -14px 34px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(180, 235, 255, 0.28),
        0 0 26px rgba(80, 200, 240, 0.25);
}
@keyframes bar-sheen {
    from { background-position: 0% 0; }
    to   { background-position: -220% 0; }
}
/* 下端の発光ライン */
#top-bar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent, rgba(120, 225, 255, 0.9), rgba(160, 240, 255, 1), rgba(120, 225, 255, 0.9), transparent);
    filter: blur(0.4px);
}
#top-bar .bar-icon {
    width: clamp(22px, 52%, 34px);
    height: auto;
    aspect-ratio: 1;
    border-radius: 8px;
    box-shadow: 0 0 14px rgba(120, 220, 255, 0.45);
}
#top-bar .bar-title {
    font-family: 'Fredoka', 'Zen Maru Gothic', 'Noto Sans JP', 'Segoe UI', sans-serif;
    font-size: clamp(17px, 5vh, 30px);
    font-weight: 600;
    letter-spacing: 0.14em;
    white-space: nowrap;
    background: linear-gradient(90deg, #a8ecff 0%, #ffffff 45%, #7fd0ff 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 10px rgba(120, 220, 255, 0.6));
}
#top-bar .bar-hint {
    position: absolute;
    right: 16px;
    font-size: 11px;
    letter-spacing: 0.06em;
    color: rgba(200, 235, 250, 0.45);
    white-space: nowrap;
}
#top-bar:hover .bar-hint {
    color: rgba(220, 245, 255, 0.85);
}

/* バー表示中は本体のUIを丸ごと隠す */
body.compact {
    overflow: hidden;
}
body.compact .container,
body.compact .bubbles {
    display: none !important;
}
body.compact #top-bar {
    display: flex;
}
/* 幅が狭いときはヒントを省いてタイトルを優先 */
@media (max-width: 560px) {
    #top-bar .bar-hint { display: none; }
}

/* 点滅（黄色）の瞬間は文字を濃色にして視認性を確保 */
body.flash-on #countdown-display {
    color: #2b2600;
    text-shadow: none;
}
body.flash-on #countdown-timer button {
    color: #221f06;
    border-color: rgba(0, 0, 0, 0.3);
}
body.flash-on #preset-empty,
body.flash-on #earphone-mode-label {
    color: #3a3410 !important;
}

#top-bar .bar-warn {
    display: none;
    position: absolute;
    right: 16px;
    font-size: 11px;
    letter-spacing: 0.04em;
    color: #ffd08a;
    white-space: nowrap;
}
@media (max-width: 560px) {
    #top-bar .bar-warn { display: none !important; }
}
