:root {
    --bg-color: #0d1a15;
    --glass-bg: rgba(20, 45, 30, 0.7);
    --glass-border: rgba(100, 200, 150, 0.2);
    
    --snake-green: #2ecc71;
    --snake-red: #e74c3c;
    --snake-blue: #3498db;
    --snake-yellow: #f1c40f;
    --snake-purple: #9b59b6;
    --snake-orange: #e67e22;
    --snake-cyan: #00bcd4;
    --snake-pink: #ff7979;
    --snake-teal: #1abc9c;
    --snake-lime: #badc58;
    
    --text-main: #e0f2e9;
    --accent: #2ecc71;
    
    --tile-size: 40px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(30, 80, 45, 0.4) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(20, 60, 40, 0.4) 0%, transparent 40%);
    color: var(--text-main);
    overflow: hidden;
    touch-action: manipulation;
}

#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

#start-screen {
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 50;
}

#start-screen .glass-panel {
    padding: 40px;
    max-width: 500px;
    width: 100%;
}

h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 5px;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

h1 span {
    color: var(--accent);
}

.subtitle {
    font-size: 1.2rem;
    color: #a0d4b5;
    margin-bottom: 30px;
}

.level-selection h3 {
    margin-bottom: 15px;
}

.level-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin: 20px 0 5px 0;
}

.primary-btn {
    background: linear-gradient(145deg, #2ecc71, #27ae60);
    color: #000;
    border: none;
    padding: 15px 40px;
    font-size: 1.5rem;
    font-weight: 800;
    border-radius: 30px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: inherit;
    margin-bottom: 15px;
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.4), inset 0 2px 5px rgba(255,255,255,0.3);
}
.primary-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 20px rgba(46, 204, 113, 0.5), inset 0 2px 5px rgba(255,255,255,0.4);
    filter: brightness(1.1);
}
.primary-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 3px 10px rgba(46, 204, 113, 0.4);
}
.secondary-btn {
    background: linear-gradient(145deg, rgba(52, 152, 219, 0.1), rgba(52, 152, 219, 0.02));
    color: #3498db;
    border: 2px solid #3498db;
    padding: 12px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    border-radius: 25px;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: inherit;
    margin-bottom: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.secondary-btn:hover {
    background: linear-gradient(145deg, rgba(52, 152, 219, 0.2), rgba(52, 152, 219, 0.05));
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 15px rgba(52, 152, 219, 0.3);
}
.secondary-btn:active {
    transform: translateY(2px) scale(0.98);
    box-shadow: 0 2px 5px rgba(52, 152, 219, 0.3);
}

.level-display {
    font-size: 4rem;
    font-weight: 900;
    width: 120px;
    text-align: center;
    color: var(--accent);
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.warning-text {
    color: var(--snake-red);
    font-weight: bold;
    height: 20px;
    transition: opacity 0.3s;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    color: white;
}

.btn-info-main {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
}
.btn-primary {
    background: var(--accent);
    color: #000;
}
.btn-primary:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}
.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-main);
}
.btn-secondary-solid {
    background: #e0f2e9;
    color: #000;
    border: none;
}
.btn:hover:not(:disabled) {
    transform: scale(1.05);
}

.hud {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
    z-index: 10;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.lives-display {
    display: flex;
    gap: 5px;
    height: 24px;
}

.heart {
    font-size: 1.2rem;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.heart.lost {
    opacity: 0.2;
    transform: scale(0.5);
    filter: grayscale(100%);
}

.heart.pop {
    animation: heartPop 0.4s ease-out;
}

@keyframes heartPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.level-controls button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 2.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: white;
    background: linear-gradient(145deg, rgba(255,255,255,0.2), rgba(255,255,255,0.05));
    border: 2px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 2px 5px rgba(255,255,255,0.1);
}
.level-controls button:active {
    transform: scale(0.9) translateY(2px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.btn-minus {
    background: linear-gradient(145deg, rgba(231, 76, 60, 0.2), rgba(231, 76, 60, 0.05));
    border: 2px solid rgba(231, 76, 60, 0.4);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 2px 5px rgba(231,76,60,0.1);
}
.btn-minus:hover {
    background: linear-gradient(145deg, rgba(231, 76, 60, 0.4), rgba(231, 76, 60, 0.1));
    border-color: #e74c3c;
    color: #e74c3c;
    box-shadow: 0 6px 15px rgba(231, 76, 60, 0.3), inset 0 2px 5px rgba(255,255,255,0.2);
    transform: translateY(-2px);
}
.btn-plus {
    background: linear-gradient(145deg, rgba(46, 204, 113, 0.2), rgba(46, 204, 113, 0.05));
    border: 2px solid rgba(46, 204, 113, 0.4);
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3), inset 0 2px 5px rgba(46,204,113,0.1);
}
.btn-plus:hover {
    background: linear-gradient(145deg, rgba(46, 204, 113, 0.4), rgba(46, 204, 113, 0.1));
    border-color: #2ecc71;
    color: #2ecc71;
    box-shadow: 0 6px 15px rgba(46, 204, 113, 0.3), inset 0 2px 5px rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.btn-icon {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
}
.btn-icon:hover {
    background: rgba(255,255,255,0.2);
}
.btn-large {
    width: 60px;
    height: 60px;
    font-size: 2rem;
}

.right-hud {
    display: flex;
    gap: 10px;
}

.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding: 10px;
}

#board-wrapper {
    position: relative;
}

#game-svg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2;
    overflow: visible;
}

.snake-body {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: opacity 0.3s;
    cursor: pointer;
}

.snake-head {
    fill: currentColor;
    cursor: pointer;
    transform-origin: 0px 10px;
}

.snake-group {
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
    transition: filter 0.3s;
}

.snake-group:hover {
    filter: drop-shadow(0 0 10px currentColor);
}

.idle-look {
    animation: headLookAround 2s ease-in-out;
}

@keyframes headLookAround {
    0% { transform: rotate(0deg); }
    20% { transform: rotate(-12deg); }
    40% { transform: rotate(12deg); }
    60% { transform: rotate(-6deg); }
    80% { transform: rotate(6deg); }
    100% { transform: rotate(0deg); }
}

.snake-tongue {
    stroke: red;
    stroke-width: 1.5px;
    fill: none;
    transform-origin: 0px -15px;
    transform: scaleY(0);
}

.snake-head.flick .snake-tongue {
    animation: tongueFlick 0.6s ease-in-out;
}

@keyframes tongueFlick {
    0% { transform: scaleY(0); }
    15% { transform: scaleY(1); }
    30% { transform: scaleY(0); }
    45% { transform: scaleY(1); }
    60% { transform: scaleY(0); }
    100% { transform: scaleY(0); }
}

.snake-eye {
    fill: #fff;
}

.rock-rect {
    stroke-width: 3;
    rx: 6; ry: 6;
    filter: drop-shadow(0 4px 4px rgba(0,0,0,0.5));
}

.moving-obstacle {
    transition: x 0.4s linear, y 0.4s linear;
}

.portal-hole {
    fill: #050a08;
    stroke-width: 3;
    animation: portalPulse 2s infinite alternate ease-in-out;
}

@keyframes portalPulse {
    0% { stroke-width: 2; filter: drop-shadow(0 0 2px currentColor); }
    100% { stroke-width: 5; filter: drop-shadow(0 0 10px currentColor); }
}
.rock-brown {
    fill: #5d4037;
    stroke: #3e2723;
}
.rock-gray {
    fill: #7f8c8d;
    stroke: #2c3e50;
}
.rock-mossy {
    fill: #4a5d23;
    stroke: #2e3e14;
}

.wiggle {
    animation: wiggleAnim 0.3s ease-in-out;
}

.flash-anim {
    animation: doubleFlash 0.6s ease-in-out;
}

.hint-flash {
    animation: tripleFlash 0.9s ease-in-out;
}

@keyframes tripleFlash {
    0% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); }
    16% { filter: drop-shadow(0 0 15px currentColor); }
    33% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); }
    50% { filter: drop-shadow(0 0 15px currentColor); }
    66% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); }
    83% { filter: drop-shadow(0 0 15px currentColor); }
    100% { filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4)); }
}

@keyframes doubleFlash {
    0% { opacity: 1; filter: brightness(1); }
    25% { opacity: 0.4; filter: brightness(2); }
    50% { opacity: 1; filter: brightness(1); }
    75% { opacity: 0.4; filter: brightness(2); }
    100% { opacity: 1; filter: brightness(1); }
}

@keyframes wiggleAnim {
    0% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    50% { transform: translateX(4px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    padding: 30px;
    max-width: 500px;
    width: 100%;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 15px; right: 15px;
    background: transparent;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.rules-content {
    margin-top: 20px;
    line-height: 1.6;
}

.rules-content h3 {
    margin: 15px 0 10px;
}
.rules-content ul {
    list-style: none;
}
.rules-content li {
    margin-bottom: 10px;
    background: rgba(0,0,0,0.2);
    padding: 10px;
    border-radius: 8px;
}

.text-center { text-align: center; }
.win-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}
