/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700;900&family=Inter:wght@300;400;600;700&display=swap');

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

:root {
    --bg-dark: #0a0a0f;
    --bg-medium: #141420;
    --bg-light: #1e1e30;
    --bg-card: #252540;
    --text-primary: #e8e6f0;
    --text-secondary: #9a97b0;
    --text-dim: #5a5870;
    --accent-gold: #f0c060;
    --accent-red: #e04050;
    --accent-blue: #4080e0;
    --accent-green: #40c070;
    --accent-purple: #8040e0;
    --accent-cyan: #40c0d0;
    --energy-color: #f0c060;
    --hp-color: #e04050;
    --block-color: #6090d0;
    --attack-color: #e06050;
    --skill-color: #50b0e0;
    --power-color: #c060e0;
    --curse-color: #800020;
    --rare-color: #f0c060;
    --uncommon-color: #60a0e0;
    --common-color: #808090;
    --boss-color: #e04050;
    --shadow-soft: 0 4px 20px rgba(0,0,0,0.5);
    --shadow-hard: 0 2px 10px rgba(0,0,0,0.8);
    --glow-gold: 0 0 20px rgba(240,192,96,0.3);
    --glow-red: 0 0 20px rgba(224,64,80,0.3);
    --glow-blue: 0 0 20px rgba(64,128,224,0.3);
    --transition-fast: 0.15s ease;
    --transition-med: 0.3s ease;
    --transition-slow: 0.5s ease;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-med);
}

.screen.active {
    display: flex;
    opacity: 1;
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.92);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 40px;
    overflow-y: auto;
}

.overlay.active {
    display: flex;
}

.overlay h2 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin-bottom: 30px;
    font-size: 28px;
}

.overlay-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    max-width: 900px;
    margin-bottom: 30px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px;
}

/* Buttons */
.menu-btn {
    font-family: 'Cinzel', serif;
    font-size: 18px;
    font-weight: 700;
    padding: 14px 40px;
    background: linear-gradient(135deg, var(--bg-light), var(--bg-card));
    color: var(--text-primary);
    border: 1px solid rgba(240, 192, 96, 0.3);
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.menu-btn:hover {
    background: linear-gradient(135deg, var(--bg-card), #303050);
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
    transform: translateY(-2px);
}

.small-btn {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 6px 14px;
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.small-btn:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.2);
}

.btn-back {
    position: absolute;
    bottom: 30px;
    left: 30px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    padding: 8px 20px;
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-card);
    border-radius: 3px;
}

/* Damage Numbers */
#damage-numbers {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2000;
}

.damage-number {
    position: absolute;
    font-family: 'Cinzel', serif;
    font-weight: 900;
    font-size: 32px;
    pointer-events: none;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    animation: float-up 1s ease-out forwards;
}

.damage-number.damage { color: var(--accent-red); }
.damage-number.heal { color: var(--accent-green); }
.damage-number.block { color: var(--block-color); }
.damage-number.buff { color: var(--accent-gold); }

@keyframes float-up {
    0% { transform: translateY(0) scale(1.2); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.8); opacity: 0; }
}

/* Tooltip */
.tooltip {
    position: fixed;
    background: var(--bg-dark);
    border: 1px solid var(--accent-gold);
    border-radius: 6px;
    padding: 10px 14px;
    max-width: 250px;
    font-size: 13px;
    color: var(--text-primary);
    z-index: 3000;
    pointer-events: none;
    display: none;
    box-shadow: var(--shadow-soft);
    line-height: 1.5;
}

.tooltip.visible {
    display: block;
}

/* HP / Energy displays */
.hp-display, .gold-display, .floor-display, .energy-display {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 16px;
    padding: 4px 12px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.hp-display {
    color: var(--hp-color);
    background: rgba(224, 64, 80, 0.1);
}

.gold-display {
    color: var(--accent-gold);
    background: rgba(240, 192, 96, 0.1);
}

.floor-display {
    color: var(--accent-cyan);
    background: rgba(64, 192, 208, 0.1);
}

.energy-display {
    color: var(--energy-color);
    background: rgba(240, 192, 96, 0.15);
    font-size: 20px;
}

/* Rest Screen */
.rest-choices {
    display: flex;
    gap: 40px;
    margin-top: 40px;
}

.rest-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 30px 50px;
    background: var(--bg-light);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    color: var(--text-primary);
    font-family: 'Cinzel', serif;
    font-size: 20px;
    cursor: pointer;
    transition: all var(--transition-med);
}

.rest-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
    transform: translateY(-4px);
}

.rest-icon {
    font-size: 48px;
}

.rest-desc {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Shop */
.shop-gold {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    color: var(--accent-gold);
    margin-bottom: 20px;
}

.shop-items {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    max-width: 900px;
    margin-bottom: 30px;
}

.shop-item {
    position: relative;
    cursor: pointer;
}

.shop-price {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    color: var(--accent-gold);
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 14px;
    padding: 2px 10px;
    border-radius: 10px;
    border: 1px solid var(--accent-gold);
    z-index: 1;
}

.shop-actions {
    margin-bottom: 20px;
}

/* Relic display */
.relic-list {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    max-width: 600px;
    margin-bottom: 30px;
}

.relic-item {
    width: 60px;
    height: 60px;
    background: var(--bg-card);
    border: 2px solid rgba(240, 192, 96, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.relic-item:hover {
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
    transform: scale(1.1);
}

/* Victory / Game Over */
#victory-screen, #gameover-screen {
    background: linear-gradient(135deg, rgba(10,10,15,0.95), rgba(20,20,32,0.95));
}

#victory-screen h2 {
    font-family: 'Cinzel', serif;
    font-size: 48px;
    color: var(--accent-gold);
    text-shadow: 0 0 30px rgba(240, 192, 96, 0.5);
}

#gameover-screen h2 {
    font-family: 'Cinzel', serif;
    font-size: 48px;
    color: var(--accent-red);
    text-shadow: 0 0 30px rgba(224, 64, 80, 0.5);
}

#victory-stats, #gameover-stats {
    margin: 30px 0;
    font-size: 16px;
    line-height: 2;
    color: var(--text-secondary);
}

.stat-line {
    display: flex;
    justify-content: space-between;
    min-width: 300px;
}

.stat-label { color: var(--text-dim); }
.stat-value { color: var(--text-primary); font-weight: 600; }

/* Potion Bar */
.potion-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-left: 10px;
}

.potion-slot {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-medium);
    border: 2px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

.potion-slot.filled:hover {
    transform: scale(1.2);
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
}

.potion-slot.empty {
    opacity: 0.3;
    cursor: default;
}

.potion-slot.filled {
    border-color: rgba(255,255,255,0.3);
}

/* Settings */
.settings-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 400px;
    margin-bottom: 30px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.setting-row label {
    font-size: 15px;
    color: var(--text-secondary);
}

.setting-toggle {
    font-family: 'Cinzel', serif;
    font-size: 13px;
    padding: 6px 16px;
    background: var(--bg-card);
    color: var(--accent-gold);
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 60px;
}

.setting-toggle:hover {
    background: rgba(240, 192, 96, 0.15);
}

.setting-toggle.off {
    color: var(--text-dim);
    border-color: var(--text-dim);
}

.setting-slider {
    width: 150px;
    accent-color: var(--accent-gold);
}

.setting-select {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
}

/* HP Bar (player) */
.hp-bar-wrapper {
    width: 100%;
    max-width: 120px;
    height: 6px;
    background: rgba(0,0,0,0.4);
    border-radius: 3px;
    overflow: hidden;
}

.hp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #c03040, #e05060);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Achievement popup */
.achievement-popup {
    position: fixed;
    top: 20px;
    right: -400px;
    width: 350px;
    background: linear-gradient(135deg, #1a1530, #252045);
    border: 2px solid var(--accent-gold);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 5000;
    box-shadow: 0 0 30px rgba(240, 192, 96, 0.3);
    transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.achievement-popup.visible {
    right: 20px;
}

.ach-icon {
    font-size: 40px;
    flex-shrink: 0;
}

.ach-title {
    font-size: 11px;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ach-name {
    font-family: 'Cinzel', serif;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.ach-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Combo display */
@keyframes combo-pop {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -60%) scale(1); opacity: 0; }
}

/* Turn counter */
.turn-counter {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    color: var(--text-dim);
    position: absolute;
    top: 45px;
    left: 20px;
}
