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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f172a;
    color: #ffffff;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color-scheme: dark;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
}

#app {
    width: 100%;
    max-width: 400px;
    min-height: 100vh;
    background: #0f172a;
    position: relative;
    overflow: hidden;
}

.auth-container {
    padding: 60px 30px;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.auth-container.hidden {
    display: none;
}

/* Скрываем форму авторизации по умолчанию для всех, пока JS не решит, что показать */
#auth {
    display: none;
}

/* Если JS добавил класс show-auth, показываем (для браузера без токена) */
#auth.show-auth {
    display: block;
}

.auth-container h1 {
    margin-bottom: 40px;
    font-size: 2.5em;
    font-weight: 900;
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-tabs {
    position: relative;
    display: flex;
    margin-bottom: 30px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px;
    z-index: 1;
}

.tab-slider {
    position: absolute;
    top: 6px;
    left: 6px;
    width: calc(50% - 6px);
    height: calc(100% - 12px);
    background: #3a7bd5;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(58, 123, 213, 0.4);
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    z-index: -1;
}

.auth-tabs button {
    flex: 1;
    position: relative;
    padding: 12px;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2;
}

.auth-tabs button:hover {
    transform: scale(1.05) rotate(-1deg);
    color: #ffffff;
}

.auth-tabs button.active {
    background: transparent;
    color: #ffffff;
    box-shadow: none;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#auth-form input {
    padding: 18px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.03);
    color: #ffffff;
    font-size: 16px;
    transition: all 0.3s;
    appearance: none;
    -webkit-appearance: none;
}

#auth-form input:focus {
    background: rgba(255, 255, 255, 0.07);
    border-color: #3a7bd5;
    outline: none;
    box-shadow: 0 0 0 4px rgba(58, 123, 213, 0.1);
}

#auth-form button {
    padding: 18px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    color: #ffffff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 8px 20px rgba(58, 123, 213, 0.3);
}

#auth-form button:hover {
    transform: translateY(-2px) scale(1.05) rotate(2deg);
    box-shadow: 0 12px 25px rgba(58, 123, 213, 0.4);
}

.auth-message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 600;
    background: rgba(255, 71, 87, 0.1);
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.2);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0f172a;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.start-screen-container {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
}

.start-screen-text {
    color: #ffffff;
    font-size: 1.8em;
    font-weight: 900;
    letter-spacing: -0.5px;
    animation: fadeInDown 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.start-screen-btn {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.32, 0.72, 0, 1);
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    border-radius: 50px;
    box-shadow: 0 20px 40px rgba(58, 123, 213, 0.3);
    animation: fadeInUp 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.start-screen-btn:hover {
    transform: scale(1.1) rotate(5deg);
    border-radius: 40px;
}

.play-icon {
    width: 0;
    height: 0;
    border-left: 50px solid #ffffff;
    border-top: 30px solid transparent;
    border-bottom: 30px solid transparent;
    margin-left: 12px;
}

.main-header {
    padding: 40px 20px 20px;
    text-align: center;
}

/* Настройка заголовка для Telegram: скрываем его везде, так как он есть в системной панели */
body.tg-app .main-header,
body.tg-app .auth-container h1 {
    display: none;
}

#card-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: calc(100vh - 120px); /* Увеличили область, так как нет заголовка */
    padding: 20px;
}

body.tg-app #card-container {
    height: 100vh; /* В Telegram карточка занимает весь экран */
    padding-top: 20px;
}

.track-card {
    width: 100%;
    max-width: 340px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 32px;
    padding: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.album-cover {
    width: 100%;
    aspect-ratio: 1;
    margin-bottom: 25px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.track-info h2 {
    font-size: 1.6em;
    margin-bottom: 8px;
    font-weight: 800;
}

.track-info p {
    color: #94a3b8;
    font-size: 1.1em;
    font-weight: 500;
}

.controls {
    margin-top: 25px;
}

#play-pause-btn {
    width: 70px;
    height: 70px;
    background: #ffffff;
    color: #0f172a;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

#play-pause-btn:hover {
    transform: scale(1.1) rotate(-3deg);
}

#play-pause-btn svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(calc(100% - 70px));
    width: 100%;
    max-width: 400px;
    background: #1e293b;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 40px 40px 0 0;
    padding: 0 20px 40px;
    z-index: 2000;
    transition: transform 0.6s cubic-bezier(0.32, 0.72, 0, 1);
}

.bottom-sheet.open {
    transform: translateX(-50%) translateY(0);
}

.sheet-handle {
    width: 50px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin: 20px auto 30px;
}

.sheet-content {
    display: flex;
    flex-direction: column;
    gap: 15px; 
}

.sheet-btn {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    width: 100%;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.03);
    color: #ffffff;
    font-size: 1.1em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.sheet-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: scale(1.03) rotate(-1deg);
}

.sheet-btn.logout {
    color: #ff4757;
}

.btn-icon-svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    backdrop-filter: blur(4px);
    transition: opacity 0.4s;
}

.modal {
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #1e293b;
    padding: 30px 25px;
    border-radius: 32px;
    width: 90%;
    max-width: 360px; 
    max-height: 80vh;
    overflow-y: auto;
    color: #ffffff;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.modal-content::-webkit-scrollbar {
    width: 12px; 
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.modal-content::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    background-clip: padding-box; 
    border: 4px solid transparent; 
    border-radius: 10px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.close {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #94a3b8;
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #ffffff;
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
    font-weight: 900;
}

.preference-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.preference-item div {
    flex: 1;
    padding-right: 15px;
}

.preference-item strong {
    display: block;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.preference-item a {
    color: #3a7bd5;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
}

.preference-item button {
    background: rgba(255, 71, 87, 0.1);
    color: #ff4757;
    border: none;
    padding: 10px 16px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.preference-item button:hover {
    background: rgba(255, 71, 87, 0.2);
    transform: scale(1.1) rotate(3deg);
}

#reload-offline-btn {
    transition: all 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}

#reload-offline-btn:hover {
    transform: scale(1.1) rotate(-2deg);
    box-shadow: 0 15px 30px rgba(58, 123, 213, 0.4);
}

.hidden {
    display: none !important;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(60px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-80px); }
    to { opacity: 1; transform: translateY(0); }
}
