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

:root {
  --primary-color: #ff9900;
  --secondary-color: #00ccff;
  --bg-color: #8CD743;
  --text-color: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.4);
  --panel-border: 3px solid rgba(255, 255, 255, 0.8);
  --panel-shadow: 0 15px 35px rgba(0,0,0,0.2);
  --hp-color: #FF3366;
  --xp-color: #00E5FF;
}

body, html {
    width: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: var(--bg-color);
    font-family: 'Fredoka', sans-serif;
    color: #333;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

button, .color-swatch, .icon-btn, .powerup-card {
    -webkit-tap-highlight-color: transparent;
}

#damage-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    box-shadow: inset 0 0 0 0 rgba(255, 0, 0, 0);
    transition: box-shadow 0.3s ease;
    z-index: 10;
}
#powerup-menu {
    z-index: 110 !important;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popIn {
    from { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
#damage-vignette.vignette-active {
    box-shadow: inset 0 0 100px 20px rgba(255, 0, 0, 0.5);
    animation: pulse-vignette 1s infinite alternate;
}
@keyframes pulse-vignette {
    from { box-shadow: inset 0 0 100px 20px rgba(255, 0, 0, 0.4); }
    to { box-shadow: inset 0 0 150px 40px rgba(255, 0, 0, 0.7); }
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    will-change: transform;
}

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

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: var(--panel-border);
    border-radius: 30px;
    padding: 20px;
    text-align: center;
    pointer-events: auto;
    box-shadow: var(--panel-shadow);
    width: 95%;
    max-width: 500px;
    will-change: transform, opacity;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    max-height: 90vh;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

.bounce-title {
    font-size: 3rem;
    color: var(--primary-color);
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff, 0 4px 0 rgba(0,0,0,0.1);
    margin-bottom: 10px;
    animation: bounce 2s infinite ease-in-out;
}

.level-up-title, .game-over-title {
    font-size: 2rem;
    color: var(--secondary-color);
    text-shadow: 2px 2px 0 #fff, -2px -2px 0 #fff, 2px -2px 0 #fff, -2px 2px 0 #fff;
    margin-bottom: 10px;
}
@media (min-width: 768px) {
    .level-up-title, .game-over-title { font-size: 2.5rem; margin-bottom: 15px; }
}

.subtitle {
    font-size: 1rem;
    color: #555;
    margin-bottom: 15px;
    font-weight: 600;
}

.score-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 20px;
}

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

/* Chunky Buttons */
button {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    padding: 12px 20px;
    border: 4px solid #fff;
    border-radius: 40px;
    cursor: pointer;
    text-transform: uppercase;
    color: #fff;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.1s;
    background: linear-gradient(180deg, #ffb347 0%, #ff7700 100%);
    box-shadow: 0 6px 0 #cc5500, 0 10px 15px rgba(0,0,0,0.2);
    pointer-events: auto;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

@media (hover: hover) {
    button:hover {
        transform: translateY(-2px);
    }
}

button:active {
    transform: translateY(8px);
    box-shadow: 0 0px 0 #cc5500, 0 5px 10px rgba(0,0,0,0.2);
}

.chunky-btn.primary {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 100%);
    box-shadow: 0 8px 0 #16a34a, 0 15px 20px rgba(0,0,0,0.2);
}
.chunky-btn.primary:active {
    box-shadow: 0 0px 0 #16a34a, 0 5px 10px rgba(0,0,0,0.2);
}

.chunky-btn.secondary {
    background: linear-gradient(180deg, #60a5fa 0%, #3b82f6 100%);
    box-shadow: 0 8px 0 #2563eb, 0 15px 20px rgba(0,0,0,0.2);
}
.chunky-btn.secondary:active {
    box-shadow: 0 0px 0 #2563eb, 0 5px 10px rgba(0,0,0,0.2);
}

.chunky-btn.danger {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
    box-shadow: 0 8px 0 #dc2626, 0 15px 20px rgba(0,0,0,0.2);
}
.chunky-btn.danger:active {
    box-shadow: 0 0px 0 #dc2626, 0 5px 10px rgba(0,0,0,0.2);
}

/* HUD Bars */
#hud {
    position: absolute;
    top: max(10px, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px 12px !important;
    border-radius: 20px;
    width: 95%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    pointer-events: none;
    z-index: 90;
}

.hud-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
}

.gauge-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.gauge-label {
    font-weight: bold;
    font-size: 0.85rem;
    color: #333;
    text-align: left;
    padding-left: 5px;
}

.gauge-container:first-child .gauge-label { color: var(--hp-color); }
.gauge-container:nth-child(2) .gauge-label { color: var(--xp-color); }

.gauge-tube {
    width: 100%;
    height: 20px;
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.9);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 3px 6px rgba(0,0,0,0.1);
}

.gauge-liquid {
    height: 100%;
    width: 100%;
    border-radius: 10px;
    transition: width 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}
.gauge-liquid::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 50%;
    background: linear-gradient(rgba(255,255,255,0.4), rgba(255,255,255,0));
    border-radius: 10px 10px 0 0;
}

.health-liquid { background: linear-gradient(90deg, #ff0055, #ff4081); }
.xp-liquid { background: linear-gradient(90deg, #00b4db, #0083b0); }

#skills-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

.skills-title {
    width: 100%;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.slot {
    background: #f0f0f0;
    border-radius: 10px;
    padding: 5px 10px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    gap: 10px;
}
.slot-label {
    color: #888;
}
.slot-value {
    color: #333;
}

/* Power Up Choices (Cards) */
.choices {
    display: flex;
    flex-direction: column; /* Stack vertically on mobile */
    gap: 15px;
    justify-content: center;
    margin-top: 15px;
    width: 100%;
}
@media (min-width: 768px) {
    .choices {
        flex-direction: row;
    }
}

.powerup-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 4px solid #fff;
    border-radius: 15px;
    padding: 10px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    position: relative;
    overflow: hidden;
}

.powerup-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 50%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.6), transparent);
    transform: skewX(-25deg);
    transition: 0.5s;
    pointer-events: none;
}

@media (min-width: 768px) {
    .powerup-card {
        padding: 20px;
        border-radius: 25px;
    }
}

@media (hover: hover) {
    .powerup-card:hover {
        transform: translateY(-5px) scale(1.05);
        box-shadow: 0 10px 25px rgba(0,0,0,0.25);
    }
    .powerup-card:hover::before {
        left: 150%;
    }
}

.powerup-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: block;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
    animation: float 3s ease-in-out infinite;
}

@media (min-width: 768px) {
    .powerup-icon {
        font-size: 4rem;
        margin-bottom: 15px;
    }
}

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

.powerup-title {
    font-size: 1.1rem;
    font-weight: 800;
    color: #333;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0px;
}

.powerup-desc {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .powerup-title { font-size: 1.4rem; letter-spacing: 1px; margin-bottom: 10px; }
    .powerup-desc { font-size: 1.1rem; line-height: 1.4; }
}

/* Mobile Controls */
#mobile-controls {
    display: none; 
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    z-index: 20;
}
#mobile-controls.visible {
    display: block !important;
}

.bio-joystick {
  position: fixed;
  top: 0; left: 0; width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  border: 4px solid #fff;
  transform: translate3d(-50%, -50%, 0) scale(0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out, transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 9999;
}

.bio-joystick.active {
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
}

.bio-thumb {
  position: absolute;
  top: 50%; left: 50%; width: 50px; height: 50px;
  margin-top: -25px; margin-left: -25px;
  border-radius: 50%;
  background: var(--secondary-color);
  border: 4px solid #fff;
  will-change: transform;
}



.icon-btn {
    font-size: 1.3rem;
    background: #fff;
    border: 3px solid #ccc;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    z-index: 100;
    pointer-events: auto;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    margin: 0;
    transition: transform 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.icon-btn:active {
    transform: scale(0.85);
}

.pause-buttons .chunky-btn {
    width: 100%;
}

.top-bar {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    pointer-events: none;
}
.top-bar .icon-btn {
    pointer-events: auto;
    border: 3px solid #ff9900;
}

.powerup-card.rarity-Common { border-color: #b0bec5; }
.powerup-card.rarity-Rare { border-color: #29b6f6; box-shadow: 0 4px 20px rgba(41, 182, 246, 0.6); }
.powerup-card.rarity-Epic { border-color: #ab47bc; box-shadow: 0 4px 25px rgba(171, 71, 188, 0.7); }
.powerup-card.rarity-Legendary { 
    border-color: #ffa726; 
    box-shadow: 0 4px 30px rgba(255, 167, 38, 0.8);
    background: linear-gradient(135deg, rgba(255,255,255,0.9), rgba(255,240,200,0.9));
}

.coins-display {
    background: rgba(255,255,255,0.9);
    padding: 8px 20px;
    border-radius: 30px;
    font-size: 1.4rem;
    font-weight: 900;
    color: #ffaa00;
    border: 3px solid #ffaa00;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.shop-item {
    background: rgba(255, 255, 255, 0.6);
    padding: 15px;
    border-radius: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 3px solid #fff;
    margin-bottom: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.shop-item span {
    font-size: 1.1rem;
    font-weight: bold;
}
.shop-item .chunky-btn {
    padding: 10px 20px;
    font-size: 1rem;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
.error-shake {
    animation: errorShake 0.3s ease;
}

/* Player Color Picker Swatches */
.color-swatch {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.6);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.color-swatch:active {
    transform: scale(0.85);
}
.color-swatch.selected {
    border: 4px solid #fff;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.3), 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.15);
}
.color-swatch.locked {
    filter: grayscale(1) brightness(0.6);
}
.color-swatch.locked::after {
    content: "🔒";
    font-size: 16px;
    opacity: 0.9;
}

/* Toast Notification System */
.toast-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-family: 'Fredoka One', 'Varela Round', sans-serif;
    font-size: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.2);
    animation: slideDownFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: none;
    text-align: center;
}

.toast.toast-success { border-color: #51CF66; color: #51CF66; }
.toast.toast-error { border-color: #FF6B6B; color: #FF6B6B; }
.toast.toast-reward { border-color: #FFD43B; color: #FFD43B; }

.toast.fade-out {
    animation: fadeOutUp 0.4s ease forwards;
}

@keyframes slideDownFade {
    0% { opacity: 0; transform: translateY(-20px) scale(0.9); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeOutUp {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-20px) scale(0.9); }
}

/* =============================================
   INSTRUCTIONS SCREEN — Premium Card UI
   ============================================= */
.inst-panel {
    background: linear-gradient(145deg, rgba(30,30,60,0.92) 0%, rgba(20,20,45,0.96) 100%) !important;
    border: 3px solid rgba(100, 200, 255, 0.35) !important;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1) !important;
    padding: 24px 16px !important;
}

.inst-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, #00E5FF, #FF9900, #FF3366);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
    margin-bottom: 18px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.inst-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-bottom: 16px;
}

.inst-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, 0.07);
    border: 2px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px;
    padding: 12px 16px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: cardSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
    animation-delay: var(--delay, 0s);
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.inst-card:active {
    transform: scale(0.97);
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(0, 229, 255, 0.5);
}

@keyframes cardSlideIn {
    from {
        opacity: 0;
        transform: translateX(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

.inst-icon {
    font-size: 2.2rem;
    width: 52px;
    height: 52px;
    min-width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(0,229,255,0.2), rgba(255,153,0,0.2));
    border-radius: 14px;
    border: 2px solid rgba(255,255,255,0.15);
    animation: iconPulse 2.5s ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

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

.inst-info {
    text-align: left;
    flex: 1;
}

.inst-label {
    font-size: 1.05rem;
    font-weight: 800;
    color: #00E5FF;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 2px;
}

.inst-desc {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 600;
    line-height: 1.3;
}

/* Step Indicator Dots */
.inst-dots {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 18px;
}

.inst-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(0, 229, 255, 0.6);
    animation: dotGlow 1.5s ease-in-out infinite;
}
.inst-dot:nth-child(1) { animation-delay: 0s; }
.inst-dot:nth-child(2) { animation-delay: 0.2s; }
.inst-dot:nth-child(3) { animation-delay: 0.4s; }
.inst-dot:nth-child(4) { animation-delay: 0.6s; }

@keyframes dotGlow {
    0%, 100% { opacity: 0.4; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.4); background: #fff; }
}

/* FIGHT Button */
.fight-btn {
    background: linear-gradient(180deg, #ff4444 0%, #cc0000 100%) !important;
    box-shadow: 0 8px 0 #880000, 0 12px 30px rgba(255, 0, 0, 0.4) !important;
    border: 4px solid rgba(255, 255, 255, 0.8) !important;
    font-size: 1.5rem !important;
    letter-spacing: 3px;
    animation: fightPulse 1.5s ease-in-out infinite;
    position: relative;
    overflow: hidden;
}

.fight-btn::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 60%; height: 100%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
    transform: skewX(-25deg);
    animation: btnShine 2.5s ease-in-out infinite;
}

@keyframes fightPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); box-shadow: 0 8px 0 #880000, 0 15px 40px rgba(255, 0, 0, 0.6) !important; }
}

@keyframes btnShine {
    0% { left: -100%; }
    50% { left: 150%; }
    100% { left: 150%; }
}

.fight-btn:active {
    transform: translateY(8px) scale(0.98) !important;
    box-shadow: 0 0px 0 #880000, 0 5px 10px rgba(255,0,0,0.3) !important;
    animation: none;
}

/* Difficulty Warning Banner (shown in HUD) */
.diff-banner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, rgba(255,0,0,0.9), rgba(200,0,0,0.9));
    color: #fff;
    padding: 12px 30px;
    border-radius: 12px;
    font-size: 1.3rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    z-index: 200;
    pointer-events: none;
    animation: diffBannerIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), diffBannerOut 0.4s ease 1.6s forwards;
    border: 3px solid rgba(255,255,255,0.5);
    box-shadow: 0 10px 40px rgba(255,0,0,0.5);
    text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

@keyframes diffBannerIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
@keyframes diffBannerOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(1.2); }
}
