/* ===================================================
   SPACE ACADEMY - Complete CSS
   Dark space theme for Telegram Mini Game
   =================================================== */

/* ---------- CSS VARIABLES ---------- */
:root {
    --bg-primary: #0a0e27;
    --bg-card: #1a1f3a;
    --bg-card-hover: #242a4a;
    --bg-input: #151a33;
    --accent: #FF6B6B;
    --accent-dark: #cc5555;
    --success: #4ECDC4;
    --success-dark: #3ba89f;
    --warning: #FFE66D;
    --warning-dark: #d4bf3c;
    --text: #ffffff;
    --text-muted: #8892b0;
    --text-dim: #5a6480;
    --border: rgba(255, 255, 255, 0.08);
    --glow-accent: rgba(255, 107, 107, 0.3);
    --glow-success: rgba(78, 205, 196, 0.3);
    --glow-warning: rgba(255, 230, 109, 0.3);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tab-height: 64px;
}

/* ---------- RESET & BASE ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ---------- STARS BACKGROUND ---------- */
.stars-bg {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.stars-bg::before,
.stars-bg::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: transparent;
}

.stars-bg::before {
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(1px 1px at 30% 60%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 50% 10%, rgba(255,255,255,0.9) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 40%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 80%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 15% 85%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 45% 50%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 85% 55%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 25% 35%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 75%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 5% 45%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 65% 90%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(1px 1px at 35% 5%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 95% 25%, rgba(255,255,255,0.6) 0%, transparent 100%);
    animation: starsTwinkle 4s ease-in-out infinite alternate;
}

.stars-bg::after {
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 40% 70%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 80% 50%, rgba(255,255,255,0.9) 0%, transparent 100%),
        radial-gradient(1px 1px at 8% 65%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 48% 92%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 72% 8%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(1px 1px at 88% 38%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 18% 58%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 58% 42%, rgba(255,255,255,0.6) 0%, transparent 100%);
    animation: starsTwinkle 5s ease-in-out 1s infinite alternate-reverse;
}

@keyframes starsTwinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* ---------- SCREENS ---------- */
.screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.screen.active {
    display: flex;
}

.screen-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 16px calc(var(--tab-height) + var(--safe-bottom) + 16px);
    -webkit-overflow-scrolling: touch;
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
}

/* Screen transitions */
.screen.slide-in-right {
    display: flex;
    animation: slideInRight 0.3s ease forwards;
}
.screen.slide-out-left {
    display: flex;
    animation: slideOutLeft 0.3s ease forwards;
}
.screen.slide-in-left {
    display: flex;
    animation: slideInLeft 0.3s ease forwards;
}
.screen.slide-out-right {
    display: flex;
    animation: slideOutRight 0.3s ease forwards;
}
.screen.fade-in {
    display: flex;
    animation: fadeIn 0.3s ease forwards;
}
.screen.fade-out {
    display: flex;
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0.8; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutLeft {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(-30%); opacity: 0; }
}
@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0.8; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(30%); opacity: 0; }
}
@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes fadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.96); }
}

/* ---------- LOADING SCREEN ---------- */
#loading-screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-container {
    text-align: center;
    padding: 40px 20px;
}

.rocket-wrapper {
    position: relative;
    width: 120px;
    height: 200px;
    margin: 0 auto 32px;
}

.rocket {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    animation: rocketFloat 2s ease-in-out infinite;
}

.rocket-body {
    width: 40px;
    height: 80px;
    background: linear-gradient(135deg, #e8e8e8, #c0c0c0);
    border-radius: 50% 50% 30% 30% / 60% 60% 20% 20%;
    position: relative;
    box-shadow: 0 0 20px rgba(255, 107, 107, 0.3);
}

.rocket-window {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #4ECDC4, #2b9a92);
    border-radius: 50%;
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: inset 0 -2px 4px rgba(0,0,0,0.2), 0 0 10px rgba(78, 205, 196, 0.5);
}

.rocket-fin {
    position: absolute;
    bottom: -5px;
    width: 14px;
    height: 30px;
    background: var(--accent);
    border-radius: 0 0 50% 50%;
}
.rocket-fin-left { left: -8px; transform: skewX(10deg); }
.rocket-fin-right { right: -8px; transform: skewX(-10deg); }

.rocket-flame {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2px;
}

.flame {
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: flameFlicker 0.15s ease-in-out infinite alternate;
}
.flame-1 { width: 8px; height: 25px; background: linear-gradient(to bottom, #FFE66D, #FF6B6B); animation-delay: 0s; }
.flame-2 { width: 12px; height: 35px; background: linear-gradient(to bottom, #fff, #FFE66D, #FF6B6B); animation-delay: 0.05s; }
.flame-3 { width: 8px; height: 25px; background: linear-gradient(to bottom, #FFE66D, #FF6B6B); animation-delay: 0.1s; }

.rocket-stars span {
    position: absolute;
    width: 2px;
    height: 2px;
    background: #fff;
    border-radius: 50%;
    animation: rocketStar 1s linear infinite;
}
.rocket-stars span:nth-child(1) { left: 20px; top: 120px; animation-delay: 0s; }
.rocket-stars span:nth-child(2) { left: 55px; top: 130px; animation-delay: 0.15s; }
.rocket-stars span:nth-child(3) { left: 80px; top: 125px; animation-delay: 0.3s; }
.rocket-stars span:nth-child(4) { left: 40px; top: 140px; animation-delay: 0.45s; }
.rocket-stars span:nth-child(5) { left: 65px; top: 135px; animation-delay: 0.6s; }
.rocket-stars span:nth-child(6) { left: 30px; top: 150px; animation-delay: 0.2s; }
.rocket-stars span:nth-child(7) { left: 75px; top: 145px; animation-delay: 0.35s; }
.rocket-stars span:nth-child(8) { left: 50px; top: 155px; animation-delay: 0.5s; }
.rocket-stars span:nth-child(9) { left: 35px; top: 160px; animation-delay: 0.65s; }
.rocket-stars span:nth-child(10) { left: 60px; top: 150px; animation-delay: 0.8s; }

@keyframes rocketFloat {
    0%, 100% { transform: translate(-50%, -50%) translateY(0px); }
    50% { transform: translate(-50%, -50%) translateY(-10px); }
}

@keyframes flameFlicker {
    0% { height: 25px; opacity: 0.8; }
    100% { height: 30px; opacity: 1; }
}
.flame-2 { animation-name: flameFlicker2; }
@keyframes flameFlicker2 {
    0% { height: 30px; opacity: 0.9; }
    100% { height: 38px; opacity: 1; }
}

@keyframes rocketStar {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(40px) scale(0); opacity: 0; }
}

.loading-title {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent), var(--warning));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.loading-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--warning));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ---------- COMMON ELEMENTS ---------- */
.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    text-align: center;
}

.subsection-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 24px 0 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--glow-accent);
}
.btn-primary:active {
    box-shadow: 0 2px 8px var(--glow-accent);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), var(--success-dark));
    color: #fff;
    box-shadow: 0 4px 15px var(--glow-success);
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
    border-radius: 14px;
    width: 100%;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

.hidden {
    display: none !important;
}

/* ---------- MAIN SCREEN ---------- */
.main-header {
    margin-bottom: 20px;
}

.player-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
}

.player-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.player-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.player-meta {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 14px;
    font-weight: 600;
}

.player-level {
    font-size: 11px;
    color: var(--text-muted);
}

.player-currencies {
    display: flex;
    gap: 8px;
}

.currency-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.currency-icon {
    font-size: 14px;
}

.energy-badge {
    cursor: pointer;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
    animation: glowPulse 2s ease-in-out infinite;
}

.energy-badge.claimed {
    animation: none;
    opacity: 0.5;
    pointer-events: none;
}

/* Planets Grid */
.planets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.planet-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.planet-card::before {
    content: '';
    position: absolute;
    top: -1px; left: -1px; right: -1px; bottom: -1px;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, var(--planet-color, var(--accent)), transparent);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    transition: opacity 0.3s ease;
}

.planet-card:active {
    transform: scale(0.97);
}

.planet-card:active::before {
    opacity: 1;
}

.planet-card.locked {
    opacity: 0.5;
    pointer-events: none;
}

.planet-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 16px;
}

.planet-emoji {
    font-size: 48px;
    margin-bottom: 8px;
    display: block;
    filter: drop-shadow(0 0 10px var(--planet-color, var(--accent)));
    animation: planetFloat 3s ease-in-out infinite;
}

.planet-card:nth-child(2n) .planet-emoji {
    animation-delay: -1.5s;
}

.planet-card-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.planet-card-info {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.planet-card-progress {
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
}

.planet-card-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--planet-color, var(--accent)), var(--success));
    transition: width 0.5s ease;
}

@keyframes planetFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* ---------- PLANET SCREEN ---------- */
.planet-header {
    text-align: center;
    padding: 24px 16px;
    margin-bottom: 16px;
}

.planet-icon-large {
    font-size: 72px;
    margin-bottom: 12px;
    display: block;
    animation: planetFloat 3s ease-in-out infinite;
}

.planet-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}

.planet-description {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    line-height: 1.4;
}

.planet-progress-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.planet-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.planet-progress-text {
    font-size: 12px;
    color: var(--text-muted);
}

/* Missions List */
.missions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mission-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.mission-card:active {
    transform: scale(0.98);
    background: var(--bg-card-hover);
}

.mission-card.locked {
    opacity: 0.4;
    pointer-events: none;
}

.mission-card.completed {
    border-color: rgba(78, 205, 196, 0.3);
}

.mission-card.completed::after {
    content: '';
}

.mission-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.mission-card.available .mission-icon {
    background: rgba(255, 107, 107, 0.15);
}

.mission-card.completed .mission-icon {
    background: rgba(78, 205, 196, 0.15);
}

.mission-card.locked .mission-icon {
    background: rgba(255, 255, 255, 0.05);
}

.mission-info {
    flex: 1;
    min-width: 0;
}

.mission-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mission-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.mission-status {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.mission-card.available .mission-status {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent);
}

.mission-card.completed .mission-status {
    background: rgba(78, 205, 196, 0.15);
    color: var(--success);
}

.mission-card.locked .mission-status {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-dim);
}

.mission-best-score {
    font-size: 11px;
    color: var(--success);
    font-weight: 600;
}

/* ---------- QUIZ SCREEN ---------- */
.quiz-content {
    padding-bottom: 16px !important;
    display: flex;
    flex-direction: column;
}

.quiz-header {
    padding: 12px 0 16px;
}

.quiz-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.quiz-mission-name {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60%;
}

.quiz-progress {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
}

.quiz-timer-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}

.quiz-timer-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--success), var(--warning));
    border-radius: 3px;
    transition: width 0.1s linear;
}

.quiz-timer-fill.warning {
    background: linear-gradient(90deg, var(--warning), var(--accent));
}

.quiz-timer-fill.danger {
    background: var(--accent);
    animation: timerPulse 0.5s ease-in-out infinite;
}

.quiz-timer-fill.frozen {
    background: linear-gradient(90deg, #63d5f5, #4ECDC4);
    animation: timerFrozen 1s ease-in-out infinite;
}

@keyframes timerPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

@keyframes timerFrozen {
    0%, 100% { opacity: 0.8; }
    50% { opacity: 1; }
}

.quiz-timer-text {
    font-size: 12px;
    color: var(--text-muted);
    text-align: right;
    display: block;
}

.quiz-question-card {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 24px 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-question-text {
    font-size: 17px;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
}

.quiz-answers {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.answer-btn {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.4;
}

.answer-btn:active {
    transform: scale(0.98);
}

.answer-btn .answer-letter {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.answer-btn.selected {
    border-color: var(--accent);
    background: rgba(255, 107, 107, 0.1);
}

.answer-btn.correct {
    border-color: var(--success);
    background: rgba(78, 205, 196, 0.15);
    animation: correctPulse 0.4s ease;
}

.answer-btn.correct .answer-letter {
    background: var(--success);
    color: #fff;
}

.answer-btn.wrong {
    border-color: var(--accent);
    background: rgba(255, 107, 107, 0.15);
    animation: shake 0.4s ease;
}

.answer-btn.wrong .answer-letter {
    background: var(--accent);
    color: #fff;
}

.answer-btn.dimmed {
    opacity: 0.3;
    pointer-events: none;
}

.answer-btn:disabled {
    pointer-events: none;
}

@keyframes correctPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* Booster Panel */
.quiz-booster-panel {
    margin-top: auto;
    padding-top: 12px;
}

.booster-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.booster-scroll::-webkit-scrollbar {
    display: none;
}

.booster-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 72px;
    flex-shrink: 0;
    position: relative;
}

.booster-btn:active {
    transform: scale(0.95);
    background: var(--bg-card-hover);
}

.booster-btn.used {
    opacity: 0.3;
    pointer-events: none;
}

.booster-btn.empty {
    opacity: 0.3;
    pointer-events: none;
}

.booster-icon {
    font-size: 20px;
}

.booster-name {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.booster-qty {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent);
    border-radius: 9px;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hint Box */
.quiz-hint-box {
    background: rgba(255, 230, 109, 0.1);
    border: 1px solid rgba(255, 230, 109, 0.3);
    border-radius: 12px;
    padding: 12px 16px;
    margin-top: 12px;
}

.hint-text {
    font-size: 13px;
    color: var(--warning);
    line-height: 1.4;
}

/* ---------- RESULTS SCREEN ---------- */
.results-content {
    text-align: center;
    padding-top: 40px !important;
    position: relative;
    overflow: hidden;
}

.results-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
}

.results-score-circle {
    width: 140px;
    height: 140px;
    margin: 0 auto 24px;
    position: relative;
}

.score-ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.score-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 8;
}

.score-ring-fill {
    fill: none;
    stroke: var(--success);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 1.5s ease;
}

.score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 32px;
    font-weight: 800;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
}

.result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.result-stat-icon {
    font-size: 20px;
}

.result-stat-value {
    font-size: 20px;
    font-weight: 700;
}

.result-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.results-rewards {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.reward-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    animation: rewardPop 0.5s ease;
}

.reward-icon {
    font-size: 18px;
}

.reward-value {
    font-size: 15px;
    font-weight: 700;
    color: var(--warning);
}

@keyframes rewardPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.results-xp-bar {
    margin-bottom: 24px;
    text-align: left;
}

.xp-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.xp-bar {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--warning));
    border-radius: 4px;
    transition: width 1s ease;
    width: 0%;
}

.results-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Confetti */
.results-confetti {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 10;
}

.confetti-piece {
    position: absolute;
    width: 8px;
    height: 8px;
    top: -10px;
    animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* ---------- LEADERBOARD SCREEN ---------- */
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-card);
    padding: 4px;
    border-radius: 12px;
}

.lb-tab {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lb-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--glow-accent);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.lb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.lb-row.self {
    border-color: rgba(255, 107, 107, 0.4);
    background: rgba(255, 107, 107, 0.08);
}

.lb-row.top-1 {
    border-color: rgba(255, 215, 0, 0.4);
    background: rgba(255, 215, 0, 0.08);
}

.lb-row.top-2 {
    border-color: rgba(192, 192, 192, 0.4);
    background: rgba(192, 192, 192, 0.05);
}

.lb-row.top-3 {
    border-color: rgba(205, 127, 50, 0.4);
    background: rgba(205, 127, 50, 0.05);
}

.lb-rank {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.lb-rank.medal {
    font-size: 20px;
}

.lb-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.lb-info {
    flex: 1;
    min-width: 0;
}

.lb-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-level {
    font-size: 11px;
    color: var(--text-muted);
}

.lb-score {
    font-size: 15px;
    font-weight: 700;
    color: var(--warning);
    flex-shrink: 0;
}

.leaderboard-self {
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid rgba(255, 107, 107, 0.3);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.leaderboard-self strong {
    color: var(--text);
}

/* ---------- PROFILE SCREEN ---------- */
.profile-header {
    text-align: center;
    padding: 24px 0;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 12px;
    box-shadow: 0 0 20px var(--glow-accent);
}

.profile-name {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.profile-level-badge {
    display: inline-block;
    padding: 4px 14px;
    background: rgba(255, 107, 107, 0.15);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 12px;
}

.profile-xp-bar {
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto;
    max-width: 200px;
    margin-bottom: 4px;
}

.profile-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--warning));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.profile-xp-text {
    font-size: 11px;
    color: var(--text-muted);
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.profile-stat-card {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 16px 12px;
    text-align: center;
    border: 1px solid var(--border);
}

.profile-stat-value {
    font-size: 22px;
    font-weight: 700;
    display: block;
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-currencies-row {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.profile-currency {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
}

.profile-currency .currency-icon {
    font-size: 20px;
}

.profile-currency .currency-value {
    font-size: 18px;
    font-weight: 700;
}

.profile-currency .currency-label {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: auto;
}

/* Achievements Gallery */
.achievements-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.achievement-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.achievement-card.unlocked {
    border-color: rgba(255, 230, 109, 0.3);
}

.achievement-card.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.achievement-card-icon {
    font-size: 28px;
    margin-bottom: 4px;
    display: block;
}

.achievement-card-name {
    font-size: 9px;
    color: var(--text-muted);
    line-height: 1.2;
    display: block;
}

/* Mission History */
.mission-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.history-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.history-info {
    flex: 1;
    min-width: 0;
}

.history-name {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-date {
    font-size: 11px;
    color: var(--text-muted);
}

.history-score {
    font-size: 14px;
    font-weight: 700;
    color: var(--success);
    flex-shrink: 0;
}

/* ---------- SHOP SCREEN ---------- */
.shop-balance {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.shop-balance .currency-badge {
    padding: 8px 16px;
    font-size: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.shop-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.shop-item {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.shop-item:active {
    transform: scale(0.97);
}

.shop-item-icon {
    font-size: 36px;
    margin-bottom: 8px;
    display: block;
}

.shop-item-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.shop-item-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.3;
    min-height: 28px;
}

.shop-item-price {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--warning);
}

.shop-buy-btn {
    width: 100%;
    padding: 8px 16px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: #fff;
}

.shop-buy-btn:active {
    transform: scale(0.96);
}

.shop-buy-btn:disabled {
    background: var(--bg-primary);
    color: var(--text-dim);
    opacity: 0.5;
    pointer-events: none;
}

.shop-item-owned {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* ---------- DAILY REWARDS SCREEN ---------- */
.daily-subtitle {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.daily-calendar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}

.daily-day {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 14px 8px;
    text-align: center;
    border: 2px solid var(--border);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.daily-day.special {
    grid-column: span 1;
}

.daily-day.claimed {
    border-color: rgba(78, 205, 196, 0.4);
    background: rgba(78, 205, 196, 0.08);
}

.daily-day.claimed::after {
    content: '✅';
    font-size: 14px;
}

.daily-day.active {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--glow-accent);
    animation: glowPulse 2s ease-in-out infinite;
}

.daily-day.upcoming {
    opacity: 0.4;
}

.daily-day-num {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

.daily-day-icon {
    font-size: 24px;
}

.daily-day-reward {
    font-size: 13px;
    font-weight: 700;
    color: var(--warning);
}

.daily-streak-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
    padding: 12px 20px;
    background: var(--bg-card);
    border-radius: 14px;
    border: 1px solid var(--border);
}

.streak-icon {
    font-size: 24px;
}

.streak-text {
    font-size: 16px;
    font-weight: 600;
}

.daily-claim-btn {
    max-width: 300px;
    margin: 0 auto;
    display: block;
}

.daily-claim-btn:disabled {
    background: var(--bg-card);
    color: var(--text-dim);
    box-shadow: none;
}

/* ---------- ACHIEVEMENT POPUP ---------- */
.achievement-popup {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 90%;
    max-width: 360px;
    padding: 16px 20px;
    animation: achievementSlideIn 0.5s ease forwards;
}

.achievement-popup.hidden {
    display: none;
}

.achievement-popup.dismiss {
    animation: achievementSlideOut 0.4s ease forwards;
}

.achievement-popup-inner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(255, 230, 109, 0.15), rgba(255, 107, 107, 0.1));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 230, 109, 0.3);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.achievement-popup-icon {
    font-size: 32px;
    flex-shrink: 0;
    animation: trophySpin 0.6s ease;
}

.achievement-popup-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.achievement-popup-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--warning);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.achievement-popup-name {
    font-size: 15px;
    font-weight: 700;
}

@keyframes achievementSlideIn {
    from { transform: translateX(-50%) translateY(-100%); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes achievementSlideOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(-100%); opacity: 0; }
}

@keyframes trophySpin {
    0% { transform: scale(0) rotate(-180deg); }
    60% { transform: scale(1.2) rotate(10deg); }
    100% { transform: scale(1) rotate(0deg); }
}

/* ---------- TAB BAR ---------- */
.tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    display: none;
    justify-content: space-around;
    align-items: center;
    padding: 6px 8px calc(var(--safe-bottom) + 6px);
    background: rgba(10, 14, 39, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    z-index: 50;
}

.tab-bar.visible {
    display: flex;
}

.tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 16px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
}

.tab-btn span {
    font-size: 10px;
    font-weight: 600;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn:active {
    transform: scale(0.92);
}

/* ---------- UTILITY ANIMATIONS ---------- */
@keyframes glowPulse {
    0%, 100% { box-shadow: 0 0 5px var(--glow-accent); }
    50% { box-shadow: 0 0 20px var(--glow-accent); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes glow {
    0%, 100% { filter: drop-shadow(0 0 5px var(--glow-accent)); }
    50% { filter: drop-shadow(0 0 15px var(--glow-accent)); }
}

/* ---------- LOADING SPINNER (INLINE) ---------- */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 14px;
}

/* ---------- SCROLLBAR ---------- */
.screen-content::-webkit-scrollbar {
    width: 3px;
}
.screen-content::-webkit-scrollbar-track {
    background: transparent;
}
.screen-content::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
}

/* ---------- RESPONSIVE ---------- */
@media (min-width: 500px) {
    .screen-content {
        padding-left: 24px;
        padding-right: 24px;
    }
}

@media (max-width: 340px) {
    .planets-grid {
        grid-template-columns: 1fr;
    }
    .achievements-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
    .daily-calendar {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* === CRYSTAL PACKS === */
.shop-section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-secondary, #9fa8da);
    margin-bottom: 12px;
    padding-left: 4px;
}

.crystal-packs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.crystal-pack {
    background: var(--bg-card, #1a2142);
    border-radius: 14px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255,255,255,0.06);
    position: relative;
    overflow: hidden;
}

.crystal-pack.popular {
    border-color: rgba(255, 215, 64, 0.3);
    background: linear-gradient(135deg, rgba(255,215,64,0.06), transparent);
}

.crystal-pack.popular::after {
    content: 'ХИТ';
    position: absolute;
    top: 6px;
    right: -20px;
    background: linear-gradient(90deg, #ffd740, #ffab40);
    color: #0a0e27;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 24px;
    transform: rotate(35deg);
}

.crystal-pack-icon {
    font-size: 28px;
    width: 48px;
    text-align: center;
    flex-shrink: 0;
}

.crystal-pack-info {
    flex: 1;
    min-width: 0;
}

.crystal-pack-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary, #e8eaf6);
}

.crystal-pack-bonus {
    font-size: 12px;
    color: #69f0ae;
    margin-top: 2px;
}

.crystal-pack-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

.pack-buy-btn {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: transform 0.15s;
}

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

.pack-buy-btn.stars-btn {
    background: linear-gradient(135deg, #7c4dff, #448aff);
    color: white;
}

.pack-buy-btn.card-btn {
    background: rgba(255,255,255,0.08);
    color: var(--text-secondary, #9fa8da);
    border: 1px solid rgba(255,255,255,0.1);
}
