:root {
    --bg-dark: #0a0a14;
    --primary: #ff9c3a; /* Culoarea aluatului */
    --accent-cyan: #00f7ff;
    --accent-magenta: #ff007b;
    --text-light: #f0f0f0;
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --bg-gradient: radial-gradient(circle at top right, #1a1a2e, #0a0a14);
}

[data-theme="light"] {
    --bg-dark: #f8f1e5;
    --primary: #e67e22;
    --accent-cyan: #2980b9;
    --accent-magenta: #c0392b;
    --text-light: #2c3e50;
    --overlay-bg: rgba(255, 255, 255, 0.9);
    --glass: rgba(0, 0, 0, 0.05);
    --glass-border: rgba(0, 0, 0, 0.1);
    /* Pattern de față de masă în carouri subtile */
    --bg-pattern: 
        linear-gradient(45deg, rgba(230, 126, 34, 0.05) 25%, transparent 25%), 
        linear-gradient(-45deg, rgba(230, 126, 34, 0.05) 25%, transparent 25%), 
        linear-gradient(45deg, transparent 75%, rgba(230, 126, 34, 0.05) 75%), 
        linear-gradient(-45deg, transparent 75%, rgba(230, 126, 34, 0.05) 75%);
    --bg-gradient: radial-gradient(circle at top right, #fff9f0, #f8f1e5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    background-color: var(--bg-dark);
    font-family: 'Outfit', sans-serif;
    color: var(--text-light);
    overflow: hidden;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic Viewport Height */
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed; /* Previne scroll-ul pe iOS */
    width: 100%;
    touch-action: none; /* Dezactivează gesturile browser-ului */
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 100vh; /* Fallback */
    height: 100dvh; /* Dynamic Viewport Height */
    background: var(--bg-gradient);
    background-image: var(--bg-pattern);
    background-size: 60px 60px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    transition: background 0.5s ease;
    touch-action: none;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* OVERLAYS */
.overlay {
    position: absolute;
    inset: 0;
    background: var(--overlay-bg);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 100;
    text-align: center;
    padding: 2rem;
    transition: opacity 0.4s ease, background 0.5s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* HUD */
#hud {
    position: absolute;
    top: 20px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center; /* Centrare pe verticală pentru tot HUD-ul */
    z-index: 50;
    pointer-events: none;
}

.stats-group {
    display: flex;
    gap: 8px;
}

.actions-group {
    display: flex;
    align-items: center;
    gap: 12px; /* Spațiu între inimi și butonul de pauză */
}

.stat-box {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    min-width: 80px;
}

.label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-cyan);
}

.value {
    font-size: 1.5rem;
    font-weight: 900;
}

.lives-container {
    display: flex;
    gap: 15px;
    align-items: center;
    margin-left: 10px;
}

.custom-heart {
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #ff007b, #ff4c4c);
    position: relative;
    transform: rotate(-45deg);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    filter: drop-shadow(0 0 8px rgba(255, 0, 123, 0.8));
    flex-shrink: 0;
}

.custom-heart::before,
.custom-heart::after {
    content: "";
    width: 14px;
    height: 14px;
    background: inherit;
    border-radius: 50%;
    position: absolute;
}

.custom-heart::before { top: -7px; left: 0; }
.custom-heart::after { top: 0; left: 7px; }

.custom-heart.empty {
    background: #444;
    filter: grayscale(1) opacity(0.3);
    box-shadow: none;
}

.custom-heart.active {
    box-shadow: 0 0 12px rgba(255, 0, 123, 0.5);
}

.custom-heart.panic {
    animation: heartBeat 0.5s infinite alternate;
}

@keyframes heartBeat {
    from { transform: rotate(-45deg) scale(1.1); filter: drop-shadow(0 0 12px #ff007b); }
    to { transform: rotate(-45deg) scale(1.4); filter: drop-shadow(0 0 20px #ff007b); }
}

/* TEXT & BUTTONS */
.neon-text {
    font-size: clamp(2rem, 10vw, 3.5rem);
    font-weight: 900;
    letter-spacing: -2px;
    color: var(--text-light);
    text-shadow: 0 0 10px var(--accent-cyan);
    margin-bottom: 0.5rem;
    animation: neonPulse 2s infinite alternate;
}

.animate-title {
    animation: titleFloat 3s ease-in-out infinite alternate;
}

@keyframes titleFloat {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.logo-container {
    width: 120px;
    height: 120px;
    margin-bottom: 1rem;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(var(--primary), 0.3);
    background: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-container img {
    max-width: 100%;
    height: auto;
}

@keyframes neonPulse {
    from { text-shadow: 0 0 10px var(--accent-cyan), 0 0 20px var(--accent-cyan); }
    to { text-shadow: 0 0 15px var(--accent-cyan), 0 0 30px var(--accent-cyan), 0 0 40px var(--accent-cyan); }
}

.subtitle {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.instructions {
    margin-bottom: 2rem;
    line-height: 1.6;
    color: var(--text-light);
    opacity: 0.8;
}

.instructions-visual {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin: 1.5rem 0;
}

.instr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.instr-item .icon { font-size: 2.5rem; }
.instr-item .text { font-size: 0.8rem; font-weight: 700; color: var(--accent-cyan); letter-spacing: 1px; }

.best-score {
    margin-top: 2rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

.icon-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    backdrop-filter: blur(4px);
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s;
    z-index: 110;
}

.icon-btn:hover {
    transform: scale(1.1);
    background: var(--glass-border);
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn-hud {
    position: relative; /* Schimbat din absolute pentru a sta în Actions Group */
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-light);
    width: 42px;
    height: 42px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 1.2rem;
    backdrop-filter: blur(4px);
    transition: transform 0.2s, background 0.2s;
    pointer-events: auto;
}

.icon-btn-hud:hover {
    transform: scale(1.1);
    background: var(--glass-border);
}

.menu-box {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.menu-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
    max-width: 250px;
}

.main-btn {
    background: linear-gradient(45deg, var(--primary), #ff6b6b);
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 50px;
    color: white;
    font-weight: 900;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(255, 156, 58, 0.3);
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.2s, box-shadow 0.2s;
    letter-spacing: 1px;
    animation: buttonPulse 1.5s infinite;
}

@keyframes buttonPulse {
    0% { transform: scale(1); box-shadow: 0 10px 20px rgba(255, 156, 58, 0.3); }
    50% { transform: scale(1.05); box-shadow: 0 15px 30px rgba(255, 156, 58, 0.5); }
    100% { transform: scale(1); box-shadow: 0 10px 20px rgba(255, 156, 58, 0.3); }
}

.main-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(255, 156, 58, 0.5);
}

.secondary-btn {
    background: transparent;
    border: 2px solid var(--glass-border);
    padding: 0.8rem 2rem;
    border-radius: 50px;
    color: var(--text-light);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.secondary-btn:hover {
    background: var(--glass);
    border-color: var(--text-light);
}

.final-score-box {
    margin: 2rem 0;
}

.final-score-box p {
    font-size: 0.8rem;
    letter-spacing: 2px;
    color: var(--accent-magenta);
}

.neon-text-red {
    font-size: 2.5rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 10px var(--accent-magenta), 0 0 20px var(--accent-magenta);
}

.hidden {
    display: none !important;
}

/* ANIMATIONS */
.shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

.best-score-box {
    margin-top: 1rem;
}

.best-score-box p {
    font-size: 0.7rem;
    letter-spacing: 2px;
    color: var(--accent-cyan);
}

#reward-msg {
    font-size: 1.5rem;
    font-weight: 900;
    margin: 1rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.rank-reveal {
    animation: rankIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes rankIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}
