:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --primary-color: #3b82f6;
    --secondary-color: #1e293b;
    --accent-color: #60a5fa;
    --danger-color: #ef4444;
    --ring-bg: #1e293b;
    --ring-active: #3b82f6;
    --font-main: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.5);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 2rem;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

header {
    width: 100%;
    display: flex;
    justify-content: center;
    /* Center the content */
    align-items: center;
    position: relative;
    /* For absolute positioning of the button */
}

h1 {
    font-weight: 700;
    font-size: 3rem;
    /* Bigger font */
    letter-spacing: -0.025em;
    text-align: center;
}

.icon-button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    /* Take out of flow to prevent pushing H1 */
    right: 0;
    /* Position on the right */
    z-index: 1100;
}

.icon-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Timer Display with Ring */
.timer-display-container {
    position: relative;
    width: min(500px, 80vw);
    height: min(500px, 80vw);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem auto;
}

.progress-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
    pointer-events: none;
}

.progress-ring__circle-bg {
    stroke: var(--ring-bg);
}

.progress-ring__circle {
    stroke: var(--ring-active);
    stroke-dasharray: 1445;
    /* 2 * PI * 230 */
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.1s linear;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px var(--primary-color));
}

.timer-display {
    position: absolute;
    text-align: center;
}

.time-text {
    font-family: var(--font-mono);
    font-size: 6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.05em;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.status-text {
    margin-top: 0.5rem;
    font-size: 1rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
}

.status-text.complete {
    font-size: 1.5rem;
    font-weight: 700;
    animation: flash 0.5s infinite;
}

@keyframes flash {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Inputs */
.input-section {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: -1rem;
    /* pull up closer to display when visible */
}

.time-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--secondary-color);
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: var(--shadow-soft);
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-group input {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 1.5rem;
    width: 2.5ch;
    text-align: center;
    outline: none;
}

.input-group input:focus {
    color: var(--primary-color);
}

/* Remove arrows from number input */
.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

.input-group label {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 0.25rem;
}

.separator {
    font-size: 1.5rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 1.25rem;
    /* align correctly with nums */
}

/* Presets */
.presets {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
}

.preset-btn {
    background: var(--secondary-color);
    border: 1px solid transparent;
    color: var(--text-color);
    padding: 0.75rem 1.25rem;
    border-radius: 9999px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #334155;
    transform: translateY(-1px);
}

.preset-btn.active {
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-glow);
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 0.5rem;
    width: 100%;
}

.control-btn {
    padding: 0.75rem 2rem;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 1.125rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    min-width: 100px;
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.control-btn.primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.control-btn.primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.control-btn.secondary {
    background: var(--secondary-color);
    color: var(--text-color);
}

.control-btn.secondary:hover:not(:disabled) {
    background: #334155;
}

.control-btn.destr {
    background: transparent;
    color: #94a3b8;
    border: 1px solid #334155;
}

.control-btn.destr:hover:not(:disabled) {
    color: var(--danger-color);
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.control-btn.stop {
    background: var(--danger-color);
    color: white;
    animation: pulse 1s infinite;
}

.control-btn.stop:hover {
    background: #dc2626;
}

.hidden {
    display: none !important;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Sound Controls */
.sound-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: rgba(30, 41, 59, 0.5);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    margin-top: 0.5rem;
}

#volume-slider {
    -webkit-appearance: none;
    appearance: none;
    width: min(150px, 40vw);
    height: 4px;
    border-radius: 2px;
    background: #475569;
    outline: none;
}

#volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-color);
    cursor: pointer;
}

footer {
    margin-top: auto;
    font-size: 0.875rem;
    color: #64748b;
    text-align: center;
    width: 100%;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .app-container {
        padding: 1rem;
        gap: 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .timer-display-container {
        margin: 0.5rem auto;
    }

    .time-text {
        font-size: clamp(2rem, 12vw, 4rem);
    }

    .status-text {
        font-size: 0.875rem;
    }

    .time-inputs {
        padding: 0.75rem;
        gap: 0.25rem;
    }

    .input-group input {
        font-size: 1.25rem;
        width: 2ch;
    }

    .separator {
        font-size: 1.25rem;
    }

    .presets {
        gap: 0.5rem;
    }

    .preset-btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    .controls {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.75rem;
    }

    .control-btn {
        padding: 0.625rem 1.5rem;
        font-size: 1rem;
        min-width: 90px;
    }

    .sound-controls {
        width: auto;
    }

    footer {
        font-size: 0.75rem;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .time-text {
        font-size: 1.75rem;
    }

    .control-btn {
        padding: 0.5rem 1rem;
        min-width: 80px;
        font-size: 0.875rem;
    }
}

/* Settings Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--secondary-color);
    border-radius: 1rem;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.settings-section {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-section:last-child {
    border-bottom: none;
}

.settings-section h3 {
    font-size: 0.875rem;
    font-weight: 500;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

/* Sound Options */
.sound-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.sound-option {
    background: var(--bg-color);
    border: 2px solid transparent;
    color: var(--text-color);
    padding: 0.625rem 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.sound-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sound-option.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.preview-btn {
    width: 100%;
    background: var(--bg-color);
    border: 1px solid #475569;
    color: var(--text-color);
    padding: 0.625rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.preview-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Custom Audio Upload */
.custom-upload-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-radius: 0.5rem;
}

.custom-upload-section.hidden {
    display: none;
}

.upload-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.upload-btn:hover {
    background: #2563eb;
}

.custom-audio-name {
    font-size: 0.875rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: 2px solid transparent;
    color: var(--text-color);
    padding: 0.75rem;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-option:hover {
    background: rgba(255, 255, 255, 0.05);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: rgba(59, 130, 246, 0.1);
}

.theme-preview {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--preview-bg);
    border: 3px solid var(--preview-accent);
    box-shadow: 0 0 0 2px var(--preview-bg), inset 0 0 8px var(--preview-accent);
}

.theme-option span:last-child {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Color Themes */
[data-theme="ocean"] {
    --bg-color: #0c4a6e;
    --secondary-color: #164e63;
    --primary-color: #06b6d4;
    --accent-color: #22d3ee;
    --ring-bg: #155e75;
    --ring-active: #06b6d4;
}

[data-theme="forest"] {
    --bg-color: #14532d;
    --secondary-color: #166534;
    --primary-color: #22c55e;
    --accent-color: #4ade80;
    --ring-bg: #15803d;
    --ring-active: #22c55e;
}

[data-theme="sunset"] {
    --bg-color: #431407;
    --secondary-color: #7c2d12;
    --primary-color: #f97316;
    --accent-color: #fb923c;
    --ring-bg: #9a3412;
    --ring-active: #f97316;
}

[data-theme="purple"] {
    --bg-color: #2e1065;
    --secondary-color: #3b0764;
    --primary-color: #a855f7;
    --accent-color: #c084fc;
    --ring-bg: #581c87;
    --ring-active: #a855f7;
}

[data-theme="rose"] {
    --bg-color: #4c0519;
    --secondary-color: #881337;
    --primary-color: #f43f5e;
    --accent-color: #fb7185;
    --ring-bg: #9f1239;
    --ring-active: #f43f5e;
}

/* Modal Mobile */
@media (max-width: 600px) {
    .modal-content {
        max-width: 100%;
    }

    .theme-options {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-preview {
        width: 32px;
        height: 32px;
    }
}