:root {
    --primary-color: #00f3ff;
    --secondary-color: #ff0055;
    --bg-color: #050510;
    --text-color: #ffffff;
    --font-main: 'Kanit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden !important;
    /* Force remove scrollbars */
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
    -webkit-text-size-adjust: none;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 600px;
    background: black;
    box-shadow: 0 0 50px rgba(0, 243, 255, 0.1);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    /* Sharp images */
    image-rendering: crisp-edges;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 16, 0.95);
    transition: opacity 0.3s ease;
    pointer-events: auto;
    text-align: center;
    overflow-y: auto;
    /* Allow scrolling if shop is long */
}

.screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.screen.active {
    opacity: 1;
}

/* Typography & HUD */
.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 0 0 20px var(--primary-color), 2px 2px var(--secondary-color);
    letter-spacing: 2px;
    margin-bottom: 0.5rem;
    line-height: 1;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 2rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
    width: 80%;
    max-width: 300px;
}

.btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 0.8rem 2rem;
    font-size: 1.2rem;
    font-family: var(--font-main);
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
    border-radius: 5px;
    width: 100%;
}

.btn:hover {
    background: var(--primary-color);
    color: var(--bg-color);
    box-shadow: 0 0 30px rgba(0, 243, 255, 0.8);
    transform: scale(1.05);
}

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

.btn.secondary {
    border-color: #ffffff;
    color: #ffffff;
    box-shadow: none;
}

.btn.secondary:hover {
    background: #ffffff;
    color: var(--bg-color);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

.btn.small {
    padding: 0.5rem 1rem;
    font-size: 1rem;
    width: auto;
}

.btn.back-btn {
    margin-top: 2rem;
    width: auto;
    border-color: #888;
    color: #888;
}

.instructions {
    margin-top: 2rem;
    font-size: 1rem;
    color: #888;
}

.instructions span {
    color: var(--secondary-color);
    font-weight: bold;
    border: 1px solid var(--secondary-color);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin: 0 0.2rem;
}

/* Shop & Selection UI */
.currency-display {
    font-size: 1.5rem;
    color: gold;
    margin-bottom: 20px;
    font-weight: bold;
}

.shop-container,
.grid-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 90%;
}

.shop-item,
.grid-item {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border: 2px solid transparent;
}

.shop-item h3 {
    font-size: 1rem;
    color: var(--primary-color);
}

.shop-item p {
    color: gold;
    font-size: 1.2rem;
    font-weight: bold;
}

.grid-item {
    cursor: pointer;
    transition: all 0.2s;
}

.grid-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.grid-item.selected {
    border-color: var(--primary-color);
    background: rgba(0, 243, 255, 0.15);
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.grid-item img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.select-section {
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.select-section h3 {
    margin-bottom: 10px;
    color: #aaa;
    text-transform: uppercase;
    font-size: 0.9rem;
}

/* HUD specific */
#hud {
    background: transparent;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 2rem;
    pointer-events: none;
}

.score-container {
    text-align: left;
}

.label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
}

#score {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
    line-height: 1;
}

#hud-coins {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Game Over specific */
#game-over h1 {
    font-size: 3.5rem;
    color: var(--secondary-color);
    text-shadow: 0 0 20px var(--secondary-color);
    margin-bottom: 2rem;
}

.final-score,
.high-score {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.high-score {
    color: #ffd700;
    margin-bottom: 2rem;
}

#controls {
    position: absolute;
    bottom: 80px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 40px;
    pointer-events: none;
}

#controls.hidden {
    display: none;
}

.control-btn {
    pointer-events: auto;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-size: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: transform 0.1s;
    user-select: none;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.9);
}

#hearts-container {
    padding: 10px;
    font-size: 24px;
    text-align: center;
}

.heart {
    display: inline-block;
    animation: heartbeat 1.5s infinite;
}

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

    10% {
        transform: scale(1.1);
    }

    20% {
        transform: scale(1);
    }

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



.invulnerable {
    animation: blink 0.2s infinite;
    opacity: 0.7;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }

    100% {
        opacity: 1;
    }
}

/* Skill Button */
#skill-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    /* Enable clicking */
}

.skill-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.1s;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.3);
}

.skill-btn:active {
    transform: scale(0.95);
}

.skill-btn.disabled {
    filter: grayscale(1);
    border-color: #555;
    color: #555;
    cursor: not-allowed;
}

#skill-cooldown-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    /* Grows from 0% to 100% or shrinks */
    background: rgba(0, 0, 0, 0.7);
    transition: height 0.1s linear;
}

#skill-icon {
    position: relative;
    z-index: 1;
}

#skill-label {
    margin-top: 5px;
    text-shadow: 0 0 2px black;
    font-weight: bold;
}

/* Skill Timer */
#skill-timer {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 5px #000;
    pointer-events: none;
    z-index: 2;
    -webkit-text-stroke: 1px black;
}

#skill-timer.hidden {
    display: none;
}

#skill-timer.pulsate {
    color: #ff3333;
    animation: timerPulse 0.5s infinite alternate;
}

@keyframes timerPulse {
    from {
        transform: translate(-50%, -50%) scale(1);
    }

    to {
        transform: translate(-50%, -50%) scale(1.3);
    }
}

/* Gacha Overlay */
#gacha-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.gacha-container {
    text-align: center;
    position: relative;
    width: 300px;
}

#gacha-spinner {
    width: 150px;
    height: 150px;
    margin: 20px auto;
    border: 5px solid gold;
    border-radius: 10px;
    background: #222;
    overflow: hidden;
    position: relative;
    box-shadow: 0 0 20px gold;
}

#gacha-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#gacha-result {
    /* Position below the spinner naturally */
    margin-top: 10px;
    position: relative;
    width: 100%;
}

.glow-bg {
    position: absolute;
    top: -50px;
    /* Shift up to cover image too */
    left: 50%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, gold 0%, transparent 70%);
    transform: translate(-50%, -50%);
    z-index: -1;
    animation: rotate 5s linear infinite;
    opacity: 0.5;
}

@keyframes rotate {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

#gacha-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
}

.flash-anim {
    animation: flash 0.5s ease-out;
}

@keyframes flash {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

#gacha-name {
    font-size: 2rem;
    color: gold;
    text-shadow: 0 0 5px black;
}

/* Code Redemption */
.code-section {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 20px;
}

#code-input {
    background: #000;
    border: 2px solid gold;
    color: white;
    padding: 10px;
    font-family: 'Kanit', sans-serif;
    font-size: 1rem;
    text-transform: uppercase;
    text-align: center;
    width: 150px;
    border-radius: 5px;
}

#code-input:focus {
    outline: none;
    box-shadow: 0 0 10px gold;
}

#code-submit-btn {
    border: 2px solid gold;
    background: #444;
}