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

:root {
    --cyan: #00eaff;
    --blue: #3478ff;
    --purple: #9b5cff;
    --pink: #ff3cac;
    --green: #39ff88;
    --yellow: #ffd93d;
    --red: #ff4d67;
    --dark: #050814;
    --panel: rgba(7, 13, 32, 0.92);
    --border: rgba(0, 234, 255, 0.3);
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #02040d;
    font-family: Arial, Helvetica, sans-serif;
    color: white;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

button {
    border: none;
    outline: none;
    cursor: pointer;
    color: white;
    font-family: inherit;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #02040d;
}

#gameCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

/* =========================
   HUD
========================= */

#hud {
    position: absolute;
    z-index: 10;
    top: 0;
    left: 0;
    width: 100%;
    padding: 18px 25px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
}

.hud-left,
.hud-right {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.hud-item {
    min-width: 110px;
    padding: 10px 16px;
    border: 1px solid rgba(0, 234, 255, 0.22);
    background: rgba(3, 9, 25, 0.75);
    backdrop-filter: blur(8px);
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}

.hud-label {
    display: block;
    font-size: 9px;
    letter-spacing: 2px;
    color: #7c8ba8;
    margin-bottom: 4px;
}

.hud-item > span:not(.hud-label) {
    font-size: 18px;
    font-weight: bold;
}

.hud-center {
    text-align: center;
}

#levelText {
    padding: 8px 22px;
    border-radius: 30px;
    background: rgba(20, 35, 80, 0.8);
    border: 1px solid rgba(0, 234, 255, 0.35);
    color: var(--cyan);
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 2px;
    box-shadow: 0 0 20px rgba(0, 234, 255, 0.15);
}

#comboText {
    margin-top: 8px;
    color: var(--yellow);
    font-size: 20px;
    font-weight: 900;
    text-shadow: 0 0 12px rgba(255, 217, 61, 0.8);
    transition: 0.2s;
}

.combo-hidden {
    opacity: 0;
}

#healthContainer {
    display: flex;
    gap: 4px;
    white-space: nowrap;
}

.heart {
    font-size: 16px;
}

.empty-heart {
    filter: grayscale(1);
    opacity: 0.25;
}

#powerupHUD {
    position: absolute;
    left: 50%;
    top: 95px;
    transform: translateX(-50%);
    min-width: 220px;
    text-align: center;
}

#powerupName {
    display: block;
    color: var(--cyan);
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.powerup-bar {
    height: 5px;
    background: rgba(255,255,255,0.12);
    border-radius: 10px;
    overflow: hidden;
}

#powerupBar {
    width: 100%;
    height: 100%;
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan);
}

/* =========================
   SCREENS
========================= */

.screen {
    position: absolute;
    z-index: 20;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background:
        radial-gradient(
            circle at center,
            rgba(22, 35, 80, 0.28),
            rgba(0, 0, 0, 0.72)
        );
    backdrop-filter: blur(3px);
}

.hidden {
    display: none !important;
}

.overlay {
    background: rgba(1, 3, 12, 0.72);
}

/* =========================
   MENU
========================= */

.menu-panel {
    width: min(460px, 90vw);
    padding: 45px;
    text-align: center;
    border-radius: 24px;
    border: 1px solid rgba(0, 234, 255, 0.28);
    background:
        linear-gradient(
            145deg,
            rgba(12, 22, 49, 0.96),
            rgba(4, 9, 24, 0.97)
        );
    box-shadow:
        0 30px 80px rgba(0,0,0,0.65),
        0 0 50px rgba(0, 160, 255, 0.08);
    animation: panelIn 0.45s ease;
}

@keyframes panelIn {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.title-decoration {
    color: var(--cyan);
    letter-spacing: 18px;
    margin-bottom: 15px;
    text-shadow: 0 0 20px var(--cyan);
}

.menu-panel h1 {
    font-size: clamp(45px, 8vw, 76px);
    line-height: 0.85;
    letter-spacing: 7px;
    font-weight: 900;
    color: white;
    text-shadow:
        0 0 12px rgba(255,255,255,0.6),
        0 0 30px rgba(0,234,255,0.35);
}

.menu-panel h2 {
    font-size: 25px;
    letter-spacing: 11px;
    color: var(--cyan);
    margin-top: 10px;
}

.subtitle {
    margin-top: 15px;
    font-size: 11px;
    letter-spacing: 5px;
    color: #7283a5;
}

.menu-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 30px 0 25px;
}

.menu-stats div {
    min-width: 110px;
    padding: 12px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
}

.menu-stats span {
    font-size: 18px;
}

.menu-stats strong {
    margin-left: 5px;
    font-size: 18px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.menu-buttons button,
.panel-footer button,
.large-panel > button,
.instructions-panel > button,
.record-panel > button {
    width: 100%;
    min-height: 48px;
    padding: 13px 20px;
    border-radius: 10px;
    background: rgba(255,255,255,0.055);
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    font-weight: bold;
    letter-spacing: 1px;
    transition: 0.2s;
}

.menu-buttons button:hover,
.panel-footer button:hover,
.large-panel > button:hover,
.instructions-panel > button:hover,
.record-panel > button:hover {
    transform: translateY(-2px);
    background: rgba(0,234,255,0.1);
    border-color: rgba(0,234,255,0.45);
    box-shadow: 0 5px 25px rgba(0,234,255,0.1);
}

.primary-button {
    background: linear-gradient(135deg, #006fbe, #2847bd) !important;
    border-color: rgba(0,234,255,0.6) !important;
    box-shadow: 0 0 25px rgba(0,170,255,0.15);
}

.primary-button:hover {
    background: linear-gradient(135deg, #0088e8, #3859df) !important;
    box-shadow: 0 0 35px rgba(0,170,255,0.3) !important;
}

.version {
    margin-top: 25px;
    color: #44516a;
    font-size: 9px;
    letter-spacing: 2px;
}

/* =========================
   LARGE PANELS
========================= */

.large-panel {
    width: min(1000px, 92vw);
    max-height: 90vh;
    overflow-y: auto;
    padding: 30px;
    border-radius: 22px;
    background: rgba(5, 11, 28, 0.97);
    border: 1px solid rgba(0,234,255,0.25);
    box-shadow: 0 30px 80px rgba(0,0,0,0.6);
}

.large-panel::-webkit-scrollbar {
    width: 5px;
}

.large-panel::-webkit-scrollbar-thumb {
    background: #174e69;
    border-radius: 10px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.panel-header h2 {
    font-size: 30px;
    color: var(--cyan);
}

.panel-header p {
    margin-top: 5px;
    color: #6e7c98;
    font-size: 12px;
}

.currency {
    padding: 12px 18px;
    border-radius: 10px;
    background: rgba(255,217,61,0.07);
    border: 1px solid rgba(255,217,61,0.2);
    color: var(--yellow);
    font-weight: bold;
}

/* =========================
   UPGRADES
========================= */

.upgrade-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.upgrade-card {
    position: relative;
    padding: 18px;
    background: linear-gradient(
        145deg,
        rgba(18,29,58,0.8),
        rgba(7,13,29,0.8)
    );
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    transition: 0.2s;
}

.upgrade-card:hover {
    border-color: rgba(0,234,255,0.3);
    transform: translateY(-2px);
}

.upgrade-card.locked {
    opacity: 0.55;
}

.upgrade-top {
    display: flex;
    align-items: center;
    gap: 12px;
}

.upgrade-icon {
    width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
    background: rgba(0,234,255,0.08);
    font-size: 23px;
}

.upgrade-info h3 {
    font-size: 15px;
}

.upgrade-info p {
    color: #6e7c98;
    font-size: 10px;
    margin-top: 3px;
}

.upgrade-level {
    margin: 15px 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-label {
    color: #7283a5;
    font-size: 10px;
    letter-spacing: 1px;
}

.level-value {
    color: var(--cyan);
    font-weight: bold;
}

.level-dots {
    display: flex;
    gap: 4px;
}

.level-dot {
    width: 18px;
    height: 4px;
    border-radius: 5px;
    background: rgba(255,255,255,0.1);
}

.level-dot.active {
    background: var(--cyan);
    box-shadow: 0 0 8px rgba(0,234,255,0.7);
}

.upgrade-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.upgrade-cost {
    color: var(--yellow);
    font-size: 12px;
}

.upgrade-button {
    padding: 9px 13px;
    border-radius: 7px;
    background: #0d4870;
    border: 1px solid rgba(0,234,255,0.25);
    font-size: 10px;
    font-weight: bold;
}

.upgrade-button:hover {
    background: #116a98;
}

.upgrade-button:disabled {
    cursor: not-allowed;
    opacity: 0.35;
}

.max-level {
    color: var(--green);
    font-size: 11px;
    font-weight: bold;
}

.panel-footer {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 25px;
}

.panel-footer button {
    width: auto;
}

.danger-button {
    color: var(--red) !important;
    border-color: rgba(255,77,103,0.2) !important;
}

/* =========================
   INSTRUCTIONS
========================= */

.instructions-panel {
    text-align: center;
}

.instructions-panel h2 {
    color: var(--cyan);
    font-size: 30px;
    margin-bottom: 25px;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.instruction-card {
    padding: 18px;
    background: rgba(255,255,255,0.035);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
}

.big-icon {
    display: block;
    font-size: 28px;
    margin-bottom: 10px;
}

.instruction-card h3 {
    color: var(--cyan);
    font-size: 12px;
    letter-spacing: 1px;
}

.instruction-card p {
    color: #7c8ba8;
    font-size: 10px;
    line-height: 1.6;
    margin-top: 8px;
}

.controls-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 20px 0;
}

.controls-info div {
    padding: 8px;
    color: #71809c;
    font-size: 10px;
}

.controls-info span {
    color: white;
    font-weight: bold;
    margin-right: 5px;
}

/* =========================
   RECORD
========================= */

.trophy {
    font-size: 55px;
    margin-bottom: 10px;
}

.record-panel h2 {
    color: var(--yellow);
}

.record-number {
    margin-top: 25px;
    font-size: 65px;
    font-weight: 900;
    color: white;
    text-shadow: 0 0 30px rgba(255,217,61,0.45);
}

.record-panel > p {
    color: #687792;
    letter-spacing: 3px;
    font-size: 10px;
}

.record-details {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 30px 0;
}

.record-details div {
    min-width: 140px;
    padding: 13px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
}

.record-details span {
    display: block;
    color: #65738d;
    font-size: 9px;
}

.record-details strong {
    display: block;
    margin-top: 5px;
}

/* =========================
   GAME OVER / PAUSE
========================= */

.pause-icon {
    color: var(--cyan);
    font-size: 45px;
    margin-bottom: 10px;
}

.gameover-icon {
    font-size: 50px;
}

.gameover-panel h2 {
    color: var(--red);
}

.final-score {
    margin: 25px 0;
}

.final-score span {
    display: block;
    color: #66748f;
    font-size: 10px;
    letter-spacing: 2px;
}

.final-score strong {
    display: block;
    font-size: 55px;
    margin-top: 4px;
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 20px;
}

.final-stats div {
    min-width: 115px;
    padding: 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
}

.final-stats span {
    display: block;
    color: #66748f;
    font-size: 9px;
}

.final-stats strong {
    display: block;
    margin-top: 4px;
}

.new-record {
    padding: 10px;
    margin-bottom: 18px;
    border-radius: 8px;
    background: rgba(255,217,61,0.08);
    border: 1px solid rgba(255,217,61,0.25);
    color: var(--yellow);
    font-weight: bold;
    font-size: 12px;
}

/* =========================
   MESSAGES
========================= */

#messageContainer {
    position: absolute;
    z-index: 50;
    top: 150px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.game-message {
    padding: 10px 18px;
    margin-bottom: 8px;
    border-radius: 20px;
    background: rgba(3,10,28,0.9);
    border: 1px solid rgba(0,234,255,0.35);
    color: var(--cyan);
    font-size: 12px;
    font-weight: bold;
    animation: messageAnimation 1.7s ease forwards;
}

@keyframes messageAnimation {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }

    15% {
        opacity: 1;
        transform: translateY(0);
    }

    75% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-25px);
    }
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 800px) {

    .upgrade-grid {
        grid-template-columns: 1fr;
    }

    .instruction-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hud-item {
        min-width: 80px;
        padding: 7px 10px;
    }

    .hud-label {
        font-size: 7px;
    }

    .hud-item > span:not(.hud-label) {
        font-size: 13px;
    }

    #hud {
        padding: 10px;
    }

    #powerupHUD {
        top: 75px;
    }
}

@media (max-width: 550px) {

    .menu-panel {
        padding: 30px 20px;
    }

    .large-panel {
        padding: 18px;
    }

    .instruction-grid {
        grid-template-columns: 1fr;
    }

    .controls-info {
        grid-template-columns: repeat(2, 1fr);
    }

    .hud-center {
        display: none;
    }

    .hud-left,
    .hud-right {
        gap: 5px;
    }

    .hud-item {
        min-width: auto;
    }

    .panel-footer {
        flex-direction: column;
    }

    .panel-footer button {
        width: 100%;
    }
}