/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --dark-bg: #0d0d1a;
    --glow-color: #6699ff;
    --glow-light: rgba(102, 153, 255, 0.6);
    --glow-dim: rgba(102, 153, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --control-bg: rgba(255, 255, 255, 0.1);
    --control-active: rgba(102, 153, 255, 0.3);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#app {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    position: relative;
    overflow: hidden;
}

/* Ambient Glow */
.ambient-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, var(--glow-dim) 0%, transparent 70%);
    filter: blur(100px);
    animation: pulse 4s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    100% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 0.8;
    }
}

.ambient-glow.breathing {
    animation: breathingGlow 8s ease-in-out infinite;
}

@keyframes breathingGlow {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.9;
    }
}

/* Main Container */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 60px 20px;
    position: relative;
    z-index: 1;
}

/* Breathing Circle */
.breathing-circle-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.outer-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px solid;
    pointer-events: none;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ring-1 {
    width: 200px;
    height: 200px;
    border-color: rgba(102, 153, 255, 0.3);
}

.ring-2 {
    width: 240px;
    height: 240px;
    border-color: rgba(102, 153, 255, 0.2);
}

.ring-3 {
    width: 280px;
    height: 280px;
    border-color: rgba(102, 153, 255, 0.1);
}

.breathing-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: radial-gradient(circle at center, var(--glow-light) 0%, var(--glow-dim) 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center;
    position: relative;
}

.breathing-circle:active {
    transform: scale(0.95);
}

.text-guide {
    filter: none;
    -webkit-filter: none;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
    position: relative;
    z-index: 100;
}

.phase-text {
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    transition: opacity 0.3s ease;
    color: #ffffff;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9), 0 0 20px rgba(102, 153, 255, 0.5);
    white-space: pre-line;
    line-height: 1.3;
}

.time-remaining {
    font-size: 16px;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.time-remaining.active {
    opacity: 1;
}

/* Breathing States */
.breathing-circle.inhale {
    animation: inhale var(--cycle-duration, 8s) ease-in-out;
}

.breathing-circle.exhale {
    animation: exhale var(--cycle-duration, 8s) ease-in-out;
}

@keyframes inhale {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(0.6);
    }
}

@keyframes exhale {
    from {
        transform: scale(0.6);
    }

    to {
        transform: scale(1);
    }
}

/* Outer rings breathing effect */
.outer-ring.breathing {
    opacity: 1 !important;
}

.ring-1.breathing {
    animation: ringPulse1 var(--cycle-duration, 8s) ease-in-out infinite;
}

.ring-2.breathing {
    animation: ringPulse2 var(--cycle-duration, 8s) ease-in-out infinite;
}

.ring-3.breathing {
    animation: ringPulse3 var(--cycle-duration, 8s) ease-in-out infinite;
}

@keyframes ringPulse1 {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.3;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
}

@keyframes ringPulse2 {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.2;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.4;
    }
}

@keyframes ringPulse3 {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.1;
    }

    50% {
        transform: scale(1.2);
        opacity: 0.3;
    }
}

/* Controls */
.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.controls.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

.duration-selector {
    display: flex;
    gap: 30px;
}

.duration-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: var(--control-bg);
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.duration-btn:active {
    transform: scale(0.95);
}

.duration-btn.active {
    background: var(--control-active);
    border-color: var(--glow-color);
    box-shadow: 0 0 20px rgba(102, 153, 255, 0.3);
}

.settings-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--control-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.settings-btn:active {
    transform: scale(0.95);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    background: rgba(13, 13, 26, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-panel.active {
    transform: translateY(0);
}

.settings-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
}

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

.settings-header h2 {
    font-size: 24px;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    color: var(--glow-color);
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 16px;
}

.settings-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.setting-group {
    margin-bottom: 32px;
}

.setting-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-control {
    display: flex;
    align-items: center;
    gap: 16px;
}

.setting-control input[type="range"] {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
}

.setting-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--glow-color);
    cursor: pointer;
    box-shadow: 0 0 10px rgba(102, 153, 255, 0.5);
}

.setting-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--glow-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(102, 153, 255, 0.5);
}

.setting-control span {
    min-width: 50px;
    text-align: right;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.feature-status {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 16px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.status-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.status-badge {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 500;
}

.status-badge.supported {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
}

.status-badge.not-supported {
    background: rgba(244, 67, 54, 0.2);
    color: #e57373;
}

/* Responsive */
@media (max-width: 480px) {
    .duration-selector {
        gap: 20px;
    }

    .duration-btn {
        width: 54px;
        height: 54px;
        font-size: 16px;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
    }

    #app {
        height: -webkit-fill-available;
    }
}