/* ============================
   Arrow Escape - Clean White UI
   ============================ */

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', system-ui, sans-serif;
    font-weight: 600;
    background: #FFFFFF;
    color: #1a1a1a;
    user-select: none;
    -webkit-user-select: none;
}

/* ===== CANVAS ===== */
#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    outline: none;
    touch-action: none;
}

/* ===== UI OVERLAY ===== */
#uiOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
}

#uiOverlay > * {
    pointer-events: auto;
}

/* ===== SCREENS ===== */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
}

.screen.active {
    display: flex;
}

.hidden {
    display: none !important;
}

/* ===== COMMON BUTTONS ===== */
.back-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
    box-shadow: none;
    color: #333;
}

.back-btn:active {
    background: #e0e0e0;
}

.back-btn svg path {
    fill: #333;
}

.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 32px;
    border-radius: 28px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.04em;
    transition: transform 0.1s, opacity 0.15s;
    border: none;
    width: 100%;
    max-width: 260px;
    box-shadow: none;
    text-shadow: none;
}

.menu-btn:active {
    transform: scale(0.96);
    opacity: 0.85;
}

.next-btn {
    background: #1a1a1a;
}

.replay-btn {
    background: #f5f5f5;
    color: #333;
}

.replay-btn svg path {
    fill: #333;
}

.retry-btn {
    background: #1a1a1a;
}

.levels-btn {
    background: #f5f5f5;
    color: #333;
}

/* ===== MAIN MENU ===== */
#menuScreen {
    justify-content: center;
    background: #FFFFFF;
    overflow: hidden;
}

.menu-settings-btn {
    position: absolute;
    top: clamp(16px, 3vh, 28px);
    right: clamp(16px, 3vw, 28px);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    z-index: 5;
}

.menu-settings-btn:active {
    background: #e0e0e0;
}

.menu-settings-btn svg path {
    fill: #999;
}

.menu-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(1.5rem, 4vh, 2.5rem);
    position: relative;
    z-index: 1;
}

/* ===== LOGO ===== */
.game-title {
    line-height: 1;
    position: relative;
}

.title-line {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.title-arrow {
    font-size: clamp(2.8rem, 11vw, 5rem);
    color: #1a1a1a;
    text-shadow: none;
    animation: none;
}

.title-escape {
    font-size: clamp(3.2rem, 13vw, 5.8rem);
    color: #1a1a1a;
    text-shadow: none;
    margin-top: -0.1em;
    animation: none;
}

.game-title::after {
    content: '';
    display: block;
    width: 40px;
    height: 3px;
    margin: 12px auto 0;
    background: #1a1a1a;
    border-radius: 2px;
    animation: none;
}

.menu-subtitle {
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
    color: #999;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
}

/* ===== PLAY BUTTON ===== */
.play-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 48px;
    border-radius: 28px;
    background: #1a1a1a;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: clamp(1rem, 3.5vw, 1.2rem);
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.08em;
    box-shadow: none;
    text-shadow: none;
    transition: transform 0.15s, opacity 0.15s;
    position: relative;
    overflow: hidden;
    animation: none;
}

.play-btn:active {
    transform: scale(0.96);
    opacity: 0.85;
    animation: none;
}

.play-btn-shine {
    display: none;
}

.play-icon {
    flex-shrink: 0;
}

/* ===== SETTINGS SCREEN ===== */
#settingsScreen {
    display: flex;
    background: #FFFFFF;
    z-index: 150;
    flex-direction: column;
    align-items: center;
    padding-top: clamp(16px, 4vh, 32px);
}

.settings-container {
    width: 90%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2vh, 18px);
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.settings-container::-webkit-scrollbar { width: 3px; }
.settings-container::-webkit-scrollbar-track { background: transparent; }
.settings-container::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.settings-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-title {
    flex: 1;
    font-size: clamp(1.3rem, 4vw, 1.6rem);
    font-weight: 800;
    color: #1a1a1a;
    letter-spacing: 0.02em;
}

.settings-section-label {
    font-size: clamp(0.65rem, 1.8vw, 0.75rem);
    color: #999;
    letter-spacing: 0.15em;
    font-weight: 600;
    text-transform: uppercase;
}

/* ===== TOGGLE SWITCHES ===== */
.settings-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #f8f8f8;
    border: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-toggle-row:active {
    background: #f0f0f0;
}

.toggle-icon {
    font-size: 1.3rem;
    line-height: 1;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.toggle-icon svg {
    stroke: #555;
}

.toggle-label {
    flex: 1;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 600;
    color: #333;
}

.toggle-switch {
    width: 48px;
    height: 28px;
    border-radius: 14px;
    background: #ddd;
    border: none;
    position: relative;
    flex-shrink: 0;
    transition: background 0.25s;
}

.toggle-switch .toggle-knob {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 11px;
    background: #fff;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    transition: left 0.25s;
}

.settings-toggle-row.active .toggle-switch {
    background: #1a1a1a;
}

.settings-toggle-row.active .toggle-switch .toggle-knob {
    left: 23px;
}

/* ===== VOLUME SLIDER ===== */
.settings-slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-radius: 12px;
    background: #f8f8f8;
    border: 1px solid #eee;
}

.slider-icon {
    flex-shrink: 0;
    width: 22px;
    text-align: center;
}

.slider-icon svg {
    stroke: #555;
}

.volume-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #ddd;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #1a1a1a;
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    cursor: pointer;
}

.slider-value {
    font-size: clamp(0.75rem, 2vw, 0.85rem);
    font-weight: 700;
    color: #555;
    min-width: 36px;
    text-align: right;
}

/* ===== LANGUAGE LIST ===== */
.settings-lang-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 40vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-right: 4px;
}

.settings-lang-list::-webkit-scrollbar { width: 3px; }
.settings-lang-list::-webkit-scrollbar-track { background: transparent; }
.settings-lang-list::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.settings-lang-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #f8f8f8;
    border: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.settings-lang-item:active {
    background: #f0f0f0;
}

.settings-lang-item.active {
    background: #1a1a1a;
    border-color: #1a1a1a;
}

.settings-lang-flag {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
}

.settings-lang-name {
    flex: 1;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-weight: 600;
    color: #333;
}

.settings-lang-item.active .settings-lang-name {
    color: #fff;
}

.settings-lang-check {
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
    line-height: 1;
    color: #fff;
}

.settings-lang-item.active .settings-lang-check {
    opacity: 1;
}

/* ===== RESET BUTTON ===== */
.settings-reset-btn {
    width: 100%;
    padding: 14px 20px;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
    font-family: inherit;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    font-weight: 700;
    color: #e53935;
    letter-spacing: 0.04em;
    transition: background 0.15s;
    margin-top: 8px;
}

.settings-reset-btn:active {
    background: #fef0f0;
}

.settings-reset-btn.confirming {
    background: #e53935;
    color: #fff;
    border-color: #e53935;
    animation: none;
}

/* ===== LEVEL SELECT ===== */
#levelSelectScreen {
    padding: clamp(16px, 3vh, 24px) 16px;
    background: #FFFFFF;
}

.ls-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 400px;
    margin-bottom: clamp(16px, 3vh, 24px);
}

.ls-title {
    flex: 1;
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    font-weight: 800;
    color: #1a1a1a;
    letter-spacing: 0.02em;
}

.ls-spacer {
    width: 44px;
}

.ls-scroller {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 400px;
    padding: 0 4px 20px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    align-content: start;
}

.ls-scroller::-webkit-scrollbar { width: 3px; }
.ls-scroller::-webkit-scrollbar-track { background: transparent; }
.ls-scroller::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

/* ===== LEVEL CARD ===== */
.level-card {
    aspect-ratio: 1;
    border-radius: 16px;
    background: #f8f8f8;
    border: 1.5px solid #eee;
    cursor: pointer;
    transition: transform 0.1s, background 0.15s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
}

.level-card:active {
    transform: scale(0.95);
    background: #f0f0f0;
}

.level-card.current {
    background: #1a1a1a;
    border-color: #1a1a1a;
}

.level-card.current .level-card-number {
    color: #fff;
}

.level-card.completed {
    background: #f8f8f8;
}

.level-card.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

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

.level-card-number {
    font-size: clamp(1.1rem, 3.5vw, 1.4rem);
    font-weight: 800;
    color: #1a1a1a;
    line-height: 1;
}

.level-card-check {
    color: #4CAF50;
    line-height: 1;
}

.level-card-lock {
    color: #ccc;
    line-height: 1;
}

/* ===== GAME HUD ===== */
#gameHUD {
    pointer-events: none;
    padding: clamp(12px, 2vh, 20px) 16px;
}

.hud-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    pointer-events: none;
}

.hud-top .back-btn,
.hud-top .hud-arrows-count,
.hud-top .level-badge,
.hud-top .hearts-container {
    pointer-events: auto;
}

/* Arrows count badge */
.hud-arrows-count {
    background: #f5f5f5;
    padding: 4px 12px;
    border-radius: 14px;
    font-size: clamp(0.8rem, 2.2vw, 0.9rem);
    font-weight: 700;
    color: #555;
}

/* Level Badge */
.level-badge {
    background: transparent;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.level-badge-text {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: 0.02em;
}

/* Hearts */
.hearts-container {
    display: flex;
    gap: 2px;
}

.heart {
    color: #e53935;
    filter: none;
    transition: transform 0.2s;
    display: inline-flex;
    align-items: center;
}

.heart.pulse {
    animation: none;
}

.heart.empty {
    color: #e0e0e0;
    filter: none;
}

.heart.breaking {
    animation: heartBreak 0.5s ease-out forwards;
}

@keyframes heartBreak {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.3); opacity: 1; }
    100% { transform: scale(0); opacity: 0; }
}


/* ===== FLOATING TEXT ===== */
#floatingTextContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.floating-text {
    position: absolute;
    font-weight: 800;
    font-size: clamp(1.3rem, 4vw, 1.8rem);
    color: #1a1a1a;
    text-shadow: none;
    pointer-events: none;
    white-space: nowrap;
}

.floating-text.negative {
    color: #e53935;
    text-shadow: none;
}

/* ===== OVERLAYS ===== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
}

.overlay.active {
    display: flex;
}

.overlay-panel {
    width: 90%;
    max-width: 340px;
    padding: clamp(32px, 5vh, 44px) clamp(24px, 4vw, 36px);
    text-align: center;
    position: relative;
    border-radius: 24px;
    background: #fff;
    border: 1px solid #eee;
    box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

.overlay-title {
    font-size: clamp(1.3rem, 4.5vw, 1.7rem);
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.victory-title {
    color: #1a1a1a;
    text-shadow: none;
}

.fail-title {
    color: #e53935;
    text-shadow: none;
}

.overlay-subtitle {
    color: #999;
    font-size: clamp(0.8rem, 2.5vw, 0.95rem);
    font-weight: 500;
    margin-bottom: 24px;
}

.overlay-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* ===== CONFETTI ===== */
#confettiContainer, #confettiContainer2 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    top: -10px;
}

/* ===== TUTORIAL ===== */
.tutorial-tooltip {
    position: absolute;
    bottom: 30%;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    border-radius: 20px;
    background: #1a1a1a;
    border: none;
    color: #fff;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    font-weight: 600;
    display: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 15;
    white-space: nowrap;
    text-shadow: none;
}

.tutorial-tooltip.active {
    display: block;
}

.tooltip-arrow-indicator {
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1a1a1a;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 360px) {
    .heart svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 320px) {
    .ls-scroller {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 500px) {
    .ls-scroller {
        grid-template-columns: repeat(5, 1fr);
        max-width: 480px;
    }
}

@media (min-width: 768px) {
    .ls-scroller {
        max-width: 480px;
    }

    .settings-container {
        max-width: 420px;
    }
}
