/* ==========================================
   GLOBAL STYLES & CORE CANVAS
   ========================================== */
html, body {
    height: 100%;
    margin: 0;
    background-image: url('images/gameplaybg.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-position: center;
    overflow: hidden;
}

canvas {
    width: 1280px;
    height: 720px;
    border: 10px solid black;
    border-radius: 5px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    background-color: rgba(255, 255, 255, 0.8);
}

/* Scales the whole 1280x720 stage to fit any viewport, keeping it centered */
#viewport-scaler {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 1280px;
    height: 720px;
    flex-shrink: 0;
    transform-origin: center center;
}

#Game-Window {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.hidden {
    display: none !important;
}

/* ==========================================
   HUD HEADS UP DISPLAY LAYER
   ========================================== */
#ui-layer {
    position: absolute;
    bottom: 20px;
    left: 5%;
    width: 90%;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 1000;
}

.ui-group {
    pointer-events: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.health-group { 
    align-items: flex-start; 
}

.magic-group { 
    align-items: flex-end; 
}

.xp-group {
    flex-grow: 1;
    max-width: 35%;
    margin: 0 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==========================================
   ABILITIES & UTILITY ICONS
   ========================================== */
.abilities {
    display: flex;
    gap: 15px;
    margin-bottom: 5px;
}

.ability-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.ability-icon.ready {
    box-shadow: 0 0 15px 3px #b056ff;
    filter: drop-shadow(0 0 5px #b056ff);
}

.ability-icon.cooldown {
    box-shadow: 0 0 15px 2px #ffc048;
    filter: grayscale(80%) drop-shadow(0 0 5px #ffc048);
    opacity: 0.6;
}

/* ==========================================
   VITALITY TUBES & RESOURCE STAT BARS
   ========================================== */
.bar-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px; /* Uniform bounding area centers all tubes perfectly */
}

.magic-group .bar-wrapper { 
    flex-direction: row-reverse; 
}

.icon {
    font-size: 40px;
    filter: drop-shadow(0 0 8px rgba(255,255,255,0.4));
}

.tube {
    width: 300px;
    height: 35px;
    background: linear-gradient(to bottom, #111, #000);
    border: 3px solid #333;
    border-radius: 8px;
    position: relative;
    box-shadow: inset 0 0 10px #000, 0 0 10px rgba(0,0,0,0.8);
    overflow: hidden;
}

.xp-tube {
    background: linear-gradient(to bottom, #111, #000);
    border: 3px solid #333;
    box-shadow: inset 0 0 10px #000, 0 0 10px rgba(0,0,0,0.8);
}

.fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease-out;
}

.health-fill {
    background: linear-gradient(to bottom, #ff3366, #990000);
    box-shadow: 0 0 10px #ff3366;
}

.magic-fill {
    background: linear-gradient(to bottom, #33ccff, #004080);
    box-shadow: 0 0 10px #33ccff;
}

.xp-fill {
    background: linear-gradient(to bottom, #2ecc71, #27ae60);
    box-shadow: 0 0 10px #2ecc71;
    width: 0%;
}

.bar-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-family: "Acme", sans-serif;
    font-size: 18px;
    letter-spacing: 2px;
    text-shadow: 1px 1px 3px black, -1px -1px 3px black;
}

.tube.taking-damage {
    box-shadow: 0 0 25px 5px #ff0000;
}

/* ==========================================
   VERTICAL STORE NAVIGATION STACK
   ========================================== */
.store-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 15px;
    align-self: flex-end;
    width: 100%;
}

.store-item {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    cursor: pointer;
    font-family: 'Lexend Exa', sans-serif;
    color: #ffffff;
    font-size: 1.1rem;
    transition: transform 0.15s ease;
}

.store-item:hover {
    transform: scale(1.1);
}

.store-count {
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.6);
}

.store-emoji {
    font-size: 1.5rem;
}

/* ==========================================
   MENU OVERLAYS & LEVEL UP INTERFACE
   ========================================== */
#levelup-panel, #upgrade-panel, #perk-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    pointer-events: auto;
}

.panel-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background-image: url('images/background.png');
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    font-family: 'Lexend Exa', sans-serif;
    color: #ffffff;
}

.panel-title {
    font-family: 'Acme', sans-serif;
    font-size: 3.5rem;
    color: #ffc048;
    margin: 0 0 10px 0;
    text-shadow: 0 0 20px rgba(255, 192, 72, 0.5);
}

.panel-subtitle {
    font-size: 0.95rem;
    color: #ffffff;
    margin: 0 0 50px 0;
    opacity: 0.8;
}

.interface {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); 
    gap: 16px;
    width: 100%;
    max-width: 800px;
    justify-content: center;
    justify-items: center;
}

.reward-card {
    background-color: #06060e;
    border: 2px solid #291f22;
    border-radius: 10px;
    padding: 10px 8px;
    max-width: 180px;
    min-width: 140px;
    text-align: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

.reward-card:hover {
    transform: scale(1.05) translateY(-4px);
    box-shadow: 0 0 15px rgba(255, 107, 157, 0.4);
}

.reward-title {
    font-family: 'Acme', sans-serif;
    color: #ffc048;
    font-size: 1.25rem;
    margin: 0 0 6px 0;
}

.reward-desc {
    font-size: 0.72rem;
    line-height: 1.3;
    color: #ffffff;
    margin: 0;
    opacity: 0.9;
}

/* ==========================================
   DYNAMIC BOSS SYSTEM GRAPHICS
   ========================================== */
.enemy-boss {
    position: relative;
    border: 2px solid #ffc048;
}

.enemy-boss::before {
    content: "";
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle, #ff6b9d, transparent 70%);
    z-index: -1;
    filter: blur(15px);
}

.enemy-boss::after {
    content: "";
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 107, 157, 0.5), transparent);
    animation: redSweep 2s infinite;
}

@keyframes redSweep {
    100% { left: 100%; }
}

/* ==========================================
   LEVEL UP INTERFACE DESIGN OVERLAY
   ========================================== */
#levelup-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle, #020224 0%, #000000 100%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#levelup-panel.hidden {
    display: none !important;
}

.interface-panel {
    border: 2px solid #ffffff;
    border-radius: 12px;
    padding: 30px;
    width: 100%;
    max-width: 640px;
    background: rgba(0, 0, 0, 0.8);
    text-align: center;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

.menu-title {
    font-family: 'Acme', sans-serif;
    color: #ffffff;
    font-size: 2.5rem;
    margin-bottom: 25px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.options-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.menu-toggle {
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    padding: 15px 20px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.menu-toggle:hover {
    transform: scale(1.02);
    border-color: #ff6b9d;
    box-shadow: 0 0 15px rgba(255, 107, 157, 0.3);
}

.card-content {
    display: flex;
    align-items: center;
    gap: 20px;
    position: relative;
    z-index: 2;
}

.img-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}

.heart-icon {
    background-color: #ff6b9d; 
}

.flower-icon {
    background-color: #ffc048; 
}

.details {
    flex-grow: 1;
    position: relative;
}

.option-title {
    font-family: 'Acme', sans-serif;
    color: #ffffff;
    font-size: 1.4rem;
    margin: 0 0 5px 0;
}

.body-text, .footer-note {
    font-family: 'Lexend Exa', sans-serif;
    color: #ffffff;
    font-size: 0.9rem;
    margin: 0;
    opacity: 0.8;
}

.footer-note {
    font-size: 0.8rem;
    margin-top: 15px;
    opacity: 0.5;
}

.badge {
    position: absolute;
    right: 0;
    top: 0;
    font-family: 'Lexend Exa', sans-serif;
    font-size: 0.8rem;
    font-weight: bold;
}

.pink-text { color: #ff6b9d; }
.gold-text { color: #ffc048; }

/* ==========================================
   VICTORY GAME OVER OVERLAY VISUALS
   ========================================== */
#victory-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
}

#victory-panel .panel-wrapper {
    background-image: url('images/background.png') !important;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

/* Universal lock for game elements and tooltips */
canvas, 
#game-container, 
#story-panel, 
.tooltip, 
.description {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    
    -webkit-touch-callout: none;
    touch-action: none;
}

/* Global insurance policy to hide any highlight */
::selection, 
::-moz-selection {
    background: transparent;
}