/* ========================================
   CSS Reset & Base
   ======================================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #000000;
    color: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ========================================
   Splash Screen
   ======================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-dot {
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.7) 40%, 
        rgba(255, 255, 255, 0.3) 70%, 
        rgba(255, 255, 255, 0) 100%
    );
    border-radius: 50%;
    animation: splash-pulse 2s ease-in-out infinite;
}

@keyframes splash-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ========================================
   Onboarding
   ======================================== */
.onboarding {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
    opacity: 1;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.onboarding.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.onboarding-container {
    width: 100%;
    max-width: 360px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
}

/* Слайды */
.onboarding-slides {
    position: relative;
    width: 100%;
    min-height: 320px;
}

.onboarding-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 24px;
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

.onboarding-slide.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

.onboarding-slide.exit {
    opacity: 0;
    transform: translateX(-30px);
}

/* Иконки слайдов */
.slide-icon {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide-dot {
    width: 32px;
    height: 32px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(255, 255, 255, 0.6) 50%, 
        rgba(255, 255, 255, 0) 100%
    );
    border-radius: 50%;
    animation: slide-dot-glow 3s ease-in-out infinite;
}

@keyframes slide-dot-glow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.9;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

.slide-svg {
    width: 64px;
    height: 64px;
    color: rgba(255, 255, 255, 0.8);
}

.slide-title {
    font-size: 1.75rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: 0.02em;
}

.slide-text {
    font-size: 1rem;
    font-weight: 300;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.6);
}

/* Индикаторы слайдов */
.onboarding-dots {
    display: flex;
    gap: 12px;
}

.onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.2);
    transition: background-color 0.3s, transform 0.3s;
    cursor: pointer;
}

.onboarding-dot.active {
    background-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.2);
}

/* Кнопки онбординга */
.onboarding-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.onboarding-btn {
    flex: 1;
    padding: 14px 24px;
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.onboarding-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.4);
}

.onboarding-btn.primary {
    color: #000000;
    background-color: rgba(255, 255, 255, 0.9);
    border-color: transparent;
}

.onboarding-btn.primary:hover {
    background-color: rgba(255, 255, 255, 1);
}

.onboarding-btn.hidden {
    display: none;
}

/* ========================================
   Screens
   ======================================== */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Ready Screen (Экран ожидания)
   ======================================== */
#ready-screen {
    background-color: #000000;
}

.ready-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
}

.ready-dot {
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.6) 0%, 
        rgba(255, 255, 255, 0.4) 40%, 
        rgba(255, 255, 255, 0.15) 70%, 
        rgba(255, 255, 255, 0) 100%
    );
    border-radius: 50%;
    animation: ready-dot-breathe 4s ease-in-out infinite;
}

@keyframes ready-dot-breathe {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

.start-practice-btn {
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.85);
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-practice-btn:hover {
    color: rgba(255, 255, 255, 1);
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.5);
}

.start-practice-btn:active {
    transform: scale(0.98);
}

.start-practice-btn.fade-out {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
}

/* ========================================
   Sound Toggle (Переключатель звука)
   ======================================== */
.sound-toggle-container {
    margin-top: 8px;
}

.sound-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.5);
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
}

.sound-toggle:hover {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.25);
}

.sound-toggle.active {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.sound-toggle-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sound-toggle-icon svg {
    width: 18px;
    height: 18px;
}

.sound-on-icon {
    display: block;
}

.sound-off-icon {
    display: none;
}

.sound-toggle:not(.active) .sound-on-icon {
    display: none;
}

.sound-toggle:not(.active) .sound-off-icon {
    display: block;
}

.sound-toggle-text {
    letter-spacing: 0.02em;
}

/* ========================================
   Countdown Screen (Обратный отсчёт)
   ======================================== */
#countdown-screen {
    background-color: #000000;
}

.countdown-number {
    font-size: 10rem;
    font-weight: 100;
    color: rgba(255, 255, 255, 0.12);
    font-variant-numeric: tabular-nums;
    line-height: 1;
    opacity: 0;
    transform: scale(0.9);
    animation: countdown-appear 0.9s ease-out forwards;
}

@keyframes countdown-appear {
    0% {
        opacity: 0;
        transform: scale(0.85);
    }
    15% {
        opacity: 1;
        transform: scale(1);
    }
    85% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(1.05);
    }
}

/* ========================================
   Practice Screen
   ======================================== */
#practice-screen {
    background-color: #000000;
    cursor: default;
}

/* ========================================
   The Dot
   ======================================== */
.dot {
    width: 24px;
    height: 24px;
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(255, 255, 255, 0.7) 40%, 
        rgba(255, 255, 255, 0.3) 70%, 
        rgba(255, 255, 255, 0) 100%
    );
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s ease-out, filter 0.3s ease-out, box-shadow 0.3s ease-out;
    will-change: transform, filter, box-shadow;
}

.dot:hover {
    transform: scale(1.1);
}

/* Активное состояние во время сессии */
.dot.active {
    background: radial-gradient(circle, 
        rgba(255, 255, 255, 1) 0%, 
        rgba(255, 255, 255, 0.8) 40%, 
        rgba(255, 255, 255, 0.4) 70%, 
        rgba(255, 255, 255, 0) 100%
    );
}

/* Мощная вспышка при клике */
.dot.flash {
    animation: dot-flash 0.3s ease-out forwards;
}

@keyframes dot-flash {
    0% {
        transform: scale(3.5);
        filter: brightness(5);
        box-shadow: 0 0 40px 15px rgba(255, 255, 255, 0.9);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* ========================================
   Swipe Hint & Progress
   ======================================== */
.swipe-hint {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to right, 
        transparent, 
        rgba(255, 255, 255, 0.3), 
        transparent
    );
    opacity: 0;
    transform: scaleX(0);
    transition: opacity 0.2s, transform 0.2s;
}

.swipe-hint.visible {
    opacity: 1;
    transform: scaleX(1);
}

.swipe-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.8);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.05s linear;
    pointer-events: none;
    z-index: 100;
}

/* ========================================
   Stats Screen
   ======================================== */
#stats-screen {
    background-color: #000000;
    padding: 24px;
    overflow-y: auto;
}

.stats-container {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 40px;
}

.stats-title {
    font-size: 1.5rem;
    font-weight: 300;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.02em;
}

.session-status {
    text-align: center;
    font-size: 0.875rem;
    padding: 8px 16px;
    border-radius: 4px;
    display: none;
}

.session-status.interrupted {
    display: block;
    background-color: rgba(255, 100, 100, 0.15);
    color: rgba(255, 150, 150, 0.9);
    border: 1px solid rgba(255, 100, 100, 0.3);
}

.session-status.completed {
    display: block;
    background-color: rgba(100, 255, 150, 0.1);
    color: rgba(150, 255, 180, 0.9);
    border: 1px solid rgba(100, 255, 150, 0.2);
}

.stats-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stats-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.5);
}

.stats-value {
    font-size: 2rem;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.95);
}

/* Intervals List */
.intervals-block {
    max-height: 200px;
    overflow: hidden;
}

.intervals-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 140px;
    overflow-y: auto;
    padding-right: 8px;
}

.intervals-list::-webkit-scrollbar,
.history-list::-webkit-scrollbar {
    width: 4px;
}

.intervals-list::-webkit-scrollbar-track,
.history-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
}

.intervals-list::-webkit-scrollbar-thumb,
.history-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

.intervals-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    font-size: 0.875rem;
}

.intervals-list li .interval-number {
    color: rgba(255, 255, 255, 0.4);
}

.intervals-list li .interval-time {
    color: rgba(255, 255, 255, 0.8);
    font-variant-numeric: tabular-nums;
}

.intervals-list .empty-message,
.history-list .empty-message {
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
    text-align: center;
    padding: 16px;
}

/* ========================================
   Tabs
   ======================================== */
.tabs {
    display: flex;
    gap: 8px;
    padding: 4px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:hover {
    color: rgba(255, 255, 255, 0.7);
}

.tab.active {
    color: #000000;
    background-color: rgba(255, 255, 255, 0.9);
}

/* ========================================
   History Block
   ======================================== */
.history-block {
    max-height: 400px;
}

.history-block.hidden {
    display: none;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 340px;
    overflow-y: auto;
    padding-right: 8px;
}

.history-item {
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
    transition: border-color 0.2s;
}

.history-item:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.history-item-header:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.history-item-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.history-item-date {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.history-item-summary {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.85);
    font-variant-numeric: tabular-nums;
}

.history-item-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-item-status {
    font-size: 0.625rem;
    padding: 3px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-item-status.completed {
    background-color: rgba(100, 255, 150, 0.15);
    color: rgba(150, 255, 180, 0.9);
}

.history-item-status.interrupted {
    background-color: rgba(255, 100, 100, 0.15);
    color: rgba(255, 150, 150, 0.9);
}

.history-item-arrow {
    width: 16px;
    height: 16px;
    color: rgba(255, 255, 255, 0.3);
    transition: transform 0.3s ease, color 0.2s;
}

.history-item.expanded .history-item-arrow {
    transform: rotate(180deg);
    color: rgba(255, 255, 255, 0.6);
}

.history-item-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
    background-color: rgba(0, 0, 0, 0.3);
}

.history-item.expanded .history-item-details {
    max-height: 300px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.history-intervals-title {
    font-size: 0.625rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 8px;
}

.history-intervals-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.history-interval-item {
    padding: 4px 10px;
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.7);
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.history-no-intervals {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.3);
    font-style: italic;
}

/* ========================================
   Restart Button
   ======================================== */
.restart-btn {
    margin-top: 8px;
    padding: 16px 32px;
    font-size: 1rem;
    font-weight: 400;
    color: #000000;
    background-color: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.restart-btn:hover {
    background-color: rgba(255, 255, 255, 1);
}

.restart-btn:active {
    transform: scale(0.98);
}

/* ========================================
   Author Block
   ======================================== */
.author-block {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    text-align: center;
}

.author-name {
    font-size: 0.8125rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 16px;
    letter-spacing: 0.02em;
}

.author-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

/* Базовые стили для кнопок автора */
.author-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 0.75rem;
    font-weight: 400;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.author-link svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.share-btn {
    font-family: inherit;
}

/* ========================================
   Цветные кнопки автора
   ======================================== */

/* Телеграм канал — пастельно-голубой */
.link-telegram {
    color: #74b9ff;
    background-color: rgba(116, 185, 255, 0.08);
    border: 1px solid rgba(116, 185, 255, 0.25);
}

.link-telegram:hover {
    color: #74b9ff;
    background-color: rgba(116, 185, 255, 0.15);
    border-color: rgba(116, 185, 255, 0.4);
}

.link-telegram svg {
    fill: #74b9ff;
}

/* Угостить мою музу — нежно-розовый/персиковый */
.link-donate {
    color: #ffb8b8;
    background-color: rgba(255, 184, 184, 0.08);
    border: 1px solid rgba(255, 184, 184, 0.25);
}

.link-donate:hover {
    color: #ffb8b8;
    background-color: rgba(255, 184, 184, 0.15);
    border-color: rgba(255, 184, 184, 0.4);
}

.link-donate svg {
    fill: #ffb8b8;
}

/* Отзыв — мятный */
.link-feedback {
    color: #55efc4;
    background-color: rgba(85, 239, 196, 0.08);
    border: 1px solid rgba(85, 239, 196, 0.25);
}

.link-feedback:hover {
    color: #55efc4;
    background-color: rgba(85, 239, 196, 0.15);
    border-color: rgba(85, 239, 196, 0.4);
}

.link-feedback svg {
    fill: #55efc4;
}

/* Поделиться — светло-фиолетовый */
.link-share {
    color: #a29bfe;
    background-color: rgba(162, 155, 254, 0.08);
    border: 1px solid rgba(162, 155, 254, 0.25);
}

.link-share:hover {
    color: #a29bfe;
    background-color: rgba(162, 155, 254, 0.15);
    border-color: rgba(162, 155, 254, 0.4);
}

.link-share svg {
    fill: #a29bfe;
}

/* ========================================
   Utilities
   ======================================== */
.hidden {
    display: none !important;
}

/* ========================================
   Safe Area
   ======================================== */
@supports (padding-top: env(safe-area-inset-top)) {
    #stats-screen {
        padding-top: calc(24px + env(safe-area-inset-top));
        padding-bottom: calc(24px + env(safe-area-inset-bottom));
    }
    
    .onboarding-container {
        padding-top: calc(40px + env(safe-area-inset-top));
        padding-bottom: calc(40px + env(safe-area-inset-bottom));
    }
}

/* ========================================
   Achievement Styles (Геймификация)
   ======================================== */
.interval-time.achievement {
    color: #ffb347;
}

.history-interval-item.achievement {
    color: #ffb347;
    background-color: rgba(255, 179, 71, 0.1);
    border: 1px solid rgba(255, 179, 71, 0.2);
}

/* ========================================
   Toast Notifications
   ======================================== */
.toast-container {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    background-color: rgba(40, 40, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(20px);
    animation: toast-in 0.3s ease forwards;
    pointer-events: auto;
}

.toast.hiding {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.toast-icon.success {
    color: #55efc4;
}

.toast-icon.error {
    color: #ff7675;
}

.toast-icon.info {
    color: #74b9ff;
}

.toast-message {
    font-size: 0.875rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
}

/* Safe area для toast */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .toast-container {
        bottom: calc(40px + env(safe-area-inset-bottom));
    }
}
