@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;800&display=swap');

body {
    background: #000;
    margin: 0;
    padding: 0;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    font-family: 'Inter', sans-serif;
}


body.hide-mouse-cursor canvas {
    cursor: none;
}

/* ГЛАВНЫЙ КОНТЕЙНЕР - ЖЕСТКИЙ РАЗМЕР */
#game-container {
    width: 960px;
    height: 540px;
    background: #090c18;
    transform-origin: 0 0;
    /* Важно для масштабирования от левого верхнего угла */
    position: absolute;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    isolation: isolate;
}

/* ФОН */
#game-container::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #020617 80%);
    z-index: 0;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* UI BASE */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    z-index: 10;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 16px;
    padding: 0 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    color: #fff;
}

.stat-group {
    display: flex;
    gap: 20px;
    align-items: center;
    justify-self: start;
}

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

.stat-label {
    font-size: 10px;
    opacity: 0.7;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 20px;
    font-weight: bold;
}

.stage-display {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    min-width: 0;
    justify-self: center;
    text-align: center;
    max-width: 280px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.icon-btn {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.icon-btn .btn-label {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.stat-group.right {
    gap: 12px;
    justify-self: end;
    margin-right: 200px;
}

.icon-btn span[aria-hidden="true"] {
    font-size: 18px;
    line-height: 1;
    transition: filter 0.25s ease, opacity 0.25s ease;
}

.icon-btn.is-muted span[aria-hidden="true"] {
    filter: brightness(0.65);
    opacity: 0.55;
}

.interaction-msg {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 14px;
    background: rgba(0, 0, 0, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #fff;
    font-size: 14px;
    max-width: 90%;
    text-align: center;
    z-index: 15;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.controls {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 12px;
    z-index: 15;
}

body.touch-mode .controls {
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
    justify-content: space-between;
    padding: 0 16px;
}

.control-btn {
    width: 70px;
    height: 70px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(12, 16, 32, 0.9);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.35);
}

body.touch-mode .control-btn {
    flex: 0 0 auto;
}

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

/* POPUPS */
.pickup-info {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(16, 20, 40, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 4px solid #74f2b3;
    padding: 6px 16px;
    border-radius: 20px;
    z-index: 20;
    display: flex;
    align-items: center;
    max-width: 90%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s;
}

.pickup-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pickup-label {
    color: #74f2b3;
    font-weight: bold;
    margin-right: 8px;
    font-size: 12px;
}

.pickup-desc {
    color: #fff;
    font-size: 12px;
    line-height: 1.3;
    opacity: 0.9;
    word-break: break-word;
}

/* MENU OVERLAYS */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 960px;
    height: 540px;
    background: rgba(5, 8, 20, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 0 20px;
}

#startMenu.start-screen {
    background: radial-gradient(circle at 50% -20%, rgba(79, 70, 229, 0.25), transparent 60%), rgba(2, 5, 18, 0.94);
    backdrop-filter: blur(6px);
    padding: 0;
}

.start-panel {
    width: min(520px, 100%);
    padding: clamp(32px, 5vw, 48px);
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), rgba(8, 11, 38, 0.95));
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 40px 60px rgba(2, 5, 18, 0.8), 0 0 120px rgba(79, 70, 229, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(30px, 4vw, 40px);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.start-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 25%, rgba(79, 70, 229, 0.35), rgba(14, 165, 233, 0.08) 45%, transparent 70%);
    filter: blur(14px);
    opacity: 0.8;
    pointer-events: none;
}

.start-panel::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 32px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: none;
}

.start-panel > * {
    position: relative;
    z-index: 1;
}

.start-title {
    font-size: clamp(2.4rem, 4vw, 3rem);
    letter-spacing: 0.32em;
    line-height: 1.1;
    text-transform: uppercase;
    margin: 0;
    background: linear-gradient(120deg, #ffffff, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 10px 30px rgba(79, 70, 229, 0.6);
}

.start-title br {
    display: block;
    line-height: 1;
}

.start-cta {
    width: min(260px, 100%);
    border-radius: 999px;
    font-size: 1rem;
    background: linear-gradient(120deg, #c084fc, #6366f1);
    box-shadow: 0 15px 30px rgba(99, 102, 241, 0.45), 0 4px 18px rgba(14, 165, 233, 0.35);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 14px 32px;
    border: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.start-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 35px rgba(99, 102, 241, 0.5), 0 6px 24px rgba(14, 165, 233, 0.45);
}

.start-cta:active {
    transform: translateY(1px);
}

#levelOverlay {
    background: radial-gradient(circle at 50% 10%, rgba(119, 75, 255, 0.08), rgba(2, 5, 15, 0.95));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 30px 50px rgba(3, 6, 16, 0.85);
}

.menu-card {
    width: 700px;
    height: 400px;
    display: flex;
    background: #131629;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.menu-visual {
    width: 40%;
    background: radial-gradient(circle at center, #4f46e5 0%, #0f172a 70%);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.orb-visual {
    width: 60px;
    height: 60px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 30px #fff;
    animation: pulse 2s infinite;
}

.menu-content {
    width: 60%;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #fff;
}

.pre-title {
    font-size: 12px;
    letter-spacing: 4px;
    opacity: 0.6;
    margin-bottom: 10px;
}

.game-title {
    font-size: 48px;
    line-height: 1;
    margin: 0 0 20px 0;
    background: linear-gradient(to right, #fff, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.menu-desc {
    font-size: 14px;
    opacity: 0.7;
    margin-bottom: 30px;
    line-height: 1.5;
}

.cta-button {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    border: none;
    padding: 15px 30px;
    color: #fff;
    font-weight: bold;
    font-size: 18px;
    border-radius: 8px;
    cursor: pointer;
    letter-spacing: 1px;
    transition: transform 0.1s;
}

.cta-button:hover {
    transform: scale(1.02);
}

.cta-button:active {
    transform: scale(0.98);
}

#levelOverlay .cta-button {
    min-width: 260px;
    padding: 16px 48px;
    font-size: 1rem;
    border-radius: 999px;
    box-shadow: 0 15px 30px rgba(30, 9, 139, 0.45);
    letter-spacing: 1.2px;
    margin-top: 6px;
}

.pause-card {
    max-width: 460px;
    margin: 0 auto;
}

.pause-actions {
    display: flex;
    justify-content: center;
    margin-top: 18px;
}

/* UPGRADES */
.upgrade-card {
    width: min(720px, 100%);
    background: linear-gradient(180deg, rgba(32, 27, 86, 0.95), rgba(8, 9, 28, 0.9));
    border-radius: 32px;
    padding: 42px 48px 36px;
    text-align: center;
    color: #f4f5ff;
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 40px 60px rgba(5, 6, 20, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
}

.upgrade-card h2 {
    font-size: clamp(2.4rem, 3vw, 3.2rem);
    margin: 0;
    letter-spacing: 1px;
    font-weight: 800;
    text-transform: uppercase;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.upgrade-card p {
    margin: 0;
    font-size: 1.1rem;
    color: rgba(244, 245, 255, 0.8);
    line-height: 1.6;
    max-width: 540px;
}

.choices-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
    margin-top: 8px;
}

.upgrade {
    background: radial-gradient(circle at 10% 20%, rgba(129, 140, 248, 0.28), transparent 65%);
    padding: 18px 20px;
    border-radius: 18px;
    cursor: pointer;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 30px rgba(2, 4, 12, 0.6);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.upgrade:hover {
    border-color: rgba(129, 140, 248, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 20px 40px rgba(6, 10, 32, 0.5);
}

.upgrade.selected {
    border-color: rgba(14, 165, 233, 0.9);
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(67, 56, 202, 0.4));
    box-shadow: 0 16px 35px rgba(14, 165, 233, 0.25);
}

.upgrade h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #e4e7ff;
    text-transform: none;
}

.upgrade p {
    margin: 0;
    font-size: 0.95rem;
    color: rgba(244, 245, 255, 0.65);
    line-height: 1.4;
}

.stats-row {
    display: flex;
    gap: 30px;
    margin-bottom: 20px;
}

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

.ms-val {
    font-size: 24px;
    font-weight: bold;
}

.ms-lbl {
    font-size: 10px;
    opacity: 0.5;
}

.hidden {
    display: none !important;
}

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

    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}
