:root {
    --bg-dark: #040514;
    --bg-deep: #02030a;
    --primary: #8a3ffc;
    --primary-glow: #a855f7;
    --primary-light: #c084fc;
    --secondary: #00f0ff;
    --secondary-glow: #38bdf8;
    --accent: #ff007f;
    --accent-glow: #f43f5e;
    --gold: #ffd700;
    --gold-glow: #facc15;
    --emerald: #10b981;
    --panel-bg: rgba(9, 13, 34, 0.88);
    --panel-bg-subtle: rgba(14, 20, 50, 0.7);
    --panel-border: rgba(255, 255, 255, 0.16);
    --panel-border-glow: rgba(0, 240, 255, 0.35);
    --card-bg: rgba(18, 25, 62, 0.75);
    --card-hover: rgba(30, 42, 95, 0.9);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-hud: 'Orbitron', 'Outfit', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
    --shadow-soft: 0 10px 30px rgba(0, 0, 0, 0.5);
    --shadow-glow-cyan: 0 0 25px rgba(0, 240, 255, 0.4);
    --shadow-glow-purple: 0 0 25px rgba(168, 85, 247, 0.45);
    --shadow-glow-gold: 0 0 25px rgba(255, 215, 0, 0.4);
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: var(--font-main);
    color: var(--text-main);
    position: relative;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

/* UI Layer Structure */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.interactive {
    pointer-events: auto;
}

/* HUD System */
#hud-container {
    padding: 14px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 20;
}

.hud-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-card {
    background: var(--panel-bg);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 8px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-soft);
    pointer-events: auto;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.hud-card:hover {
    border-color: rgba(0, 240, 255, 0.4);
}

.score-display {
    font-family: var(--font-hud);
    font-size: 26px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.5);
    line-height: 1;
    letter-spacing: 0.5px;
}

.score-sub {
    font-size: 11px;
    color: var(--text-dim);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}

.currency-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 800;
    color: var(--gold);
    text-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
}

.currency-pill.gem-pill {
    color: var(--secondary);
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.45);
}

.currency-pill.starlight-pill {
    color: var(--primary-light);
    text-shadow: 0 0 12px rgba(192, 132, 252, 0.45);
}

/* Escalating Combo Badge */
.combo-badge {
    display: none;
    font-family: var(--font-hud);
    font-size: 17px;
    font-weight: 900;
    color: #fff;
    padding: 7px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, rgba(255, 0, 127, 0.35), rgba(244, 63, 94, 0.65));
    border: 1px solid rgba(255, 0, 127, 0.7);
    box-shadow: 0 0 20px rgba(255, 0, 127, 0.6);
    animation: comboPulse 0.6s infinite alternate cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.5px;
}

@keyframes comboPulse {
    from { transform: scale(1); filter: brightness(1); }
    to { transform: scale(1.12); filter: brightness(1.3); box-shadow: 0 0 28px rgba(255, 0, 127, 0.9); }
}

/* Altitude Gauge System */
#altitude-meter {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 240px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    overflow: hidden;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

#altitude-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, var(--primary), var(--secondary), var(--gold));
    border-radius: 6px;
    transition: height 0.15s ease-out;
    box-shadow: 0 0 12px var(--secondary);
}

#altitude-tracker {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
    font-family: var(--font-hud);
    font-size: 13px;
    font-weight: 800;
    color: var(--secondary);
    text-shadow: 0 0 10px var(--secondary);
    pointer-events: none;
    letter-spacing: 1px;
}

/* Active Relics & Powerup Dock */
#active-relics-dock {
    position: absolute;
    left: 20px;
    bottom: 24px;
    display: flex;
    gap: 8px;
    pointer-events: auto;
    z-index: 15;
}

.relic-icon-pill {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s;
    cursor: pointer;
}

.relic-icon-pill:hover {
    transform: scale(1.2) translateY(-6px);
    border-color: var(--gold);
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
}

/* Active Powerups Row */
#active-powerups {
    position: absolute;
    right: 20px;
    top: 88px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    pointer-events: none;
    z-index: 15;
}

.powerup-pill {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-soft);
    letter-spacing: 0.5px;
}

.powerup-pill .bar {
    width: 48px;
    height: 5px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.powerup-pill .fill {
    height: 100%;
    background: linear-gradient(to right, var(--secondary), var(--primary-light));
    width: 100%;
    transition: width 0.1s linear;
}

/* Multi-Tier Boss Health HUD */
#boss-hud {
    display: none;
    position: absolute;
    top: 78px;
    left: 50%;
    transform: translateX(-50%);
    width: 88%;
    max-width: 480px;
    background: rgba(14, 10, 30, 0.92);
    border: 1px solid rgba(255, 0, 100, 0.5);
    border-radius: 20px;
    padding: 12px 22px;
    backdrop-filter: blur(18px);
    pointer-events: none;
    text-align: center;
    box-shadow: 0 0 35px rgba(255, 0, 80, 0.4);
    z-index: 25;
}

#boss-name {
    font-family: var(--font-hud);
    font-size: 14px;
    font-weight: 900;
    color: #ff3366;
    margin-bottom: 6px;
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(255, 51, 102, 0.7);
}

#boss-hp-bar {
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.25);
}

#boss-hp-fill {
    height: 100%;
    background: linear-gradient(to right, #ff007f, #f43f5e, #ffd700);
    width: 100%;
    transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(255, 0, 127, 0.8);
}

/* Touch Controls */
#touch-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
    z-index: 20;
}

.touch-group {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.touch-btn {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.5);
    cursor: pointer;
    transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.15s, border-color 0.15s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.touch-btn:active {
    transform: scale(0.9);
    background: rgba(138, 63, 252, 0.45);
    border-color: var(--secondary);
    box-shadow: 0 0 20px var(--secondary);
}

.touch-btn.shoot {
    border-color: var(--secondary);
    background: rgba(0, 240, 255, 0.22);
}

.touch-btn.slam {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.22);
}

.touch-btn.boost {
    border-color: var(--primary-glow);
    background: rgba(168, 85, 247, 0.25);
}

#desktop-hint {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--text-dim);
    letter-spacing: 0.6px;
    pointer-events: none;
    background: rgba(4, 6, 20, 0.65);
    padding: 6px 16px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    white-space: nowrap;
}

/* Button & Design System */
.btn {
    font-family: var(--font-main);
    font-size: 14px;
    font-weight: 800;
    padding: 11px 22px;
    border-radius: 16px;
    border: 1px solid transparent;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    text-decoration: none;
    letter-spacing: 0.4px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    filter: brightness(1.15);
}

.btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    filter: grayscale(0.7);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff;
    box-shadow: 0 6px 24px rgba(138, 63, 252, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 8px 30px rgba(138, 63, 252, 0.7);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent), #ff0055);
    color: #fff;
    box-shadow: 0 6px 24px rgba(255, 0, 127, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary {
    background: linear-gradient(135deg, #0284c7, var(--secondary));
    color: #040514;
    font-weight: 900;
    box-shadow: 0 6px 24px rgba(0, 240, 255, 0.45);
}

.btn-gold {
    background: linear-gradient(135deg, #d97706, var(--gold));
    color: #040514;
    font-weight: 900;
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.45);
}

.btn-glass {
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    color: var(--text-main);
    backdrop-filter: blur(12px);
}

.btn-glass:hover:not(:disabled) {
    background: var(--card-hover);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.btn-icon {
    padding: 9px 13px;
    font-size: 16px;
    border-radius: 14px;
}

.btn-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--panel-border);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10;
}

.btn-close:hover {
    background: rgba(255, 0, 80, 0.45);
    border-color: #ff0055;
    transform: scale(1.15) rotate(90deg);
}

/* Modals & Screen Overlays */
.screen-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 20, 0.82);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 24px;
}

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

.modal-box {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 32px;
    padding: 34px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7), 0 0 30px rgba(138, 63, 252, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: modalAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.modal-box.large {
    max-width: 900px;
}

.modal-title {
    font-family: var(--font-hud);
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    text-align: center;
    letter-spacing: 1.5px;
    margin-bottom: 5px;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.35);
}

.modal-subtitle {
    font-size: 13px;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 24px;
    letter-spacing: 0.3px;
}

/* Tab Bars */
.tab-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 5px;
    gap: 6px;
    width: 100%;
    margin-bottom: 22px;
}

.tab-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 14px;
    border: none;
    background: transparent;
    color: var(--text-dim);
    font-family: var(--font-main);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tab-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 14px rgba(138, 63, 252, 0.5);
}

/* Item Grid & Cards */
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
    width: 100%;
    margin-bottom: 22px;
}

.grid-card {
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.grid-card:hover {
    transform: translateY(-5px) scale(1.02);
    background: var(--card-hover);
    border-color: var(--secondary);
    box-shadow: 0 8px 25px rgba(0, 240, 255, 0.3);
}

.grid-card.selected {
    border-color: var(--secondary);
    background: rgba(0, 240, 255, 0.18);
    box-shadow: 0 0 24px rgba(0, 240, 255, 0.4);
}

.grid-card .icon-box {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.grid-card .title {
    font-size: 13px;
    font-weight: 800;
    margin-bottom: 4px;
    letter-spacing: 0.3px;
}

.grid-card .perk {
    font-size: 11px;
    color: var(--text-dim);
    line-height: 1.35;
    margin-bottom: 10px;
    min-height: 30px;
}

.grid-card .price {
    font-size: 12px;
    font-weight: 900;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 5px;
}

.badge-tag {
    position: absolute;
    top: 9px;
    right: 9px;
    font-size: 9px;
    font-weight: 900;
    background: var(--primary);
    color: #fff;
    padding: 3px 7px;
    border-radius: 8px;
    letter-spacing: 0.5px;
}

/* World Navigation & Mission Map */
.world-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 18px;
}

.world-title {
    font-family: var(--font-hud);
    font-size: 17px;
    font-weight: 900;
    color: var(--secondary);
    letter-spacing: 1px;
    text-shadow: 0 0 12px rgba(0, 240, 255, 0.5);
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    width: 100%;
    margin-bottom: 22px;
}

.level-node {
    aspect-ratio: 1;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.level-node:hover:not(.locked) {
    transform: scale(1.1);
    border-color: var(--secondary);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.5);
}

.level-node.locked {
    opacity: 0.35;
    cursor: not-allowed;
    filter: grayscale(0.8);
}

.level-node.boss {
    border-color: #f43f5e;
    background: rgba(244, 63, 94, 0.18);
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.3);
}

.level-node .num {
    font-family: var(--font-hud);
    font-size: 17px;
    font-weight: 900;
}

.level-node .stars {
    font-size: 11px;
    color: var(--gold);
    margin-top: 3px;
    letter-spacing: 1px;
}

/* Roguelike Abyss Relic Sanctuary */
.relic-draft-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
    width: 100%;
    margin-bottom: 22px;
}

.relic-card {
    background: var(--card-bg);
    border: 2px solid var(--panel-border);
    border-radius: 24px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.relic-card:hover {
    transform: translateY(-10px) scale(1.05);
    border-color: var(--gold);
    box-shadow: 0 16px 40px rgba(255, 215, 0, 0.4);
}

.relic-card .rarity-badge {
    font-family: var(--font-hud);
    font-size: 10px;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 10px;
    margin-bottom: 14px;
    letter-spacing: 1px;
}

.relic-card.rare .rarity-badge { background: rgba(0, 240, 255, 0.25); color: var(--secondary); border: 1px solid var(--secondary); }
.relic-card.epic .rarity-badge { background: rgba(168, 85, 247, 0.25); color: var(--primary-glow); border: 1px solid var(--primary-glow); }
.relic-card.cosmic .rarity-badge { background: rgba(255, 215, 0, 0.25); color: var(--gold); border: 1px solid var(--gold); }

.relic-card .icon-wrap {
    font-size: 44px;
    margin-bottom: 14px;
    filter: drop-shadow(0 0 18px rgba(255, 255, 255, 0.35));
}

.relic-card .name {
    font-family: var(--font-hud);
    font-size: 15px;
    font-weight: 900;
    margin-bottom: 8px;
}

.relic-card .desc {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.45;
}

/* Constellation Talent Tree Canvas */
#constellation-canvas-wrap {
    width: 100%;
    height: 380px;
    background: rgba(4, 6, 22, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
}

#constellation-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.talent-details-panel {
    width: 100%;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

/* Level Architect Visual Editor */
.editor-container {
    display: flex;
    gap: 18px;
    width: 100%;
    height: 480px;
    margin-bottom: 18px;
}

.editor-viewport {
    flex: 1;
    background: #02030a;
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.7);
}

#editor-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.editor-toolbar {
    width: 230px;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
}

.editor-tool-btn {
    width: 100%;
    padding: 9px 12px;
    border-radius: 12px;
    border: 1px solid var(--panel-border);
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    transition: all 0.18s;
}

.editor-tool-btn:hover, .editor-tool-btn.active {
    background: var(--primary);
    border-color: var(--secondary);
    box-shadow: 0 0 15px rgba(138, 63, 252, 0.5);
}

/* Upgrades & Quests Rows */
.upgrade-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 14px 18px;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    margin-bottom: 12px;
    transition: transform 0.2s, border-color 0.2s;
}

.upgrade-row:hover {
    border-color: rgba(0, 240, 255, 0.35);
    transform: translateY(-2px);
}

.upgrade-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upgrade-icon {
    font-size: 30px;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.upgrade-pips {
    display: flex;
    gap: 5px;
    margin-top: 5px;
}

.pip {
    width: 16px;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.18);
}

.pip.filled {
    background: var(--secondary);
    box-shadow: 0 0 8px var(--secondary);
}

.quest-item {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    padding: 16px 18px;
    background: var(--card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 18px;
    margin-bottom: 12px;
}

.quest-progress-bar {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.quest-progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s ease-out;
}

/* Settings Rows */
.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 11px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 13px;
    font-weight: 600;
}

input[type="range"] {
    accent-color: var(--secondary);
    cursor: pointer;
}

select {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--panel-border);
    color: #fff;
    font-family: var(--font-main);
    padding: 7px 14px;
    border-radius: 12px;
    outline: none;
    font-weight: 700;
}

/* Top Left Brand Tag */
.browsergames-top-tag {
    position: fixed;
    top: 14px;
    left: 16px;
    z-index: 999999;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(7, 10, 24, 0.9);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(0, 242, 254, 0.4);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 12px rgba(0, 242, 254, 0.25);
    padding: 6px 14px;
    border-radius: 20px;
    font-family: var(--font-main);
    font-size: 0.74rem;
    font-weight: 800;
    color: #00f2fe;
    text-decoration: none;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    user-select: none;
    cursor: pointer;
    line-height: 1;
}

.browsergames-top-tag:hover {
    background: rgba(0, 242, 254, 0.22);
    border-color: #00f2fe;
    color: #ffffff;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 25px rgba(0, 242, 254, 0.5), 0 0 18px rgba(0, 242, 254, 0.55);
}

.browsergames-top-tag .bg-tag-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00ff88;
    box-shadow: 0 0 8px #00ff88;
    animation: bgPulseDot 2s infinite ease-in-out;
}

.browsergames-top-tag .bg-tag-icon { font-size: 0.88rem; }
.browsergames-top-tag .bg-tag-tld { color: #ffb300; }

@keyframes bgPulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.4); opacity: 0.6; }
}

/* Scrollbar Customization */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.25);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

@media (max-width: 680px) {
    .modal-box {
        padding: 24px 18px;
        border-radius: 24px;
    }
    .modal-title {
        font-size: 24px;
    }
    .level-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .relic-draft-grid {
        grid-template-columns: 1fr;
    }
    .editor-container {
        flex-direction: column;
        height: auto;
    }
    .editor-viewport {
        height: 290px;
    }
    .editor-toolbar {
        width: 100%;
        max-height: 190px;
    }
    #desktop-hint {
        display: none;
    }
    .browsergames-top-tag {
        top: 8px;
        left: 8px;
        padding: 4px 10px;
        font-size: 0.66rem;
    }
    #hud-container {
        padding-top: 38px !important;
    }
}
