* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
        --bg-1: #0f172a; /* slate-900 */
        --bg-2: #111827; /* gray-900 */
        --accent: #ea384d; /* red modern */
        --accent-2: #6366f1; /* indigo */
        --card: rgba(255, 255, 255, 0.08);
        --card-border: rgba(255, 255, 255, 0.18);
        --text: #e5e7eb; /* gray-200 */
        --muted: #9ca3af; /* gray-400 */
}

body {
    font-family: 'Kanit', 'Noto Sans Thai', 'Zen Maru Gothic', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
        background:
            radial-gradient(1200px 600px at 10% 10%, rgba(99, 102, 241, 0.18), transparent 60%),
            radial-gradient(1000px 500px at 90% 20%, rgba(234, 56, 77, 0.18), transparent 60%),
            linear-gradient(160deg, var(--bg-1), var(--bg-2));
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--text);
        position: relative;
        overflow-x: hidden;
}

#sakuraCanvas {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.container { position: relative; z-index: 1; }

#brandLogo {
        position: fixed;
        top: calc(env(safe-area-inset-top, 0px) + 20px);
        left: 50%;
        transform: translateX(-50%);
        height: clamp(44px, 8vw, 96px);
        width: auto;
        z-index: 2;
        pointer-events: none;
        opacity: 0.9;
    margin-top: 120px; /* default spacing for non-minimal view */
}

.minimal-timer #brandLogo {
    top: clamp(80px, 10vh, 140px); /* keep logo comfortably away from the top edge */
    transform: translateX(-50%) scale(1);
    opacity: 0.85;
    margin-top: 0; /* rely on top only for positioning in minimal mode */
}

@media (max-height: 480px) {
    #brandLogo { top: calc(env(safe-area-inset-top, 0px) + 8px); height: 28px; }
}

#bgVideo {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    object-fit: cover;
    z-index: -1; /* very back */
    opacity: 0;
    transition: opacity 600ms ease;
}

#bgVideo.active { opacity: 1; }

.container {
    background: transparent;
    padding: clamp(14px, 2.8vw, 28px);
    border-radius: 0;
    box-shadow: none;
    max-width: 980px;
    width: min(96%, 980px);
    border: none;
}

/* Omotenashi banner */
.omotenashi-banner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 14px;
    border-radius: 14px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.14);
}
.omote-icon {
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: #ff5a6a;
    box-shadow: 0 0 0 4px rgba(255,90,106,0.15);
}
.omote-texts .jp { font-weight: 800; letter-spacing: 0.06em; }
.omote-texts .en { font-size: 0.9em; color: var(--muted); }
.omote-texts .th { font-size: 0.9em; color: var(--muted); }
.banner-close {
    appearance: none;
    background: transparent;
    border: 0;
    color: #e5e7eb;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 8px;
}
.banner-close:hover { background: rgba(255,255,255,0.06); }

h1 {
    text-align: center;
    margin-bottom: 8px;
    font-size: clamp(3.15rem, 6.75vw + 1.35rem, 5.4rem);
    font-weight: 700;
    color: #e5e7eb;
}

h2 {
    text-align: center;
    color: var(--muted);
    margin-bottom: 12px;
    font-weight: 800;
    font-size: clamp(2.7rem, 6vw + 0.9rem, 4.5rem); /* 1.5x larger than before and larger than h1 */
    color: #ffffff;
}

#activityTitle {
    margin-top: 4px;
    margin-bottom: 6px;
}

/* Finish state styling */
#activityTitle.time-finished {
    /* Toned-down finish style for readability */
    color: #ff4d5d !important;
    -webkit-text-fill-color: #ff4d5d;
    background: none;
    position: relative;
    letter-spacing: 0.02em;
    font-size: clamp(2.4rem,6vw,4.2rem);
    animation: finishedPulse 480ms ease 0s 1;
    text-shadow: 0 2px 4px rgba(0,0,0,0.35);
}
#activityTitle.time-finished::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 0;
    height: 3px;
    border-radius: 3px;
    background: #ff4d5d;
    animation: finishedUnderline 600ms ease forwards;
    box-shadow: 0 2px 6px rgba(255,77,93,0.4);
}

@keyframes finishedPulse {
    0% { transform: scale(1); filter: brightness(1); }
    45% { transform: scale(1.12); filter: brightness(1.3); }
    100% { transform: scale(1); filter: brightness(1); }
}
@keyframes finishedGlow {
    0% { text-shadow: 0 0 6px rgba(255,68,91,0.6), 0 0 18px rgba(255,130,77,0.4); }
    100% { text-shadow: 0 0 14px rgba(255,68,91,0.9), 0 0 36px rgba(255,130,77,0.8); }
}
@keyframes finishedUnderline {
    0% { width: 0; transform: translateX(-50%); }
    55% { width: 78%; transform: translateX(-50%); }
    100% { width: 58%; transform: translateX(-50%); }
}
@keyframes finishedGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Digit finish animations */
.digits-finished .time-unit span:first-child {
    animation: digitsPop 500ms ease;
    color: #fffbfb;
    text-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
@keyframes digitsPop {
    0% { transform: scale(1); filter: brightness(1); }
    40% { transform: scale(1.25); filter: brightness(1.35); }
    100% { transform: scale(1); filter: brightness(1); }
}
@keyframes digitsBreath {
    0% { transform: translateY(0); text-shadow: 0 0 0 rgba(255,255,255,0.0); }
    50% { transform: translateY(-4px); text-shadow: 0 6px 18px rgba(255,255,255,0.35); }
    100% { transform: translateY(0); text-shadow: 0 0 0 rgba(255,255,255,0); }
}

/* Burst particles */
.finish-burst { /* subdued bursts */
    position: fixed;
    top: 50%; left: 50%;
    font-size: clamp(12px,1.2vw,22px);
    pointer-events: none;
    z-index: 9;
    animation: burstFloat 1s ease forwards;
    will-change: transform, opacity;
    mix-blend-mode: normal;
    opacity: 0.85;
    color: #ffb3bb;
    font-weight: 600;
}
@keyframes burstFloat {
    0% { transform: translate(-50%, -50%) scale(0.2) rotate(0deg); opacity: 0; }
    15% { opacity: 1; }
    70% { opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(1) rotate(var(--rot)); opacity: 0; }
}

.activity-selector { margin-bottom: 16px; }

.activity-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.activity-actions { display: flex; justify-content: center; margin-bottom: 12px; }

.activity-btn {
    background: rgba(255,255,255,0.06);
    color: var(--text);
    border: 1px solid rgba(255,255,255,0.14);
    padding: 16px 18px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 1.02em;
    line-height: 1.3;
    text-align: left;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.activity-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
    background: rgba(255,255,255,0.10);
    border-color: rgba(255,255,255,0.25);
}

.activity-btn .duration {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--muted);
}

.timer-section { text-align: center; }

.timer-display {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 8px 0 20px;
    font-size: clamp(3.6rem, 9vw + 0.5rem, 6rem);
    font-weight: 900;
    letter-spacing: 0.01em;
    text-shadow: 0 6px 24px rgba(0,0,0,0.25);
}

.time-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.time-unit span:first-child {
        font-size: 1.6em;
        color: #ffffff;
    font-family: 'Kanit', 'Zen Maru Gothic', 'Noto Sans Thai', sans-serif;
        font-variant-numeric: tabular-nums;
        font-weight: 900;
        -webkit-text-stroke: 0px transparent;
}

.label {
    font-size: 0.38em;
    color: #e5e7eb;
    margin-top: 6px;
}

.separator {
        margin: 0 10px;
        color: #ffffff;
        font-weight: 900;
}

.timer-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 8px 0 8px;
}

.control-btn {
    padding: 10px 22px;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 999px;
    font-size: 1.02em;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.06);
    color: var(--text);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

/* Smaller inline control (e.g., SGD mute) */
.control-btn.tiny {
    padding: 6px 14px;
    font-size: 0.75em;
    line-height: 1.1;
    background: rgba(255,255,255,0.08);
}
.control-btn.icon-only { padding: 10px 14px; font-size: 1.05em; width: 46px; display: inline-flex; align-items: center; justify-content: center; }
.control-btn.tiny.icon-only { padding: 6px 10px; width: 40px; font-size: 0.95em; }
.control-btn.tiny:focus-visible { box-shadow: 0 0 0 3px rgba(234,56,77,0.55); }

#startBtn {
    background: linear-gradient(135deg, #ff445b, #ff6a88);
    color: #fff;
    border-color: transparent;
}

#pauseBtn { background: rgba(99,102,241,0.18); color: #e5e7eb; }

#resetBtn { background: rgba(148,163,184,0.18); color: #e5e7eb; }

#backBtn {
    background: rgba(255,255,255,0.04);
    color: #e5e7eb;
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}

.control-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.2);
}

.control-btn:focus-visible,
.activity-btn:focus-visible {
    outline: 2px solid transparent;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.6);
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 18px; /* more spacing from digits */
    border: 1px solid rgba(255,255,255,0.12);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, rgba(255,106,136,0.9), rgba(99,102,241,0.85));
    width: 0%;
    transition: width 1s ease;
}

/* Digit change animation */
.flip {
    animation: flipScale 180ms ease-in-out;
}

@keyframes flipScale {
    0% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.06); filter: brightness(1.2); }
    100% { transform: scale(1); filter: brightness(1); }
}

@media (max-width: 600px) {
    .timer-display { font-size: 2.4em; }
    .timer-controls { flex-wrap: wrap; }
    .control-btn { padding: 9px 16px; font-size: 0.98em; }
}

/* Height-based tuning to prevent bottom overflow and keep visual center */
@media (max-height: 800px) {
    .minimal-timer .timer-display { font-size: clamp(2.6rem, 8.2vw + 0.4rem, 5rem); }
    body.minimal-timer .container { padding-top: clamp(80px, 10vh, 140px); padding-bottom: clamp(12px, 6vh, 60px); }
}
@media (max-height: 680px) {
    .minimal-timer .timer-display { font-size: clamp(2.2rem, 7.4vw + 0.4rem, 4.4rem); }
    .minimal-timer .label { font-size: 0.34em; }
}
@media (max-height: 560px) {
    .minimal-timer .timer-display { font-size: clamp(1.9rem, 6.6vw + 0.4rem, 4rem); }
    .minimal-timer .separator { margin: 0 8px; }
}
@media (max-height: 460px) {
    .minimal-timer .timer-display { font-size: clamp(1.6rem, 6vw + 0.3rem, 3.4rem); }
    .minimal-timer .label { display: none; }
}

/* Minimal timer mode: hide all text labels and controls, show only digits */
.minimal-timer .omotenashi-banner,
.minimal-timer .omotenashi-banner,
/* Keep labels visible in minimal mode */
/* .minimal-timer .label, */
.minimal-timer .timer-controls,
.minimal-timer .progress-bar { display: none !important; }

/* Re-show SGD mute button in minimal mode when activity active */
/* (Removed) SGD-specific mute button styles */

/* Top audio bar */
.top-audio-bar {
    display: flex;
    justify-content: center; /* center the music toggle */
    gap: 8px;
    margin-bottom: 4px;
    width: 100%;
}
.top-audio-bar .control-btn.icon-only { background: rgba(255,255,255,0.08); }
.minimal-timer .top-audio-bar { display: flex !important; }

/* In minimal mode, add padding-top so headings/content sit below the fixed logo */
body.minimal-timer .container {
    /* Reserve space for fixed logo and keep content vertically comfortable */
    padding-top: clamp(96px, 12vh, 160px);
    padding-bottom: clamp(16px, 8vh, 80px);
}

/* ===== Manage Activities Modal ===== */
#manageModal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 10;
}
#manageModal.open { display: block; }
#manageModal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}
#manageModal .modal-dialog {
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: min(92vw, 720px);
    max-height: 80vh;
    overflow: hidden;
    background: rgba(17, 24, 39, 0.92);
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.4);
}
#manageModal .modal-header, #manageModal .modal-footer {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
#manageModal .modal-header { display: flex; align-items: center; justify-content: space-between; }
#manageModal .modal-header h3 { margin: 0; font-size: 1.2rem; }
#manageModal .modal-close { appearance: none; background: transparent; border: 0; color: #fff; font-size: 1.4rem; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
#manageModal .modal-close:hover { background: rgba(255,255,255,0.08); }
#manageModal .modal-body { padding: 12px 16px; max-height: calc(80vh - 110px); overflow: auto; }

.activity-list { display: grid; gap: 10px; }
.activity-row { display: grid; grid-template-columns: 1fr auto auto auto auto; align-items: center; gap: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.12); border-radius: 12px; padding: 10px; }
.activity-row input[type="text"],
.activity-row input[type="number"] { background: rgba(0,0,0,0.2); color: #fff; border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 8px 10px; }
.activity-row .time-inputs { display: grid; grid-auto-flow: column; gap: 8px; align-items: center; }
.activity-row .delete-btn { appearance: none; border: 1px solid rgba(255,255,255,0.18); color: #fff; background: rgba(255, 71, 87, 0.25); padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.activity-row .delete-btn:hover { background: rgba(255, 71, 87, 0.4); }

#addActivityBtn { margin-top: 8px; }
#saveActivitiesBtn { background: linear-gradient(135deg, #22c55e, #16a34a); color: #fff; border-color: transparent; }

@media (max-width: 640px) {
    .activity-row { grid-template-columns: 1fr; }
    .activity-row .time-inputs { justify-content: start; }
}


/* end */
