/* ============================================
   DUNGEON CLICKER - Dark Fantasy Theme
   ============================================ */

:root {
    --bg-dark: #0d0a1a;
    --bg-panel: #1a1030;
    --bg-card: #231845;
    --bg-hover: #2d2055;
    --accent: #c084fc;
    --accent-bright: #e0b0ff;
    --gold: #fbbf24;
    --gold-dark: #d97706;
    --gem: #60a5fa;
    --prestige: #c084fc;
    --hp-red: #ef4444;
    --hp-green: #22c55e;
    --text: #e8e0f0;
    --text-dim: #9a8cb8;
    --text-bright: #ffffff;
    --border: #3d2a6e;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overscroll-behavior: none;
}

/* ---- Loading Screen ---- */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
}

.game-logo {
    font-size: 2.2rem;
    background: linear-gradient(135deg, var(--gold), var(--accent-bright));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
}

.loading-bar {
    width: 200px;
    height: 6px;
    background: var(--bg-panel);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 auto 1rem;
}

.loading-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    border-radius: 3px;
    animation: loading 1.5s ease-in-out forwards;
}

@keyframes loading {
    to { width: 100%; }
}

/* ---- Modals ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 900;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--accent-bright);
}

/* ---- Auth Modal ---- */
#auth-form {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

#auth-form input {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    color: var(--text);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#auth-form input:focus {
    border-color: var(--accent);
}

.auth-toggle {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-dim);
    font-size: 0.9rem;
}

.auth-toggle a {
    color: var(--accent);
    text-decoration: none;
}

#auth-skip {
    display: block;
    width: 100%;
    margin-top: 0.75rem;
}

/* ---- Buttons ---- */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: white;
}

.btn-primary:hover {
    filter: brightness(1.15);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0.25rem;
    filter: grayscale(0.3);
    transition: filter 0.15s;
}

.btn-icon:hover {
    filter: grayscale(0);
}

.hidden {
    display: none !important;
}

/* ---- Game Container ---- */
#game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 500px;
    margin: 0 auto;
}

/* ---- Top Bar ---- */
#top-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.resource {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.resource-icon {
    font-size: 1rem;
}

.gold { color: var(--gold); }
.gems { color: var(--gem); }
.prestige-crystals { color: var(--prestige); }

.per-sec {
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 400;
}

.top-actions {
    margin-left: auto;
    display: flex;
    gap: 0.25rem;
}

/* ---- Tab Navigation ---- */
#tab-nav {
    display: flex;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    flex-shrink: 0;
    scrollbar-width: none;
}

#tab-nav::-webkit-scrollbar {
    display: none;
}

.tab {
    flex: 1;
    min-width: fit-content;
    padding: 0.6rem 0.5rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.tab.active {
    color: var(--accent-bright);
    border-bottom-color: var(--accent);
}

.tab:hover {
    color: var(--text);
}

/* ---- Tab Content ---- */
#tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.tab-panel {
    display: none;
    padding: 1rem;
    min-height: 100%;
}

.tab-panel.active {
    display: block;
}

.section-title {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    color: var(--accent-bright);
}

/* ---- Dungeon Tab ---- */
.dungeon-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.floor-label {
    font-weight: 700;
    font-size: 1.1rem;
}

.zone-name {
    color: var(--text-dim);
    font-style: italic;
}

.monster-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.monster-hp-bar {
    width: 100%;
    height: 20px;
    background: var(--bg-dark);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    margin-bottom: 1rem;
}

.hp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--hp-red), #f97316);
    border-radius: 10px;
    transition: width 0.15s;
    width: 100%;
}

.hp-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

.monster-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.monster-sprite {
    font-size: 4rem;
    filter: drop-shadow(0 0 20px rgba(192, 132, 252, 0.3));
    transition: transform 0.1s;
    cursor: pointer;
}

.monster-sprite.hit {
    animation: monsterHit 0.15s;
}

@keyframes monsterHit {
    0% { transform: scale(1); }
    50% { transform: scale(0.9) rotate(-5deg); filter: brightness(2) drop-shadow(0 0 20px rgba(255,100,100,0.6)); }
    100% { transform: scale(1); }
}

.monster-sprite.death {
    animation: monsterDeath 0.4s forwards;
}

@keyframes monsterDeath {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2) rotate(10deg); opacity: 0.5; }
    100% { transform: scale(0); opacity: 0; }
}

.monster-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-dim);
}

.boss-indicator {
    color: var(--danger);
    font-weight: 700;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Damage Numbers */
#damage-numbers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.damage-num {
    position: absolute;
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--gold);
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    animation: floatDmg 0.8s ease-out forwards;
    pointer-events: none;
}

.damage-num.crit {
    font-size: 1.6rem;
    color: #ff6b6b;
}

.damage-num.hero {
    font-size: 0.9rem;
    color: var(--accent);
}

@keyframes floatDmg {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(0.7); }
}

/* Gold reward popup */
.gold-reward {
    position: absolute;
    bottom: 10px;
    font-weight: 700;
    color: var(--gold);
    font-size: 0.9rem;
    animation: floatGold 1s ease-out forwards;
}

@keyframes floatGold {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-30px); }
}

/* Click Area */
.click-area {
    margin-top: 1rem;
    text-align: center;
}

.btn-attack {
    width: 100%;
    padding: 1rem;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.1s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.btn-attack:hover {
    filter: brightness(1.1);
}

.btn-attack:active {
    transform: scale(0.97);
    filter: brightness(1.3);
}

.dps-info {
    display: flex;
    justify-content: space-around;
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-dim);
}

.btn-reward-ad {
    width: 100%;
    margin-top: 1rem;
    background: linear-gradient(135deg, #059669, #047857);
    color: white;
    font-size: 0.9rem;
}

.btn-reward-ad:hover {
    filter: brightness(1.1);
}

.btn-reward-ad.active {
    background: var(--bg-card);
    color: var(--success);
    border: 1px solid var(--success);
}

/* ---- Heroes Tab ---- */
.heroes-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.hero-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: border-color 0.15s;
}

.hero-card:hover {
    border-color: var(--accent);
}

.hero-card.locked {
    opacity: 0.5;
}

.hero-card.premium {
    border-color: var(--gold-dark);
    background: linear-gradient(135deg, var(--bg-card), #2d1f00);
}

.hero-icon {
    font-size: 2.2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-dark);
    border-radius: 50%;
    flex-shrink: 0;
}

.hero-info {
    flex: 1;
    min-width: 0;
}

.hero-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.hero-level {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.hero-dps {
    font-size: 0.8rem;
    color: var(--accent);
}

.hero-actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex-shrink: 0;
}

.btn-hire, .btn-upgrade {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.btn-hire {
    background: var(--success);
    color: white;
}

.btn-upgrade {
    background: var(--gold-dark);
    color: white;
}

.btn-hire:disabled, .btn-upgrade:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ---- Shop Tab ---- */
.shop-section {
    margin-bottom: 1.5rem;
}

.shop-section h3 {
    color: var(--text-dim);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.75rem;
}

.shop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.shop-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.shop-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.shop-item.premium {
    border-color: var(--gold-dark);
    background: linear-gradient(135deg, var(--bg-card), #2d1f00);
}

.shop-item-icon {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
}

.shop-item-name {
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.shop-item-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.shop-item-price {
    font-weight: 700;
    font-size: 1rem;
}

.price-eur { color: var(--success); }
.price-gems { color: var(--gem); }

/* ---- Prestige Tab ---- */
.prestige-info {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.prestige-info p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.prestige-preview {
    margin: 1rem 0;
    padding: 1rem;
    background: var(--bg-dark);
    border-radius: var(--radius-sm);
}

.prestige-preview p {
    color: var(--text);
}

.btn-prestige {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    font-size: 1.1rem;
    padding: 1rem 2rem;
}

.btn-prestige:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.upgrades-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upgrade-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.upgrade-info {
    flex: 1;
}

.upgrade-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.upgrade-desc {
    font-size: 0.75rem;
    color: var(--text-dim);
}

.upgrade-level {
    font-size: 0.7rem;
    color: var(--accent);
}

/* ---- Leaderboard ---- */
.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.lb-tab {
    flex: 1;
    padding: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.lb-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.lb-entry {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

.lb-rank {
    font-weight: 800;
    font-size: 1rem;
    width: 30px;
    text-align: center;
    color: var(--text-dim);
}

.lb-rank.top-1 { color: #fbbf24; }
.lb-rank.top-2 { color: #d1d5db; }
.lb-rank.top-3 { color: #d97706; }

.lb-name {
    flex: 1;
    font-weight: 600;
}

.lb-value {
    color: var(--accent);
    font-weight: 700;
}

.placeholder {
    text-align: center;
    color: var(--text-dim);
    padding: 2rem;
}

/* ---- Ad Banner ---- */
.ad-banner {
    flex-shrink: 0;
    padding: 0.25rem;
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    text-align: center;
    min-height: 60px;
}

.ad-placeholder {
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    color: var(--text-dim);
    font-size: 0.8rem;
}

.ad-placeholder.large {
    padding: 3rem;
    font-size: 1rem;
}

/* ---- Interstitial ---- */
.interstitial {
    max-width: 350px;
    text-align: center;
}

.ad-timer {
    margin-bottom: 1rem;
    color: var(--text-dim);
    font-size: 0.85rem;
}

/* ---- Toast Notifications ---- */
#toast-container {
    position: fixed;
    top: 60px;
    right: 10px;
    z-index: 800;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1rem;
    font-size: 0.85rem;
    box-shadow: var(--shadow);
    animation: toastIn 0.3s ease-out, toastOut 0.3s ease-in 2.7s forwards;
    max-width: 280px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--gem); }
.toast.reward { border-left: 3px solid var(--gold); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(50px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(50px); }
}

/* ---- PWA Install ---- */
.pwa-install {
    position: fixed;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow);
    z-index: 500;
    font-size: 0.85rem;
}

/* ---- Settings ---- */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}

.setting-row label {
    font-weight: 600;
    font-size: 0.9rem;
}

.setting-row input[type="range"] {
    width: 120px;
    accent-color: var(--accent);
}

.setting-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.modal-close {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
}

/* ---- Responsive ---- */
@media (min-width: 500px) {
    #game-container {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }

    body {
        background: radial-gradient(ellipse at center, #1a0a2e 0%, #0d0a1a 70%);
    }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

/* ---- Number formatting animation ---- */
.number-up {
    animation: numPulse 0.3s;
}

@keyframes numPulse {
    50% { transform: scale(1.15); }
}

/* Boss styling */
.monster-area.boss-fight {
    border-color: var(--danger);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.monster-area.boss-fight .monster-sprite {
    filter: drop-shadow(0 0 30px rgba(239, 68, 68, 0.5));
}
