/* Core Styling & Design System */
:root {
    --bg-dark: #09090e;
    --bg-card: rgba(18, 18, 28, 0.75);
    --primary: #ff6b8b;
    --primary-glow: rgba(255, 107, 139, 0.4);
    --secondary: #4dccc6;
    --secondary-glow: rgba(77, 204, 198, 0.3);
    --accent: #ffd166;
    --text-light: #f3f4f6;
    --text-muted: #9ca3af;
    --success: #6c5ce7;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.03);
    --shadow-main: 0 16px 32px rgba(0, 0, 0, 0.5);
    --font-heading: 'Fredoka', system-ui, sans-serif;
    --font-body: 'Outfit', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none; /* Prevents default zooming and scrolling on mobile */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-body);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background animated gradient blobs */
body::before, body::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    border-radius: 50%;
    filter: blur(100px);
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}
body::before {
    background: var(--primary);
    top: 10%;
    left: 15%;
    animation: floatBlob 20s infinite alternate ease-in-out;
}
body::after {
    background: var(--secondary);
    bottom: 10%;
    right: 15%;
    animation: floatBlob 25s infinite alternate-reverse ease-in-out;
}

@keyframes floatBlob {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

/* App Wrapper for Desktop Layout */
#app-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    max-width: 1400px;
    padding: 20px;
    z-index: 1;
}

/* Desktop Sidebars */
.desktop-sidebar {
    flex: 1;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    z-index: 2;
}

.left-sidebar {
    text-align: right;
    align-items: flex-end;
}

.right-sidebar {
    text-align: left;
    align-items: flex-start;
}

.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 24px;
    padding: 24px;
    box-shadow: var(--shadow-main);
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.sidebar-card h1 {
    font-family: var(--font-heading);
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-card p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.cat-decoration {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.pulsing-cat {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px var(--primary-glow);
    animation: heartbeat 3s infinite ease-in-out;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.controls-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.controls-list li {
    font-size: 0.9rem;
    color: var(--text-light);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-badge {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass-border);
    padding: 3px 8px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.8rem;
    color: var(--accent);
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.mock-qr {
    font-size: 2rem;
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px dashed rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qr-container small {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* 9:16 Game Container Definition */
#game-container {
    width: 100%;
    height: 100%;
    max-width: 450px;
    max-height: 800px;
    aspect-ratio: 9/16;
    background-color: #0e0e18;
    border-radius: 32px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 107, 139, 0.05);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: radial-gradient(circle at center, #1b1b2d 0%, #0d0d16 100%);
}

/* HUD Overlay */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    z-index: 20;
    animation: fadeIn 0.4s ease-out;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.score-box, .high-score-box {
    background: rgba(15, 15, 25, 0.7);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 16px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    display: flex;
    gap: 8px;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.score-box {
    color: var(--text-light);
    border-left: 3px solid var(--primary);
}

.high-score-box {
    color: var(--accent);
    border-left: 3px solid var(--accent);
}

/* Power Up Status Indicators */
#power-up-status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 140px;
    align-self: flex-start;
}

.power-indicator {
    background: rgba(15, 15, 25, 0.85);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideInLeft 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.indicator-icon {
    font-size: 1.1rem;
}

.indicator-bar-container {
    flex-grow: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.indicator-bar {
    height: 100%;
    width: 100%;
    border-radius: 3px;
    transition: width 0.1s linear;
}

#catnip-indicator {
    border-left: 3px solid var(--secondary);
}
#catnip-bar {
    background: var(--secondary);
    box-shadow: 0 0 8px var(--secondary-glow);
}

#shield-indicator {
    border-left: 3px solid #ff9ff3;
}
#shield-bar {
    background: #ff9ff3;
    box-shadow: 0 0 8px rgba(255, 159, 243, 0.5);
}

/* Menu & Overlay Screens */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(8, 8, 14, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px;
    z-index: 30;
    transition: opacity 0.3s ease, visibility 0.3s;
}

.overlay-content {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    animation: scaleUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
}

/* Main Menu Typography & Styling */
.logo-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.cat-avatar-container {
    position: relative;
    width: 110px;
    height: 110px;
    margin-bottom: 8px;
}

.avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 4px solid var(--primary);
    box-shadow: 0 12px 24px rgba(255, 107, 139, 0.3);
    object-fit: cover;
    background-color: #1b1b2d;
}

.scared-sweat {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 2.2rem;
    animation: sweatDrop 2.5s infinite ease-in-out;
}

@keyframes sweatDrop {
    0%, 100% { transform: translateY(0) scale(0.9); opacity: 0; }
    30% { opacity: 1; }
    50% { transform: translateY(12px) scale(1); }
    80%, 99% { transform: translateY(22px) scale(0.8); opacity: 0; }
}

.game-title {
    font-family: var(--font-heading);
    font-size: 2.3rem;
    font-weight: 800;
    color: var(--text-light);
    letter-spacing: -0.5px;
    text-shadow: 0 4px 12px rgba(0,0,0,0.5);
    background: linear-gradient(135deg, var(--text-light) 30%, var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.game-subtitle {
    font-size: 0.95rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Settings Menu Layout */
#settings-menu h2 {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--text-light);
}

.settings-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.settings-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.language-selector {
    display: flex;
    gap: 10px;
    width: 100%;
}

.btn-lang {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
    padding: 10px 0;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-lang.active {
    background: var(--primary);
    color: var(--text-light);
    border-color: var(--primary);
    box-shadow: 0 0 12px var(--primary-glow);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    color: var(--text-light);
    font-weight: 500;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 14px;
}

.volume-icon {
    font-size: 1.1rem;
}

/* Styled HTML5 Slider Range Input */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    flex-grow: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: transparent;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--secondary);
    box-shadow: 0 0 8px var(--secondary-glow);
    margin-top: -7px;
    transition: transform 0.1s ease, background-color 0.1s;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: var(--accent);
    box-shadow: 0 0 10px rgba(255, 209, 102, 0.4);
}

/* Game Over Layout */
.game-over-title {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    color: var(--primary);
    text-shadow: 0 0 15px var(--primary-glow);
    letter-spacing: -1px;
}

.game-over-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 80%;
    margin-top: -10px;
}

.stats-panel {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 18px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
}

.stat-row span {
    color: var(--text-muted);
}

.stat-row strong {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    color: var(--text-light);
}

#final-best {
    color: var(--accent);
}

/* Button Design System */
.menu-buttons {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    outline: none;
    transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.1), box-shadow 0.15s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #ff4f73);
    color: var(--text-light);
    box-shadow: 0 8px 20px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 10px 24px rgba(255, 107, 139, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-glow {
    position: relative;
    overflow: hidden;
}

.btn-glow::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    transform: rotate(30deg);
    animation: shine 4s infinite linear;
}

@keyframes shine {
    0% { transform: translate(-100%, -100%) rotate(30deg); }
    100% { transform: translate(100%, 100%) rotate(30deg); }
}

.credits {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Utilities */
.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    position: absolute; /* Keeps it out of flex flow */
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.85); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideInLeft {
    from { transform: translateX(-40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
    .desktop-sidebar {
        display: none !important; /* Hide sidebars on smaller screens/tablets */
    }
    #app-wrapper {
        padding: 0;
    }
}

@media (max-width: 480px) {
    #game-container {
        border-radius: 0;
        border: none;
        max-width: 100%;
        max-height: 100%;
        height: 100vh;
        width: 100vw;
    }
}
