/* ==============================================================================
 * SNAKIO: SNAKE TIME REWIND (OFFICIAL WEB EDITION)
 * Styled with Nuvras Studios Brand System:
 * - Obsidian Slate (#14171c / #11141a)
 * - Nuvras Neon Lime (#58cc02 / #bfe303)
 * - Chronal Electric Blue (#1cb0f6)
 * - Studio Gold (#ffc800) & Ruby (#ff4b4b)
 * - Tactile 3D Extrusions & Outfit / Plus Jakarta Sans Typography
 * ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@600;700;800;900&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

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

:root {
    /* Brand Palette */
    --color-bg-dark: #11141a;
    --color-surface-obsidian: #14171c;
    --color-surface-slate: #1a232f;
    --color-surface-card: #1e2632;
    --color-surface-hover: #263140;
    --color-border-dark: #14171c;
    --color-border-subtle: #2d3b4e;

    /* Signature Accents */
    --color-lime: #58cc02;
    --color-lime-bright: #bfe303;
    --color-lime-dark: #46a302;
    --color-lime-glow: rgba(88, 204, 2, 0.4);

    --color-blue: #1cb0f6;
    --color-blue-dark: #1899d6;
    --color-blue-glow: rgba(28, 176, 246, 0.4);

    --color-gold: #ffc800;
    --color-gold-dark: #e5b400;

    --color-ruby: #ff4b4b;
    --color-ruby-dark: #d82b2b;
    --color-emerald: #58cc02;
    --color-cyan: #00e5ff;

    --color-text-main: #ffffff;
    --color-text-muted: #94a3b8;
    --color-text-subtle: #64748b;

    /* Tactile 3D Extrusions */
    --shadow-3d: 0 4px 0 #14171c, 0 8px 16px rgba(0, 0, 0, 0.45);
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--color-bg-dark);
    font-family: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--color-text-main);
    touch-action: manipulation;
}

#game-wrapper {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at center, #1e2735 0%, #11141a 80%);
}

/* Studio Portal Back Button */
.web-return-btn {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 999;
    background: rgba(20, 23, 28, 0.92);
    color: var(--color-lime);
    border: 2px solid var(--color-lime);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    transition: all 0.15s ease;
}
.web-return-btn:hover {
    background: var(--color-lime);
    color: #14171c;
    transform: scale(1.04);
    box-shadow: 0 6px 16px var(--color-lime-glow);
}

/* ====================================================
   SCREENS & OVERLAYS
   ==================================================== */
.app-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    padding: env(safe-area-inset-top, 16px) env(safe-area-inset-right, 16px) env(safe-area-inset-bottom, 16px) env(safe-area-inset-left, 16px);
}

.app-screen.active {
    display: flex;
}

/* Loading Screen */
#screen-loading {
    background: var(--color-bg-dark);
    color: var(--color-lime);
    z-index: 100;
}

.spinner {
    width: 52px;
    height: 52px;
    border: 5px solid rgba(88, 204, 2, 0.2);
    border-top: 5px solid var(--color-lime);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main Menu */
.menu-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 10px;
}

.game-logo-wrapper {
    text-align: center;
    margin-bottom: 6px;
}

.game-logo-img {
    max-width: 240px;
    height: auto;
    filter: drop-shadow(0 8px 18px rgba(0,0,0,0.6));
}

.menu-mascot-img {
    width: 96px;
    height: auto;
    animation: floatMascot 2.5s ease-in-out infinite;
    filter: drop-shadow(0 10px 14px rgba(0,0,0,0.5));
}

@keyframes floatMascot {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.header-currency {
    display: flex;
    align-items: center;
    gap: 16px;
    background: rgba(20, 23, 28, 0.92);
    border: 2px solid var(--color-gold);
    padding: 6px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.currency-badge {
    color: var(--color-gold);
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* 3D Chunky Tactile Buttons (Duolingo / Arcade Style) */
.btn-chunky {
    width: 100%;
    max-width: 320px;
    padding: 14px 20px;
    font-family: 'Outfit', sans-serif;
    font-size: 17px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 16px;
    border: 3px solid var(--color-border-dark);
    box-shadow: var(--shadow-3d);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-chunky:active {
    transform: translateY(4px);
    box-shadow: 0 1px 0 var(--color-border-dark), 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Primary Button: Nuvras Lime */
.btn-primary {
    background: linear-gradient(180deg, #58cc02 0%, #46a302 100%);
    color: #ffffff;
    box-shadow: 0 4px 0 #367d02, 0 6px 14px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-primary:active {
    box-shadow: 0 1px 0 #367d02;
}

/* Secondary Button: Chronal Blue */
.btn-secondary {
    background: linear-gradient(180deg, #1cb0f6 0%, #1899d6 100%);
    color: #ffffff;
    box-shadow: 0 4px 0 #0f7bb0, 0 6px 14px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-secondary:active {
    box-shadow: 0 1px 0 #0f7bb0;
}

/* Zen Button: Sun Gold */
.btn-zen {
    background: linear-gradient(180deg, #ffc800 0%, #e5b400 100%);
    color: #14171c;
    box-shadow: 0 4px 0 #b28c00, 0 6px 14px rgba(0, 0, 0, 0.4);
}
.btn-zen:active {
    box-shadow: 0 1px 0 #b28c00;
}

/* Sandstone / Slate Auxiliary Button */
.btn-sandstone {
    background: linear-gradient(180deg, #2c3746 0%, #1f2732 100%);
    color: #ffffff;
    border: 3px solid var(--color-border-dark);
    box-shadow: 0 4px 0 #14171c, 0 6px 14px rgba(0, 0, 0, 0.4);
}
.btn-sandstone:active {
    box-shadow: 0 1px 0 #14171c;
}

.btn-danger {
    background: linear-gradient(180deg, #ff4b4b 0%, #d82b2b 100%);
    color: #ffffff;
    box-shadow: 0 4px 0 #aa1a1a;
}

.btn-rewind {
    background: linear-gradient(180deg, #00e5ff 0%, #1cb0f6 100%);
    color: #14171c;
    border: 3px solid var(--color-border-dark);
    box-shadow: 0 4px 0 #008eb3, 0 0 16px rgba(0, 229, 255, 0.6);
}

.menu-secondary-row {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 320px;
}

.menu-secondary-row .btn-chunky {
    flex: 1;
    padding: 11px 8px;
    font-size: 14px;
}

/* ====================================================
   GAMEPLAY SCREEN & HUD
   ==================================================== */
#screen-game {
    padding: 0;
    justify-content: space-between;
}

#hud-header {
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: rgba(20, 23, 28, 0.95);
    border-bottom: 2px solid var(--color-lime);
    z-index: 20;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.hud-left {
    display: flex;
    flex-direction: column;
}

.hud-score-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-weight: 800;
}

.hud-score-val {
    font-size: 24px;
    color: var(--color-gold);
    font-weight: 900;
    line-height: 1;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    max-width: 220px;
    margin: 0 10px;
}

.hud-goal-title {
    font-size: 12px;
    color: #ffffff;
    font-weight: bold;
    white-space: nowrap;
}

.hud-goal-bar {
    width: 100%;
    height: 8px;
    background: var(--color-surface-obsidian);
    border-radius: 4px;
    border: 1px solid var(--color-border-subtle);
    overflow: hidden;
}

.hud-goal-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #1cb0f6, #58cc02);
    transition: width 0.2s ease;
}

.hud-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-btn {
    background: #202733;
    border: 2px solid var(--color-border-subtle);
    color: #ffffff;
    font-weight: 800;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    transition: all 0.15s ease;
}

.hud-btn:hover {
    border-color: var(--color-lime);
    color: var(--color-lime);
}

.hud-btn:active {
    transform: translateY(2px);
}

.hud-btn.has-charges {
    background: linear-gradient(180deg, #00e5ff 0%, #1cb0f6 100%);
    color: #14171c;
    border-color: #ffffff;
    box-shadow: 0 0 12px rgba(0, 229, 255, 0.7);
}

.combo-badge {
    position: absolute;
    top: 65px;
    right: 16px;
    background: linear-gradient(180deg, #ff9600, #ff4b4b);
    color: #ffffff;
    font-weight: 900;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
    z-index: 25;
    animation: pulseCombo 0.4s infinite alternate;
}

.combo-badge.fever-active {
    background: linear-gradient(180deg, #ffc800, #ff4b4b);
    box-shadow: 0 0 18px #ffc800;
    animation: feverGlitch 0.2s infinite alternate;
}

@keyframes pulseCombo {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}

@keyframes feverGlitch {
    0% { transform: scale(1.05) rotate(-1deg); }
    100% { transform: scale(1.1) rotate(1deg); }
}

#canvas-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#game-canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* ====================================================
   VIRTUAL TOUCH CONTROLS
   ==================================================== */
#virtual-dpad-container {
    width: 100%;
    max-width: 480px;
    height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding-bottom: env(safe-area-inset-bottom, 10px);
    z-index: 20;
}

.dpad-cross {
    position: relative;
    width: 140px;
    height: 140px;
}

.dpad-btn {
    position: absolute;
    width: 46px;
    height: 46px;
    background: linear-gradient(180deg, #2b3644 0%, #1c242f 100%);
    border: 2px solid var(--color-lime);
    border-radius: 10px;
    color: var(--color-lime);
    font-size: 22px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 0 #14171c, 0 4px 8px rgba(0,0,0,0.5);
    cursor: pointer;
    touch-action: none;
    transition: transform 0.05s ease;
}

.dpad-btn:active, .dpad-btn.touch-active {
    background: var(--color-lime);
    color: #14171c;
    transform: scale(0.92);
}

#dpad-up { top: 0; left: 47px; }
#dpad-down { bottom: 0; left: 47px; }
#dpad-left { top: 47px; left: 0; }
#dpad-right { top: 47px; right: 0; }

.dpad-center {
    position: absolute;
    top: 47px;
    left: 47px;
    width: 46px;
    height: 46px;
    background: #14171c;
    border-radius: 8px;
}

/* ====================================================
   MODALS
   ==================================================== */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 13, 17, 0.88);
    backdrop-filter: blur(6px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
    padding: 20px;
}

.modal-backdrop.active {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 380px;
    background: var(--color-surface-card);
    border: 4px solid var(--color-border-dark);
    border-radius: 22px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7), 0 0 0 2px var(--color-border-subtle);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 20px;
    gap: 16px;
    text-align: center;
    position: relative;
    color: #ffffff;
}

.modal-title {
    font-size: 26px;
    font-weight: 900;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'Outfit', sans-serif;
}

.modal-subtitle {
    font-size: 15px;
    color: var(--color-text-muted);
    font-weight: bold;
}

.stats-panel {
    width: 100%;
    background: var(--color-surface-obsidian);
    border: 2px solid var(--color-border-subtle);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    justify-content: space-around;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-lbl {
    font-size: 11px;
    color: var(--color-text-subtle);
    font-weight: 800;
    text-transform: uppercase;
}

.stat-val {
    font-size: 22px;
    font-weight: 900;
    color: var(--color-gold);
}

.victory-stars {
    display: flex;
    gap: 8px;
    font-size: 38px;
    color: #374151;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.victory-star.active {
    color: var(--color-gold);
    text-shadow: 0 0 14px rgba(255, 200, 0, 0.8);
    animation: starPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes starPop {
    0% { transform: scale(0); }
    80% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.modal-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* ====================================================
   LEVEL SELECT & SKINS SHOP
   ==================================================== */
.sub-screen-header {
    width: 100%;
    max-width: 600px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-bottom: 12px;
}

.screen-heading {
    color: #ffffff;
    font-size: 22px;
    font-weight: 900;
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
}

.scroll-container {
    width: 100%;
    max-width: 600px;
    flex: 1;
    overflow-y: auto;
    padding: 6px;
}

.levels-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
    padding-bottom: 20px;
}

.level-card {
    background: var(--color-surface-card);
    border: 3px solid var(--color-border-dark);
    box-shadow: 0 4px 0 var(--color-border-dark);
    border-radius: 16px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease;
    color: #ffffff;
}

.level-card.unlocked:hover {
    border-color: var(--color-lime);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 var(--color-border-dark), 0 0 12px var(--color-lime-glow);
}

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

.level-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    background: #161c24;
}

.level-num {
    font-size: 18px;
    font-weight: 900;
    color: #ffffff;
}

.level-name {
    font-size: 12px;
    font-weight: bold;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.2;
}

.level-stars {
    display: flex;
    gap: 2px;
    font-size: 16px;
    color: #374151;
}

.level-stars .star-filled {
    color: var(--color-gold);
}

/* Skins Shop */
.shop-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 24px;
}

.shop-item-card {
    display: flex;
    align-items: center;
    background: var(--color-surface-card);
    border: 3px solid var(--color-border-subtle);
    border-radius: 16px;
    padding: 12px 16px;
    gap: 14px;
    box-shadow: 0 4px 0 var(--color-border-dark);
    transition: all 0.15s ease;
}

.shop-item-card.equipped {
    border-color: var(--color-lime);
    box-shadow: 0 4px 0 var(--color-border-dark), 0 0 14px var(--color-lime-glow);
}

.skin-preview-swatch {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

.skin-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.skin-name {
    font-size: 16px;
    font-weight: 900;
    color: #ffffff;
}

.skin-desc {
    font-size: 12px;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.skin-btn {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    border-radius: 12px;
    border: 2px solid var(--color-border-dark);
    box-shadow: 0 3px 0 var(--color-border-dark);
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
}

.skin-btn.btn-equipped {
    background: var(--color-lime);
    color: #14171c;
    border-color: #3b8a02;
    box-shadow: 0 2px 0 #3b8a02;
    cursor: default;
}

.skin-btn.btn-equip {
    background: var(--color-blue);
    color: #ffffff;
    border-color: var(--color-border-dark);
    box-shadow: 0 3px 0 var(--color-border-dark);
}

.skin-btn.btn-buy {
    background: var(--color-gold);
    color: #14171c;
    border-color: var(--color-border-dark);
    box-shadow: 0 3px 0 var(--color-border-dark);
}

/* Guide Screen */
.guide-content {
    background: var(--color-surface-card);
    border: 3px solid var(--color-border-subtle);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--color-text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.guide-content h4 {
    color: var(--color-lime);
    font-size: 15px;
    font-weight: 800;
    margin-top: 4px;
}

.guide-content p {
    color: #cbd5e1;
}

.guide-content strong {
    color: #ffffff;
}
