/* Buttons */
.btn {
    font-family: var(--font-main);
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    font-size: 0.9rem;
    padding: 12px 24px;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-glow));
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #3a3f60;
}

.btn-large {
    font-size: 1.1rem;
    padding: 16px 32px;
    width: 100%;
}

.btn-icon {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.1rem;
}

/* Menu */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.menu-title-block {
    text-align: center;
}

.menu-title {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #8b5cf6, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.menu-subtitle {
    font-size: 1.3rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.menu-progress {
    text-align: center;
    width: 100%;
}

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--success));
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.progress-text, .stars-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.stars-text {
    margin-top: 2px;
}

/* Level Select */
.level-select-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.level-select-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--bg-tertiary);
}

.level-select-title {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
}

.category-stars {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.level-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 16px;
    overflow-y: auto;
    align-content: start;
}

.level-card {
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    position: relative;
}

.level-card:active {
    transform: scale(0.93);
}

.level-card.completed {
    border-color: var(--success);
}

.level-card.current {
    border-color: var(--accent-primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.level-card.locked {
    opacity: 0.4;
    cursor: default;
}

.level-card.locked:active {
    transform: none;
}

.level-number {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
}

.level-stars {
    font-size: 0.65rem;
    letter-spacing: 1px;
}

.level-lock {
    font-size: 1.2rem;
}

.level-card.star-locked {
    opacity: 0.6;
    border-color: #fbbf2440;
}

.level-card.star-locked .level-number {
    font-size: 1rem;
    opacity: 0.7;
}

.level-stars-required {
    font-size: 0.55rem;
    color: #fbbf24;
    font-weight: 600;
    margin-top: 2px;
}

.category-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--bg-tertiary);
}

.category-name {
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 150px;
    text-align: center;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal.hidden {
    display: none;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem;
    width: 90%;
    max-width: 360px;
    text-align: center;
    z-index: 1;
    border: 1px solid var(--bg-tertiary);
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 1rem;
}

/* Victory */
.victory-content {
    overflow: hidden;
}

.victory-title {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.victory-stars {
    font-size: 2.5rem;
    margin: 1rem 0;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.star {
    display: inline-block;
    transition: all 0.3s ease;
}

.star.earned {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.5);
}

.star.empty {
    color: var(--bg-tertiary);
}

.victory-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.victory-stats p {
    margin: 4px 0;
}

#victory-record {
    color: var(--success);
    font-weight: 600;
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 1.5rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.setting-label {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-tertiary);
    border-radius: 13px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--text-secondary);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle input:checked + .toggle-slider {
    background: var(--accent-primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background: white;
}

/* Achievements */
.achievements-content {
    max-height: 80vh;
    overflow-y: auto;
}

.achievements-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 1rem;
    max-height: 50vh;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.achievements-list::-webkit-scrollbar {
    display: none;
}

.achievement-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 10px;
    text-align: left;
}

.achievement-card.unlocked {
    border: 1px solid var(--success);
}

.achievement-card.locked {
    opacity: 0.5;
}

.achievement-icon {
    font-size: 1.5rem;
    width: 40px;
    text-align: center;
}

.achievement-info {
    flex: 1;
}

.achievement-name {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.achievement-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* How To Play */
.howto-steps {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 1.5rem;
    text-align: left;
}

.howto-step {
    display: flex;
    align-items: center;
    gap: 12px;
}

.howto-number {
    width: 32px;
    height: 32px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.howto-step p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 2px;
}

/* Responsive */
@media (max-width: 480px) {
    .menu-title {
        font-size: 2rem;
    }
    .menu-subtitle {
        font-size: 1rem;
    }
    .level-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        padding: 12px;
    }
    .modal-content {
        padding: 1.5rem;
        width: 92%;
    }
}

@media (min-width: 768px) {
    .level-grid {
        grid-template-columns: repeat(5, 1fr);
        max-width: 500px;
        margin: 0 auto;
    }
}

/* Compact height */
@media (max-height: 550px) {
    /* Menu */
    .menu-container {
        flex-direction: row;
        max-width: 100%;
        gap: 2rem;
        padding: 1rem 2rem;
        padding-left: max(2rem, env(safe-area-inset-left));
        padding-right: max(2rem, env(safe-area-inset-right));
    }

    .menu-title-block {
        flex-shrink: 0;
    }

    .menu-title {
        font-size: 1.6rem;
    }

    .menu-subtitle {
        font-size: 0.85rem;
    }

    .menu-buttons {
        max-width: 250px;
    }

    .btn-large {
        font-size: 0.95rem;
        padding: 10px 24px;
    }

    .btn {
        padding: 8px 20px;
        font-size: 0.8rem;
    }

    .btn.btn-icon {
        padding: 0;
    }

    /* Modals */
    .modal-content {
        padding: 1rem 1.5rem;
        max-height: 90vh;
        overflow-y: auto;
        max-width: 320px;
    }

    .modal-title {
        font-size: 1rem;
        margin-bottom: 0.8rem;
    }

    .modal-buttons {
        gap: 6px;
        margin-top: 0.5rem;
    }

    .modal-buttons .btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }

    /* Victory */
    .victory-stars {
        font-size: 1.8rem;
        margin: 0.5rem 0;
        gap: 6px;
    }

    .victory-stats {
        font-size: 0.8rem;
        margin-bottom: 0.3rem;
    }

    /* Skip modal */
    .skip-content {
        padding: 1rem 1.5rem;
    }

    .skip-desc {
        font-size: 0.75rem;
        margin-bottom: 0.8rem;
    }

    .btn-play-ad {
        width: 50px;
        height: 50px;
        margin-bottom: 0.6rem;
    }

    .btn-play-ad svg {
        width: 24px;
        height: 24px;
    }

    /* Settings */
    .settings-list {
        gap: 10px;
        margin-bottom: 1rem;
    }

    .setting-label {
        font-size: 0.85rem;
    }

    /* Level Select */
    .level-select-header {
        padding: 6px 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .level-select-title {
        font-size: 0.9rem;
    }

    .level-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
        padding: 8px 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .level-number {
        font-size: 1rem;
        margin-bottom: 2px;
    }

    .level-stars {
        font-size: 0.55rem;
    }

    .category-nav {
        padding: 6px 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .category-name {
        font-size: 0.75rem;
    }

    /* How To Play */
    .howto-steps {
        gap: 8px;
        margin-bottom: 0.8rem;
    }

    .howto-number {
        width: 24px;
        height: 24px;
        font-size: 0.75rem;
    }

    .howto-step p {
        font-size: 0.8rem;
    }

    /* Achievements */
    .achievements-content {
        max-height: 85vh;
    }

    .achievements-list {
        max-height: 40vh;
    }

    .achievement-card {
        padding: 8px;
        gap: 8px;
    }

    .achievement-icon {
        font-size: 1.2rem;
        width: 32px;
    }

    .achievement-name {
        font-size: 0.75rem;
    }

    .achievement-desc {
        font-size: 0.65rem;
    }
}
