:root {
    --bg-dark: #222034;
    --red: #d95763;
    --green: #99e550;
    --blue: #5b6ee1;
    --yellow: #fbf236;
    --white: #ffffff;
    --text-shadow: 4px 4px 0px rgba(0,0,0,0.5);
    --font: 'Press Start 2P', cursive;
}

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

body {
    background-color: #000;
    color: var(--white);
    font-family: var(--font);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 1024px;
    height: 100%;
    max-height: 768px;
    background-color: var(--bg-dark);
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}

/* Screen Shake effect via class */
.shake {
    animation: screenshake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes screenshake {
    0% { transform: translate(0, 0); }
    20% { transform: translate(-10px, 5px); }
    40% { transform: translate(10px, -5px); }
    60% { transform: translate(-10px, -5px); }
    80% { transform: translate(10px, 5px); }
    100% { transform: translate(0, 0); }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated; /* Crisp pixels */
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 10;
    padding: 20px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    text-shadow: 2px 2px 0 #000;
    font-size: 14px;
    line-height: 1.5;
}

@media (max-width: 600px) {
    .top-bar {
        flex-direction: column;
        gap: 10px;
        font-size: 10px;
    }
}

.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-blue { color: #639bff; }
.text-green { color: var(--green); }

.powerups-container {
    position: absolute;
    top: 60px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}

.powerup-icon {
    background: rgba(0,0,0,0.5);
    border: 2px solid var(--white);
    padding: 5px 10px;
    font-size: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.powerup-bar {
    width: 50px;
    height: 10px;
    background: #333;
    border: 1px solid #fff;
}

.powerup-fill {
    height: 100%;
    background: var(--yellow);
    width: 100%;
}

/* Screens */
.screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(34, 32, 52, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    text-align: center;
    padding: 20px;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

h1 {
    font-size: 48px;
    line-height: 1.5;
    margin-bottom: 40px;
    text-shadow: var(--text-shadow);
    color: var(--white);
}

@media (max-width: 600px) { h1 { font-size: 28px; } }

.bounce-text {
    animation: bounce 2s infinite ease-in-out;
}

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

.blink {
    animation: blink 1s infinite alternate;
    margin-bottom: 40px;
    font-size: 14px;
}

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

.btn-group {
    display: flex;
    gap: 20px;
    margin-top: 20px;
}

@media (max-width: 600px) {
    .btn-group {
        flex-direction: column;
    }
}

.btn {
    font-family: var(--font);
    font-size: 16px;
    padding: 20px 30px;
    border: 4px solid #fff;
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #000;
    box-shadow: 4px 4px 0 #000;
    transition: transform 0.1s, box-shadow 0.1s;
}

.btn:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000;
}

.btn-green { background-color: var(--green); }
.btn-blue { background-color: var(--blue); }
.btn-red { background-color: var(--red); }

.mt-20 { margin-top: 40px; }

.results-box {
    background: rgba(0,0,0,0.5);
    border: 4px solid var(--white);
    padding: 30px;
    margin-bottom: 40px;
    font-size: 18px;
    line-height: 2;
}

.tips {
    margin-top: 40px;
    font-size: 10px;
    color: #aaa;
    max-width: 400px;
    line-height: 1.5;
}

/* Shop UI */
.shop-header {
    background: #000;
    padding: 15px 30px;
    border: 4px solid var(--yellow);
    margin-bottom: 30px;
    font-size: 14px;
}

.shop-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    max-width: 800px;
    width: 100%;
    overflow-y: auto;
    max-height: 50vh;
    padding: 10px;
}

@media (max-width: 768px) {
    .shop-items { grid-template-columns: 1fr; }
}

.shop-item {
    background: rgba(0,0,0,0.6);
    border: 4px solid #555;
    padding: 20px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.shop-item.maxed {
    border-color: var(--green);
}

.shop-item-title {
    font-size: 14px;
    color: var(--blue);
}

.shop-item-desc {
    font-size: 10px;
    line-height: 1.5;
    color: #ccc;
    flex-grow: 1;
}

.shop-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-item-cost {
    font-size: 12px;
}

.shop-item-level {
    font-size: 10px;
    color: #888;
}

.btn-buy {
    font-family: var(--font);
    font-size: 10px;
    padding: 10px;
    background: var(--yellow);
    color: #000;
    border: 2px solid #fff;
    cursor: pointer;
}

.btn-buy:disabled {
    background: #555;
    color: #888;
    cursor: not-allowed;
}

/* Custom Webkit scrollbar for shop */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: #111; }
::-webkit-scrollbar-thumb { background: var(--blue); border: 2px solid #000; }
