/* Idle Cult Empire - Fullscreen Gameboard Layout */

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

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

:root {
    --bg-darkest: #0e0e12;
    --bg-dark: #141418;
    --bg-panel: #1a1a22;
    --bg-card: #22212a;
    --bg-hover: #2a2832;
    --text-primary: #e0dcd0;
    --text-secondary: #b0a898;
    --text-muted: #706860;
    --accent-purple: #6a5a8a;
    --accent-purple-light: #8a72b0;
    --accent-purple-dark: #4a3a6a;
    --accent-red: #a83030;
    --accent-green: #3a8a4a;
    --accent-gold: #c8a038;
    --accent-blue: #5a6a7a;
    --border-color: #2e2c38;
    --glow-purple: 0 0 15px rgba(106, 90, 138, 0.3);
    --glow-gold: 0 0 12px rgba(184, 150, 48, 0.4);
    --font-gothic: 'Cinzel', 'Times New Roman', serif;
    --font-gothic-decorative: 'Cinzel Decorative', 'Cinzel', serif;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-darkest);
    color: var(--text-primary);
}

/* Gothic heading font for all headers and labels */
h1, h2, h3, h4, h5, h6,
.section-header h3,
.tab-label,
.spawner-tile-name,
.creature-name,
.merge-level-badge,
.essence-name,
.hud-value {
    font-family: var(--font-gothic);
}

/* Diablo-style button base — metallic dark stone */
.btn-sacrifice,
.btn-deploy,
.btn-recall,
.btn-collect-all,
.spawner-tile.spawner-buyable,
.creature-assign-row .btn-sm {
    font-family: var(--font-gothic);
    letter-spacing: 0.03em;
    border-radius: 3px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 3px rgba(0, 0, 0, 0.4);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ============================================
   GAME CONTAINER - FULLSCREEN
   ============================================ */

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* ============================================
   GAMEBOARD - FULLSCREEN CANVAS
   ============================================ */

#gameboard-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

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

/* ============================================
   TOP HUD - Resources Overlay
   ============================================ */

#top-hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(5, 5, 8, 0.95) 0%, rgba(5, 5, 8, 0) 100%);
    padding: 10px 15px 30px;
    pointer-events: none;
}

#hud-resources {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    pointer-events: auto;
}

.hud-resource {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(4, 4, 8, 0.95);
    padding: 6px 12px;
    border-radius: 3px;
    border: 1px solid rgba(106, 90, 138, 0.1);
    font-size: 0.9rem;
    font-family: var(--font-gothic);
}

.hud-resource.gems {
    border-color: var(--accent-blue);
}

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

.hud-icon-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.hud-value {
    font-weight: bold;
    min-width: 40px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

#hud-info {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#chapter-display {
    color: var(--accent-gold);
}

#multiplier-display {
    color: var(--accent-purple-light);
}

/* ============================================
   BOTTOM HUD - Actions
   ============================================ */

#bottom-hud {
    position: fixed;
    bottom: min(55%, 450px); /* Above open bottom panel */
    left: 0;
    right: 0;
    z-index: 300;
    background: linear-gradient(0deg, rgba(5, 5, 8, 0.95) 0%, rgba(5, 5, 8, 0) 100%);
    padding: 30px 15px 15px;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    pointer-events: none;
    transition: bottom 0.3s ease;
}

/* Move bottom HUD down when panel is collapsed */
body:has(#bottom-panel.collapsed) #bottom-hud {
    bottom: 60px !important;
}

/* Ritual Action Bar - pinned to left, visible when panel collapsed */
#ritual-action-bar {
    position: fixed;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 290;
    display: none;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    background: rgba(18, 18, 26, 0.95);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

body:has(#bottom-panel.collapsed) #ritual-action-bar {
    display: flex;
}

#ritual-quick-slots {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ritual-quick-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    background: var(--bg-dark);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    position: relative;
}

.ritual-quick-btn:hover:not(:disabled) {
    border-color: var(--accent-purple);
    transform: scale(1.1);
}

.ritual-quick-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ritual-quick-btn.active {
    border-color: #2a7a3a;
    box-shadow: 0 0 10px rgba(42, 122, 58, 0.3);
}

.ritual-quick-btn.cooldown::after {
    content: '';
    position: absolute;
    inset: 2px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
}

#bottom-hud > * {
    pointer-events: auto;
}

#follower-display {
    background: rgba(18, 18, 26, 0.9);
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 200px;
}

#follower-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#follower-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.15);
    border-radius: 2px;
    overflow: hidden;
}

#follower-progress {
    height: 100%;
    background: var(--accent-purple);
    transition: width 0.3s ease;
    width: 0%;
}

#follower-buttons {
    display: flex;
    gap: 4px;
}

#recruit-btn, #sacrifice-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#recruit-btn {
    background: var(--accent-green);
}

#recruit-btn:hover {
    background: #5a5;
}

#sacrifice-btn {
    background: #a33;
}

#sacrifice-btn:hover {
    background: #c44;
}

#recruit-btn:active, #sacrifice-btn:active {
    transform: scale(0.9);
}

#worship-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-purple-dark) 0%, var(--accent-purple) 100%);
    border: 3px solid var(--accent-purple-light);
    color: #d8d4c8;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: all 0.15s;
    box-shadow: 0 0 10px rgba(74, 58, 106, 0.4);
    position: relative;
    z-index: 250;
}

#worship-btn:active {
    transform: scale(0.9);
}

#worship-btn .cult-symbol {
    font-size: 1.8rem;
}

#worship-btn span:last-child {
    font-size: 0.75rem;
    color: var(--accent-green);
}

#hud-buttons {
    display: flex;
    gap: 10px;
    flex: 1;
    max-width: 200px;
    justify-content: flex-end;
}

.hud-btn {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(18, 18, 26, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hud-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-purple);
}

/* ============================================
   BOTTOM PANEL - Collapsible Menu
   ============================================ */

#bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 55%;
    max-height: 450px;
    background: rgba(4, 4, 8, 0.98);
    border-top: 1px solid rgba(74, 58, 106, 0.3);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.8), 0 -5px 30px rgba(0, 0, 0, 0.8);
}

#bottom-panel.collapsed {
    transform: translateY(calc(100% - 45px));
}

#bottom-panel.dungeon-active {
    height: 45%;
    max-height: 380px;
}

#bottom-panel.dungeon-active #panel-content {
    flex: 1;
    min-height: 0;
}

/* Expand game board when panel is collapsed */
body:has(#bottom-panel.collapsed) #gameboard-container {
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

body:has(#bottom-panel.collapsed) #game-canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Panel handle with arrow */
#panel-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5px;
    cursor: pointer;
    background: linear-gradient(180deg, #1a1a22 0%, var(--bg-dark) 100%);
    border-bottom: 1px solid rgba(74, 58, 106, 0.12);
}

#panel-arrow {
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

#panel-handle:hover #panel-arrow {
    color: var(--accent-purple);
}

#bottom-panel.collapsed #panel-arrow {
    transform: rotate(180deg);
}

#panel-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: linear-gradient(180deg, #141418 0%, #0e0e12 100%);
    border-bottom: 1px solid rgba(74, 58, 106, 0.15);
    gap: 2px;
    padding: 4px 4px;
}

#panel-tabs::-webkit-scrollbar {
    display: none;
}

.panel-tab {
    flex: 0 0 auto;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #a09890;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    position: relative;
    font-family: var(--font-gothic);
    min-width: 60px;
}

.tab-indicator {
    position: absolute;
    top: 1px;
    right: calc(50% - 20px);
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    font-size: 0.5rem;
    font-weight: bold;
    line-height: 14px;
    text-align: center;
    padding: 0 3px;
}

.tab-indicator.spawner-active {
    background: #2a7a3a;
    color: #0e0e12;
    box-shadow: 0 0 6px rgba(42, 122, 58, 0.4);
    animation: pulse-indicator 2s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.tab-icon {
    font-size: 1.6rem;
}

.tab-icon-img {
    width: 42px;
    height: 42px;
    object-fit: contain;
    filter: grayscale(0.3) brightness(1.8) drop-shadow(0 0 4px rgba(200, 195, 185, 0.3));
    transition: filter 0.2s, transform 0.2s;
}

.panel-tab:hover .tab-icon-img {
    filter: grayscale(0.1) brightness(2.0) drop-shadow(0 0 6px rgba(200, 195, 185, 0.5));
    transform: scale(1.1);
}

.panel-tab.active .tab-icon-img {
    filter: grayscale(0) brightness(1.4) drop-shadow(0 0 6px rgba(184, 150, 48, 0.6));
    transform: scale(1.1);
}

.tab-label {
    font-size: 0.65rem;
    white-space: nowrap;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.panel-tab:hover {
    background: rgba(106, 90, 138, 0.06);
    color: #b0a898;
}

.panel-tab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
    background: rgba(184, 150, 48, 0.04);
    text-shadow: 0 0 6px rgba(184, 150, 48, 0.25);
}

#panel-content {
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* CRITICAL: Hide all panel sections by default */
#panel-content > .panel-section {
    display: none !important;
}

/* CRITICAL: Show only the active panel section */
#panel-content > .panel-section.active {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.section-header {
    padding: 8px 15px;
    background: linear-gradient(90deg, rgba(74, 58, 106, 0.08) 0%, rgba(4, 4, 8, 0.95) 50%, rgba(74, 58, 106, 0.04) 100%);
    border-bottom: 1px solid rgba(74, 58, 106, 0.15);
    border-top: 1px solid rgba(60, 45, 30, 0.15);
    display: flex;
    align-items: center;
}

.section-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    margin-right: 8px;
    filter: drop-shadow(0 0 3px rgba(184, 150, 48, 0.25));
    vertical-align: middle;
}

.section-header h3 {
    color: var(--accent-gold);
    font-size: 1rem;
    margin: 0;
    font-family: var(--font-gothic-decorative);
    letter-spacing: 0.05em;
    text-shadow: 0 1px 6px rgba(184, 150, 48, 0.25);
    display: flex;
    align-items: center;
}

.scrollable-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 15px 24px;
    min-height: 0;
    background: linear-gradient(180deg, rgba(8, 6, 14, 0.95) 0%, rgba(5, 5, 8, 1) 100%);
}

/* Custom scrollbar — Diablo dark style */
.scrollable-content::-webkit-scrollbar {
    width: 6px;
}

.scrollable-content::-webkit-scrollbar-track {
    background: rgba(20, 15, 30, 0.8);
}

.scrollable-content::-webkit-scrollbar-thumb {
    background: rgba(74, 58, 106, 0.2);
    border-radius: 3px;
}

.scrollable-content::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 58, 106, 0.3);
}

.scrollable-content h4 {
    color: var(--accent-purple-light);
    font-size: 0.9rem;
    margin: 15px 0 8px;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(74, 58, 106, 0.15);
    font-family: var(--font-gothic);
    letter-spacing: 0.04em;
}

.scrollable-content h4:first-child {
    margin-top: 0;
}

/* ============================================
   BUILDINGS LIST
   ============================================ */

#buildings-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.building-card {
    background: linear-gradient(160deg, rgba(30, 28, 38, 0.95) 0%, rgba(20, 18, 28, 0.95) 100%);
    border: 1px solid rgba(160, 150, 140, 0.1);
    border-radius: 4px;
    padding: 12px;
    display: grid;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 2px 6px rgba(0, 0, 0, 0.4);
    grid-template-columns: 50px 1fr;
    grid-template-rows: auto auto;
    gap: 4px 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.building-card:hover:not(.locked) {
    border-color: var(--accent-purple);
}

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

.building-icon-wrapper {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2a2836, #1e1c28);
    border: 1px solid rgba(160, 150, 140, 0.12);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    grid-row: span 2;
    box-shadow: 0 0 8px rgba(160, 150, 140, 0.08);
}

.building-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.building-name-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.building-name {
    font-weight: bold;
    font-size: 0.95rem;
}

.building-level-badge {
    background: var(--accent-purple-dark);
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.75rem;
    white-space: nowrap;
}

.building-production {
    font-size: 0.8rem;
    color: var(--accent-green);
    line-height: 1.4;
}

.building-workers-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.building-cost {
    font-size: 0.8rem;
    color: var(--accent-gold);
    grid-column: 2;
    padding-top: 6px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
}

/* Construction Progress */
.building-card.constructing {
    border-color: var(--accent-gold);
    animation: constructPulse 2s ease-in-out infinite;
}

@keyframes constructPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(184, 150, 48, 0.2); }
    50% { box-shadow: 0 0 15px rgba(184, 150, 48, 0.4); }
}

.construction-status {
    width: 100%;
}

.construction-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-darker);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}

.construction-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #b89630);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.construction-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.construction-timer {
    font-size: 0.75rem;
    color: var(--accent-gold);
}

.skip-btn {
    padding: 2px 8px;
    font-size: 0.7rem;
    background: linear-gradient(135deg, #3a3040, #2a2030);
    border: none;
    border-radius: 4px;
    color: #b0a898;
    cursor: pointer;
    white-space: nowrap;
}

.skip-btn:hover {
    background: linear-gradient(135deg, #4a3a50, #3a3040);
    transform: scale(1.05);
}

/* ============================================
   DECORATIONS
   ============================================ */

#decorations-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
}

.decoration-card {
    background: linear-gradient(160deg, rgba(30, 28, 38, 0.95) 0%, rgba(20, 18, 28, 0.95) 100%);
    border: 1px solid rgba(160, 150, 140, 0.1);
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.decoration-card:hover:not(.locked) {
    border-color: var(--accent-purple);
    transform: translateY(-1px);
}

.decoration-card.locked {
    opacity: 0.4;
    cursor: default;
}

.decoration-card.placing {
    border-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(42, 122, 58, 0.3);
}

.decor-icon {
    font-size: 1.6rem;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.decor-icon img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.decor-name {
    font-size: 0.7rem;
    font-weight: bold;
    font-family: var(--font-gothic);
    color: var(--accent-gold);
    letter-spacing: 0.03em;
}

.decor-level {
    font-size: 0.6rem;
    background: var(--accent-purple-dark);
    padding: 1px 6px;
    border-radius: 8px;
}

.decor-bonus {
    font-size: 0.55rem;
    color: var(--accent-green);
}

.decor-lore {
    font-size: 0.5rem;
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.3;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
}

.decoration-card:hover .decor-lore {
    max-height: 60px;
}

.decor-cost {
    font-size: 0.6rem;
    color: var(--accent-gold);
    border-top: 1px solid var(--border-color);
    padding-top: 4px;
    margin-top: 2px;
    width: 100%;
}

.decor-actions {
    display: flex;
    gap: 4px;
    width: 100%;
}

.decor-actions .btn {
    flex: 1;
    font-size: 0.55rem;
    padding: 3px 6px;
}

.decor-placed-count {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.6rem;
    font-weight: bold;
    color: var(--accent-green);
    background: rgba(42, 122, 58, 0.15);
    padding: 1px 5px;
    border-radius: 6px;
}

/* ============================================
   DECORATION TOOLBAR (on-screen overlay)
   ============================================ */

#decor-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    background: rgba(15, 12, 25, 0.92);
    border: 1px solid var(--accent-purple-dark);
    border-radius: 8px;
    padding: 8px;
    max-width: 320px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

#decor-toolbar-title {
    font-family: var(--font-gothic);
    font-size: 0.7rem;
    color: var(--accent-gold);
    text-align: center;
    letter-spacing: 0.15em;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(138, 104, 32, 0.3);
    padding-bottom: 4px;
}

#decor-toolbar-items {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.decor-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(30, 25, 45, 0.8);
    border: 1px solid rgba(100, 80, 140, 0.3);
    border-radius: 6px;
    padding: 6px 2px;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 42px;
}

.decor-tool-btn:hover {
    background: rgba(60, 45, 90, 0.8);
    border-color: var(--accent-purple);
}

.decor-tool-btn.active {
    background: rgba(42, 122, 58, 0.3);
    border-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(42, 122, 58, 0.3);
}

.decor-tool-btn .tool-emoji {
    font-size: 1.2rem;
    line-height: 1;
}

.decor-tool-btn .tool-label {
    font-size: 0.45rem;
    color: var(--text-secondary);
    margin-top: 2px;
    text-align: center;
    line-height: 1.1;
    max-width: 40px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.decor-tool-btn .tool-count {
    font-size: 0.45rem;
    color: var(--accent-green);
    font-weight: bold;
}

#decor-toolbar-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

#decor-toolbar-actions button {
    flex: 1;
    min-width: 50px;
    padding: 5px 4px;
    font-size: 0.6rem;
    font-family: var(--font-gothic);
    background: rgba(30, 25, 45, 0.8);
    border: 1px solid rgba(100, 80, 140, 0.3);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    letter-spacing: 0.05em;
    transition: all 0.15s;
}

#decor-toolbar-actions button:hover {
    background: rgba(60, 45, 90, 0.8);
    color: var(--text-primary);
}

#decor-eraser-btn:hover { border-color: #c04040; color: #c04040 !important; }
#decor-export-btn:hover { border-color: var(--accent-green); color: var(--accent-green) !important; }
#decor-undo-btn:hover { border-color: var(--accent-gold); color: var(--accent-gold) !important; }
#decor-clear-all-btn:hover { border-color: #8b2020; color: #c04040 !important; }

/* ============================================
   CREATURES - MERGE BOARD
   ============================================ */

.merge-level-badge {
    font-size: 0.7rem;
    background: linear-gradient(135deg, var(--accent-purple-dark), var(--accent-purple));
    color: var(--accent-gold);
    padding: 2px 8px;
    border-radius: 3px;
    margin-left: auto;
    font-family: var(--font-gothic);
    letter-spacing: 0.03em;
    border: 1px solid rgba(74, 58, 106, 0.2);
}

/* Board is the hero — fills available width, tight layout */
.merge-board-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 6px;
    background: var(--bg-main);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 4px;
}

.merge-cell {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
    padding: 6px 2px;
    min-height: 52px;
}

.merge-cell:active {
    transform: scale(0.95);
}

.merge-cell.selected {
    border-color: var(--accent-green);
    box-shadow: 0 0 8px rgba(42, 122, 58, 0.3);
    animation: merge-pulse 0.8s ease-in-out infinite;
}

@keyframes merge-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(42, 122, 58, 0.2); }
    50% { box-shadow: 0 0 12px rgba(42, 122, 58, 0.4); }
}

.merge-cell.spawner {
    border-color: var(--accent-orange, #ff9800);
    background: linear-gradient(135deg, var(--bg-card) 80%, rgba(184, 150, 48, 0.06));
}

.merge-cell.spawner.paused {
    opacity: 0.5;
    border-color: var(--text-secondary);
    border-style: dashed;
}

.merge-cell.creature {
    border-color: var(--accent-purple);
    cursor: grab;
}

.merge-cell.creature:active {
    cursor: grabbing;
}

.merge-cell.dragging {
    opacity: 0.4;
    transform: scale(0.9);
}

.merge-cell.drag-over {
    border-color: var(--accent-green);
    background: rgba(42, 122, 58, 0.06);
    transform: scale(1.05);
}

.merge-cell.empty {
    opacity: 0.25;
    border-style: dashed;
    border-width: 1px;
    min-height: 20px;
    padding: 2px;
    background: transparent;
}

.merge-cell.empty .empty-icon {
    display: none;
}

.merge-cell.empty.drag-over {
    opacity: 0.8;
    min-height: 52px;
    padding: 6px 2px;
}

.merge-cell-icon {
    font-size: 1.4rem;
    line-height: 1;
}

.merge-cell-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    margin-top: 1px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    padding: 0 2px;
}

.spawner-progress-bar {
    width: 70%;
    height: 2px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 1px;
    margin-top: 2px;
    overflow: hidden;
}

.spawner-progress-fill {
    height: 100%;
    background: var(--accent-orange, #ff9800);
    border-radius: 1px;
    transition: width 0.3s linear;
}

.merge-trash {
    text-align: center;
    font-size: 0.7rem;
    color: var(--text-secondary);
    padding: 6px;
    margin: 4px 0;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    opacity: 0.5;
    transition: all 0.15s;
}

.merge-trash.drag-over {
    opacity: 1;
    border-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    color: #f44336;
}

/* ============================================
   MERGE OVERLAY - floats over map
   ============================================ */
.merge-overlay {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: calc(55% + 60px);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    pointer-events: none;
    padding: 10px;
    transition: bottom 0.3s ease;
}

body:has(#bottom-panel.collapsed) .merge-overlay {
    bottom: 130px;
}

.merge-overlay.hidden {
    display: none !important;
}

.merge-overlay #merge-overlay-content {
    pointer-events: auto;
    width: 92%;
    max-width: 420px;
    background: rgba(10, 10, 15, 0.92);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
    max-height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.merge-overlay #merge-overlay-content .merge-board-grid {
    min-height: 0;
    overflow-y: auto;
    flex: 1;
}

.merge-overlay #merge-overlay-content .merge-cell {
    min-height: 60px;
}

.merge-overlay .merge-board-grid {
    margin-bottom: 2px;
}

.merge-overlay .merge-hint {
    font-size: 0.6rem;
    text-align: center;
    color: var(--text-secondary);
    margin: 2px 0;
}

.merge-overlay .spawner-shop {
    margin-bottom: 4px;
}

.merge-overlay .essence-resources {
    margin-bottom: 4px;
}

/* DUNGEON BATTLE OVERLAY - floats over map like merge overlay */
.dungeon-overlay {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    bottom: 45%;
    z-index: 50;
    display: flex;
    flex-direction: column;
    pointer-events: none;
    padding: 0;
    transition: bottom 0.3s ease;
}

body:has(#bottom-panel.collapsed) .dungeon-overlay {
    bottom: 130px;
}

.dungeon-overlay.fullscreen {
    top: 0;
    bottom: 0;
    z-index: 350;
    background: rgba(20, 18, 35, 0.95);
    justify-content: center;
}

.dungeon-overlay.fullscreen #dungeon-overlay-content {
    max-height: 85vh;
}

.dungeon-fullscreen-btn {
    background: rgba(100, 100, 100, 0.3);
    border: 1px solid #888888;
    color: #bbbbbb;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.7rem;
    pointer-events: auto;
}

.dungeon-overlay.hidden {
    display: none !important;
}

.dungeon-overlay #dungeon-overlay-content {
    pointer-events: auto;
    width: 100%;
    height: 100%;
    background: rgba(30, 25, 45, 0.97);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
}

#dungeon-overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dungeon-close-btn {
    background: rgba(200, 60, 60, 0.3);
    border: 1px solid #c33;
    color: #f88;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
}

#battle-arena {
    position: relative;
    flex: 1;
    min-height: 0;
    background: linear-gradient(135deg, rgba(20, 15, 35, 0.8), rgba(30, 20, 50, 0.8));
    border-radius: 8px;
    overflow: hidden;
}

#combat-log {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70px;
    overflow-y: auto;
    font-size: 0.65rem;
    color: #c8c4b8;
    padding: 4px 8px;
    background: linear-gradient(transparent, rgba(10, 10, 15, 0.85) 20%);
    pointer-events: none;
    z-index: 3;
}

.log-entry { padding: 1px 0; }
.log-entry.kill { color: #8c8; }
.log-entry.death { color: #c66; }

#dungeon-roster {
    display: none;
}

#roster-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.roster-card {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(40, 35, 60, 0.8);
    border: 1px solid #4a4858;
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.7rem;
    cursor: pointer;
}
.roster-card.empty { opacity: 0.5; cursor: default; }
.roster-card .creature-icon { font-size: 1rem; }
.roster-card .creature-power { color: #aaaaaa; font-size: 0.6rem; }

/* Battle entities */
.entity {
    position: absolute;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: left 0.1s linear, top 0.1s linear;
}

.entity .entity-icon { font-size: 1.2rem; line-height: 1; }
.entity.boss .entity-icon { font-size: 1.6rem; }

.entity-hp-bar {
    width: 36px;
    height: 5px;
    background: #2a2832;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 2px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.entity-hp-fill {
    height: 100%;
    background: #3a8a4a;
    transition: width 0.15s;
    border-radius: 2px;
}
.entity.ally .entity-hp-fill { background: #3a8a4a; box-shadow: 0 0 4px rgba(58, 138, 74, 0.4); }
.entity.enemy .entity-hp-fill { background: #a83030; box-shadow: 0 0 4px rgba(168, 48, 48, 0.5); }
.entity.boss .entity-hp-fill { background: #b05028; box-shadow: 0 0 6px rgba(176, 80, 40, 0.6); }
.entity.boss .entity-hp-bar { width: 44px; height: 6px; }

.entity.dying {
    opacity: 0;
    transform: scale(0.5) translate(-50%, -50%) !important;
    transition: opacity 0.3s, transform 0.3s;
}

.entity.attacking { animation: entity-attack 0.15s ease-out; }
@keyframes entity-attack { 50% { transform: translate(-50%, -50%) scale(1.2); } }

.entity.support-aura::after {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 1px dashed rgba(100, 180, 255, 0.3);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.damage-number {
    position: absolute;
    font-size: 0.7rem;
    font-weight: bold;
    pointer-events: none;
    animation: dmg-float 0.8s ease-out forwards;
}
.damage-number.ally-dmg { color: #ffa; }
.damage-number.enemy-dmg { color: #f66; }
@keyframes dmg-float {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-25px); }
}

.wave-banner {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px rgba(100, 60, 200, 0.8);
    animation: banner-fade 2.2s ease-out forwards;
    pointer-events: none;
}
.wave-banner.boss-wave { color: #8b2020; text-shadow: 0 0 10px rgba(139, 32, 32, 0.6); }
@keyframes banner-fade { 0%,70% { opacity: 1; } 100% { opacity: 0; } }

.result-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}
.result-modal-overlay.hidden { display: none; }
.result-modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--accent-purple);
    border-radius: 10px;
    padding: 20px;
    max-width: 85%;
    max-height: 80%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.8);
}
.result-modal-content h2.victory { color: #4c4; }
.result-modal-content h2.defeat { color: #c44; }
.reward-line { color: #cc8; padding: 2px 0; font-size: 0.85rem; }
.survivor-line { color: #8c8; padding: 1px 0; font-size: 0.8rem; }
.loss-line { color: #c66; padding: 1px 0; font-size: 0.8rem; }

.merge-hint {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    opacity: 0.6;
}

/* Essence Resources */
.essence-resources {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.essence-resource {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    background: rgba(184, 150, 48, 0.04);
    border: 1px solid rgba(184, 150, 48, 0.15);
    border-radius: 3px;
    font-size: 0.65rem;
    font-family: var(--font-gothic);
}

.essence-icon { font-size: 0.75rem; }
.essence-name { color: #b0a898; }
.essence-amount { font-weight: bold; color: #ffcc44; }

/* Unified Spawner Grid */
.spawner-shop {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
    margin-bottom: 8px;
}

.spawner-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 5px 7px;
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(6, 5, 12, 0.95) 100%);
    border: 1px solid rgba(74, 58, 106, 0.12);
    border-radius: 4px;
    font-size: 0.6rem;
    min-width: 0;
    transition: all 0.15s;
}

.spawner-tile-top {
    display: flex;
    align-items: center;
    gap: 3px;
}

.spawner-tile-icon { font-size: 0.9rem; }

.spawner-tile-name {
    font-size: 0.6rem;
    font-weight: 700;
    flex: 1;
    font-family: var(--font-gothic);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.spawner-tile-cost {
    font-size: 0.5rem;
    color: var(--text-secondary);
}

.spawner-tile-count {
    font-size: 0.6rem;
    font-weight: 700;
    text-align: center;
    color: #b0a898;
    background: rgba(255, 255, 255, 0.04);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin: 2px -7px -5px;
    padding: 3px 0;
    border-radius: 0 0 4px 4px;
    letter-spacing: 0.5px;
}

.spawner-active .spawner-tile-count {
    color: #4a9a5a;
    background: rgba(42, 122, 58, 0.1);
}

.spawner-tile-fuel {
    font-size: 0.5rem;
    color: #a08028;
    opacity: 0.8;
}

/* Active spawner tile */
.spawner-tile.spawner-active {
    background: rgba(42, 122, 58, 0.06);
    border-color: rgba(42, 122, 58, 0.25);
    color: #4a9a5a;
}

.spawner-tile-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.spawner-tile-fill {
    height: 100%;
    background: #2a7a3a;
    border-radius: 2px;
    transition: width 0.1s linear;
}

.spawner-tile-stop {
    background: none;
    border: none;
    color: #8b3030;
    cursor: pointer;
    font-size: 0.65rem;
    padding: 0 2px;
    line-height: 1;
    margin-left: auto;
}

.spawner-tile-stop:hover { color: #8b2020; }

.spawner-tile-status {
    font-size: 0.55rem;
    text-align: center;
}

/* Paused state */
.spawner-tile.spawner-paused {
    background: rgba(255, 100, 100, 0.12);
    border-color: #8b3020;
}

.spawner-fuel-warning {
    color: #8b3020;
    font-weight: bold;
    animation: pulse-warning 1.5s ease-in-out infinite;
}

@keyframes pulse-warning {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Buyable tile */
.spawner-tile.spawner-buyable { cursor: pointer; }
.spawner-tile.spawner-buyable:active:not(.disabled) {
    border-color: var(--accent-orange, #ff9800);
    background: rgba(184, 150, 48, 0.06);
}
.spawner-tile.disabled { opacity: 0.35; cursor: not-allowed; }

/* Creature Lair — compact grid */
#creature-lair {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 4px;
}

/* Lair tile — icon-grid style */
.lair-tile {
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(6, 5, 12, 0.95) 100%);
    border: 1px solid rgba(74, 58, 106, 0.2);
    border-radius: 8px;
    padding: 8px 4px 6px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 2px;
    position: relative;
}

.lair-tile-locked {
    opacity: 0.5;
}

.lair-tile-sprite {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lair-tile-sprite img.sprite-lair {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.lair-sprite-locked img {
    filter: brightness(0.4) grayscale(0.6);
}

.lair-tile-count {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--accent-gold, #d4af37);
}

.lair-tile-name {
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    font-weight: bold;
    color: var(--text-primary);
    line-height: 1.2;
}

.lair-tile-tier {
    font-size: 0.5rem;
    color: var(--accent-gold, #d4af37);
    letter-spacing: 1px;
}

.lair-role-badge {
    font-size: 0.5rem;
    padding: 1px 6px;
    border-radius: 8px;
    color: #111;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lair-tile-prod {
    font-size: 0.55rem;
    color: var(--accent-green, #7dcea0);
    line-height: 1.2;
}

.lair-tile-status {
    font-size: 0.5rem;
    color: var(--accent-purple-light);
    opacity: 0.8;
}

.lair-tile-lock {
    font-size: 0.5rem;
    color: var(--accent-gold, #d4af37);
    opacity: 0.7;
}

/* Keep old creature-card styles for backward compat */
.creature-card {
    background: linear-gradient(160deg, var(--bg-card) 0%, rgba(6, 5, 12, 0.95) 100%);
    border: 1px solid rgba(74, 58, 106, 0.12);
    border-radius: 4px;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.creature-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.creature-icon {
    font-size: 1.1rem;
    line-height: 1;
}

.creature-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.creature-name {
    font-size: 0.65rem;
    font-weight: bold;
    line-height: 1.2;
}

.creature-count, .creature-production {
    font-size: 0.55rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.creature-role {
    font-size: 0.5rem;
}

.btn-sacrifice {
    background: linear-gradient(135deg, #8b2020, #5a1010);
    color: #d8d4c8;
    border: 1px solid #6a2828;
    padding: 2px 5px;
    font-size: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-sacrifice:hover {
    background: linear-gradient(135deg, #a03030, #7a1818);
}

.creature-status {
    font-size: 0.55rem;
    color: var(--accent-purple-light);
    line-height: 1.2;
    opacity: 0.8;
}

.creature-actions {
    display: flex;
    gap: 3px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-deploy {
    background: linear-gradient(135deg, #2a7a3a, #1a4a20);
    color: #d8d4c8;
    border: 1px solid #3a6a3a;
    padding: 2px 6px;
    font-size: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-deploy:hover:not(:disabled) {
    background: linear-gradient(135deg, #3a8a4a, #2a6a30);
}

.btn-recall {
    background: linear-gradient(135deg, #8a6010, #5a4010);
    color: #d8d4c8;
    border: 1px solid #7a6020;
    padding: 2px 6px;
    font-size: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.btn-recall:hover:not(:disabled) {
    background: linear-gradient(135deg, #a07818, #7a5818);
}

.btn-deploy:disabled, .btn-recall:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Creature subtabs */
.creature-subtabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-dark);
    flex-shrink: 0;
}

.creature-subtab {
    flex: 1;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-gothic);
    font-size: 0.8rem;
    letter-spacing: 0.03em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.creature-subtab:hover {
    color: var(--text-primary);
    background: rgba(106, 90, 138, 0.06);
}

.creature-subtab.active {
    color: var(--accent-gold);
    border-bottom-color: var(--accent-gold);
}

.creature-subtab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.creature-subtab-content.active {
    display: flex;
}

.lair-count-badge {
    background: var(--accent-purple-dark);
    color: var(--text-primary);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    min-width: 16px;
    text-align: center;
}

.lair-count-badge:empty {
    display: none;
}

.lair-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0;
    padding-bottom: 5px;
    border-bottom: 1px solid rgba(74, 58, 106, 0.15);
}

.lair-header h4 {
    color: var(--accent-purple-light);
    font-size: 0.9rem;
    margin: 0;
    border-bottom: none;
    padding-bottom: 0;
    font-family: var(--font-gothic);
    letter-spacing: 0.04em;
}

.btn-collect-all {
    background: linear-gradient(135deg, var(--accent-purple-dark), var(--accent-purple));
    color: var(--accent-gold);
    border: 1px solid rgba(74, 58, 106, 0.3);
    padding: 4px 10px;
    font-size: 0.65rem;
    border-radius: 3px;
    font-family: var(--font-gothic);
    letter-spacing: 0.03em;
    cursor: pointer;
    white-space: nowrap;
}

.btn-collect-all:hover {
    background: linear-gradient(135deg, var(--accent-purple), var(--accent-purple-dark));
}

.dungeon-board-hint {
    background: rgba(74, 58, 106, 0.12);
    border: 1px solid var(--accent-purple);
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--accent-purple-light);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.empty-lair {
    color: var(--text-secondary);
    font-size: 0.7rem;
    padding: 8px;
    opacity: 0.5;
}

/* ============================================
   RITUALS & MISSIONS
   ============================================ */

#rituals-list, #mission-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.ritual-card, .mission-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.ritual-card:hover:not(.locked), .mission-card:hover:not(.locked) {
    border-color: var(--accent-purple);
}

.ritual-name, .mission-title {
    font-weight: bold;
    font-size: 0.9rem;
}

.ritual-effect, .mission-rewards {
    font-size: 0.75rem;
    color: var(--accent-green);
}

.ritual-cost, .mission-requirements {
    font-size: 0.75rem;
    color: var(--accent-gold);
}

#mission-slots {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.mission-slot {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 10px;
    min-width: 100px;
    flex: 1;
}

.mission-slot.active {
    border-style: solid;
    border-color: var(--accent-gold);
}

/* ============================================
   QUESTS & ACHIEVEMENTS
   ============================================ */

#chapter-progress {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 10px;
}

#chapter-progress h3,
#chapter-progress h4 {
    margin: 0 0 8px;
    border: none;
    padding: 0;
    color: var(--accent-purple);
}

#quest-list, #achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
}

.quest-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
}

.quest-card.completed {
    border-color: var(--accent-green);
    opacity: 0.7;
}

.quest-name {
    font-weight: bold;
    font-size: 0.9rem;
}

.quest-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.quest-reward {
    font-size: 0.75rem;
    color: var(--accent-gold);
}

.achievement-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.achievement-card.unlocked {
    border-color: var(--accent-gold);
}

.achievement-icon {
    font-size: 1.5rem;
    opacity: 0.3;
}

.achievement-card.unlocked .achievement-icon {
    opacity: 1;
}

.achievement-name {
    font-weight: bold;
    font-size: 0.85rem;
}

.achievement-description {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* ============================================
   UPGRADES & MANAGERS
   ============================================ */

#upgrades-list, #managers-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 10px;
}

.upgrade-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
}

.upgrade-card.purchased {
    border-color: var(--accent-green);
    opacity: 0.7;
}

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

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

.upgrade-cost {
    font-size: 0.75rem;
    color: var(--accent-gold);
}

.manager-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
}

.manager-card.owned {
    border-color: var(--accent-green);
}

.manager-avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-darkest);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.manager-name {
    font-weight: bold;
    font-size: 0.85rem;
}

.manager-effect {
    font-size: 0.7rem;
    color: var(--accent-green);
}

/* ============================================
   PRESTIGE
   ============================================ */

#prestige-content {
    text-align: center;
}

#prestige-preview {
    background: var(--bg-card);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

#prestige-preview p {
    margin: 5px 0;
    font-size: 0.9rem;
}

/* ============================================
   SETTINGS
   ============================================ */

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.setting-row span {
    font-size: 0.9rem;
}

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

.settings-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.settings-buttons .action-btn {
    width: 100%;
}

#last-save {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 15px;
}

/* Cloud Save Section */
.cloud-save-section {
    background: var(--bg-darker, #1a1a1a);
    border: 1px solid var(--border-color, #333);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
}

.cloud-save-status {
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.cloud-save-code {
    font-size: 0.9rem;
    margin-bottom: 4px;
    font-family: monospace;
}

.cloud-save-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Promo Code Input */
.promo-code-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.promo-code-input input {
    flex: 1;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-darker);
    color: var(--text-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
}

.promo-code-input input::placeholder {
    text-transform: none;
    color: var(--text-muted);
}

.promo-code-input input:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 5px rgba(74, 58, 106, 0.2);
}

.promo-code-input .action-btn {
    padding: 8px 16px;
    white-space: nowrap;
}

/* ============================================
   EVENT BANNER
   ============================================ */

#event-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    display: none;
}

#event-banner.active {
    display: block;
}

/* Push top-hud down when event banner is active */
#event-banner.active ~ #top-hud,
body.event-active #top-hud {
    top: 32px;
}

/* Push overlays down when event banner is active */
body.event-active .dungeon-overlay,
body.event-active .merge-overlay {
    top: 102px;
}

/* Shift divider down on mobile so top section retains its height */
body.event-active #bottom-panel {
    height: calc(55% - 32px);
}

body.event-active #bottom-panel.dungeon-active {
    height: calc(45% - 32px);
}

body.event-active .merge-overlay {
    bottom: calc(55% - 32px + 60px);
}

body.event-active:has(#bottom-panel.collapsed) .merge-overlay {
    bottom: 130px;
}

body.event-active .dungeon-overlay {
    bottom: 45%;
}

body.event-active:has(#bottom-panel.collapsed) .dungeon-overlay {
    bottom: 130px;
}

/* ============================================
   AUTO-SAVE INDICATOR
   ============================================ */

#save-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 150;
    background: rgba(18, 18, 26, 0.9);
    border: 1px solid var(--accent-green);
    border-radius: 6px;
    padding: 6px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--accent-green);
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

#save-indicator.saving {
    opacity: 1;
    transform: translateY(0);
    border-color: var(--accent-gold);
    color: var(--accent-gold);
}

#save-indicator.saved {
    opacity: 1;
    transform: translateY(0);
    border-color: var(--accent-green);
    color: var(--accent-green);
}

#save-indicator .save-icon {
    animation: none;
}

#save-indicator.saving .save-icon {
    animation: saveRotate 1s linear infinite;
}

@keyframes saveRotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.event-banner-content {
    background: linear-gradient(135deg, var(--accent-purple-dark), var(--accent-purple));
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    animation: eventPulse 2s ease-in-out infinite;
    font-size: 0.85rem;
}

@keyframes eventPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.event-icon {
    font-size: 1.2rem;
}

.event-name {
    font-weight: bold;
    color: #fff;
}

.event-timer {
    background: rgba(0,0,0,0.3);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.8rem;
}

.event-desc {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.9);
}

/* ============================================
   SKILLS (Talent Tree)
   ============================================ */

.skill-intro {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 0.85rem;
}

#skill-points-display {
    font-size: 0.8rem;
    color: var(--accent-gold);
}

.skill-tier {
    margin-bottom: 20px;
}

.skill-tier h4 {
    color: var(--accent-purple);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.skill-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.skill-card:hover:not(.locked):not(.maxed) {
    border-color: var(--accent-purple);
    transform: translateY(-2px);
}

.skill-card.available {
    border-color: var(--accent-green);
    box-shadow: 0 0 10px rgba(42, 122, 58, 0.2);
}

.skill-card.maxed {
    border-color: var(--accent-gold);
    background: linear-gradient(135deg, var(--bg-card), rgba(255, 215, 0, 0.1));
}

.skill-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.skill-icon {
    font-size: 1.5rem;
}

.skill-info {
    flex: 1;
}

.skill-name {
    font-weight: bold;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.skill-level {
    font-size: 0.75rem;
    color: var(--accent-purple);
}

.skill-desc {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

.skill-cost {
    font-size: 0.7rem;
    color: var(--accent-gold);
    margin-top: 3px;
}

/* ============================================
   STATISTICS
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.stat-category {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid var(--border-color);
}

.stat-category h4 {
    color: var(--accent-purple);
    margin-bottom: 10px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding: 4px 0;
    border-bottom: 1px dashed rgba(255,255,255,0.15);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-row span:first-child {
    color: var(--text-secondary);
}

.stat-row span:last-child {
    color: var(--text-primary);
    font-weight: 500;
}

/* ============================================
   PROGRESS BARS
   ============================================ */

.progress-bar {
    height: 8px;
    background: var(--bg-darkest);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar.large {
    height: 12px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-purple-dark), var(--accent-purple));
    width: 0%;
    transition: width 0.3s;
    border-radius: 4px;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */

.action-btn {
    padding: 10px 15px;
    background: var(--accent-purple-dark);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-purple);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.action-btn.danger {
    background: var(--accent-red);
}

.prestige-btn {
    background: linear-gradient(135deg, var(--accent-gold) 0%, #8a6820 100%);
    width: 100%;
    padding: 15px;
    font-size: 1rem;
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-panel);
    border: 2px solid var(--accent-purple);
    border-radius: 12px;
    padding: 20px;
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: var(--glow-purple);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: var(--accent-red);
}

/* Building Modal — Immersive Bottom Sheet */
.modal-building-immersive {
    top: auto !important;
    bottom: 0 !important;
    height: auto !important;
    max-height: 70vh !important;
    align-items: flex-end !important;
    justify-content: center !important;
    padding: 0 !important;
    background: none !important;
}

.building-modal-sheet {
    border-radius: 16px 16px 0 0 !important;
    max-width: 100% !important;
    max-height: 70vh !important;
    height: auto !important;
    width: 100% !important;
    padding: 0 !important;
    background: linear-gradient(180deg, rgba(8, 6, 14, 0.98) 0%, rgba(4, 3, 8, 1) 100%) !important;
    border: none !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5) !important;
    margin-top: auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.building-modal-sheet > .modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
}

.building-modal-sheet > .building-modal-hero {
    flex-shrink: 0;
    padding: 16px 16px 0;
    background: linear-gradient(180deg, rgba(8, 6, 14, 0.98) 0%, rgba(8, 6, 14, 0.95) 100%);
    z-index: 1;
}

.building-modal-sheet > .building-modal-scrollable {
    flex: 1;
    overflow-y: auto;
    padding: 0 16px 24px;
}

.building-modal-hero {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.building-hero-sprite {
    flex-shrink: 0;
    width: 100px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.building-hero-sprite .modal-icon {
    font-size: 1rem;
}

.building-hero-sprite .sprite-building-modal {
    width: 100px !important;
    height: 120px !important;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.8));
}

.building-hero-info {
    flex: 1;
    min-width: 0;
    padding-top: 8px;
}

.building-hero-info h2 {
    color: var(--accent-purple);
    font-size: 1.1rem;
    margin-bottom: 2px;
    font-family: var(--font-gothic);
}

.building-hero-info #building-modal-level {
    color: var(--accent-gold);
    font-size: 0.85rem;
    display: block;
    margin-bottom: 6px;
}

.building-hero-info #building-modal-description {
    color: var(--text-secondary);
    font-size: 0.75rem;
    line-height: 1.4;
    margin: 0;
}

.building-modal-stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.building-stat-block {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 8px 10px;
}

.building-stat-block h3 {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.building-modal-sheet #worker-controls {
    gap: 12px;
    margin: 4px 0;
}

.building-modal-sheet #worker-bonus-text {
    font-size: 0.65rem;
    margin: 2px 0 0;
}

.building-modal-sheet #production-stats {
    background: none;
    padding: 0;
    font-size: 0.8rem;
}

.building-modal-sheet #building-factors h3 {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Legacy header styles (kept for non-building modals) */
#building-modal-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.modal-icon {
    font-size: 2.5rem;
}

#building-modal-header h2 {
    color: var(--accent-purple);
    font-size: 1.2rem;
    margin-bottom: 4px;
}

#building-modal-level {
    color: var(--accent-gold);
    font-size: 0.9rem;
}

#building-modal-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
}

/* Modal Construction Timer */
.modal-construction {
    background: linear-gradient(135deg, rgba(184, 150, 48, 0.1), rgba(184, 150, 48, 0.06));
    border: 1px solid var(--accent-gold);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
}

.modal-construction-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.modal-construction-label {
    font-size: 0.9rem;
    color: var(--accent-gold);
    font-weight: 500;
}

.modal-construction-time {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
    font-family: monospace;
}

.modal-construction-progress-bar {
    width: 100%;
    height: 10px;
    background: var(--bg-darker);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.modal-construction-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), #b89630);
    border-radius: 5px;
    transition: width 0.3s ease;
}

.skip-construction-btn {
    width: 100%;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--accent-purple), #777777);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.skip-construction-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 58, 106, 0.25);
}

#building-factors h3,
#building-workers h3,
#building-production h3 {
    font-size: 0.9rem;
    margin: 15px 0 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}

#factors-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.factor-row {
    background: var(--bg-card);
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
    -webkit-tap-highlight-color: rgba(255,255,255,0.1);
}
.factor-row:not(.factor-maxed):active {
    background: var(--bg-hover, rgba(255,255,255,0.08));
}

.factor-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.factor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.factor-name {
    font-size: 0.85rem;
    font-weight: 500;
}

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

.factor-description {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

.factor-bonus {
    font-size: 0.75rem;
    color: var(--accent-green);
}

.factor-btn {
    padding: 4px 10px;
    font-size: 0.75rem;
    background: var(--accent-purple-dark);
    border: none;
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
}

.factor-btn:disabled {
    opacity: 0.5;
}

.cost-resource {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.cost-missing {
    color: #ff6b6b;
}

.cost-resource:hover {
    color: var(--accent-gold, #d4af37);
}

/* Building lock overlay */
.building-lock-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    min-height: 200px;
}

.lock-overlay-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.lock-overlay-title {
    font-family: 'Cinzel', serif;
    font-size: 1.4rem;
    color: var(--accent-gold, #d4af37);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.lock-overlay-reqs {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    text-align: left;
    width: 100%;
    max-width: 280px;
}

.lock-overlay-reqs li {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 0.9rem;
    color: var(--text-secondary, #aaa);
}

.lock-overlay-reqs li strong {
    color: var(--text-primary, #eee);
}

.lock-overlay-preview {
    margin-top: 0.5rem;
    padding: 0.6rem 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--accent-green, #7dcea0);
}

/* Locked building card in list */
.building-lock-reason {
    font-size: 0.7rem;
    color: var(--accent-gold, #d4af37);
    opacity: 0.8;
}

/* Spawner locked preview */
.spawner-tile-preview {
    font-size: 0.65rem;
    color: var(--accent-green, #7dcea0);
    opacity: 0.8;
    margin-top: 2px;
}

.factor-maxed {
    border-left: 3px solid var(--accent-green);
}

.factor-maxed .factor-name {
    color: var(--accent-green);
}

.factor-progress-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 10px 12px;
    text-align: center;
    border-radius: 6px;
    background: var(--bg-card);
    margin-bottom: 4px;
    border: 1px solid transparent;
    cursor: default;
    font-family: inherit;
}

.factor-progress-header:disabled {
    opacity: 0.7;
}

.factor-progress-header.factor-upgrade-ready {
    background: var(--bg-card);
    border-color: var(--accent-green);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.factor-progress-header.factor-upgrade-ready:not(:disabled):hover {
    background: rgba(76, 175, 80, 0.15);
}

.factor-progress-header.factor-upgrade-ready:disabled {
    border-color: var(--text-secondary);
    opacity: 0.5;
}

.factor-progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.factor-progress-text.level-up-ready {
    color: var(--accent-green);
    font-weight: 700;
    animation: levelUpPulse 1.5s ease-in-out infinite;
}

.factor-upgrade-cost {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

@keyframes levelUpPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.building-factor-indicator {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.building-factor-indicator.factor-all-maxed {
    color: var(--accent-green);
    font-weight: 700;
    animation: levelUpPulse 1.5s ease-in-out infinite;
}

.building-buy-action {
    margin-top: 4px;
}

.building-buy-btn {
    padding: 4px 14px;
    font-size: 0.7rem;
    font-family: var(--font-gothic);
    letter-spacing: 0.08em;
    background: linear-gradient(135deg, rgba(42, 122, 58, 0.3), rgba(42, 122, 58, 0.15));
    border: 1px solid var(--accent-green);
    color: var(--accent-green);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.building-buy-btn:hover:not(.btn-disabled) {
    background: linear-gradient(135deg, rgba(42, 122, 58, 0.5), rgba(42, 122, 58, 0.3));
    box-shadow: 0 0 8px rgba(42, 122, 58, 0.3);
}

.building-buy-btn.btn-disabled {
    opacity: 0.4;
    cursor: default;
    border-color: var(--text-secondary);
    color: var(--text-secondary);
    background: rgba(30, 25, 45, 0.5);
}

#worker-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin: 10px 0;
}

.worker-btn {
    width: 36px;
    height: 36px;
    background: var(--accent-purple-dark);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
}

.worker-btn:disabled {
    opacity: 0.5;
}

#worker-bonus-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--accent-green);
}

#production-stats {
    background: var(--bg-card);
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85rem;
}

#production-stats p {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

#building-upgrade-btn {
    width: 100%;
    margin-top: 15px;
}

/* Offline Progress Modal */
.offline-modal-content {
    text-align: center;
}
.offline-modal-content h2 {
    font-size: 1.5rem;
    color: var(--accent-gold);
    margin-bottom: 4px;
}
.offline-time-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    display: block;
}
.offline-gains-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}
.offline-gain-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,0.03);
    padding: 8px 12px;
    border-radius: 8px;
}
.offline-gain-icon {
    font-size: 1.3rem;
    width: 28px;
    text-align: center;
}
.offline-gain-label {
    flex: 1;
    text-align: left;
    color: var(--text-primary);
}
.offline-gain-value {
    color: var(--accent-green);
    font-weight: bold;
    font-family: 'Fira Code', monospace;
}
.offline-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.offline-modal-buttons .action-btn {
    flex: 1;
    max-width: 160px;
}
.boost-btn {
    background: linear-gradient(135deg, var(--accent-gold), #b8860b) !important;
    color: #000 !important;
    font-weight: bold;
}
.boost-btn:disabled {
    background: var(--bg-darker) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
}
.offline-bonus-section,
.offline-rate-section {
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.offline-bonus-header {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    text-align: left;
}
.offline-rate-note {
    color: var(--text-muted);
    font-weight: normal;
    text-transform: none;
}
.offline-bonus-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    border-radius: 6px;
}
.offline-bonus-icon {
    font-size: 1rem;
    width: 24px;
    text-align: center;
}
.offline-bonus-label {
    flex: 1;
    text-align: left;
    color: var(--text-secondary);
    font-size: 0.9rem;
}
.offline-bonus-value {
    color: var(--accent-purple);
    font-weight: bold;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
}

/* Daily Rewards Modal */
#daily-rewards-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    margin: 15px 0;
}

.daily-reward-item {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 4px;
    text-align: center;
}

.daily-reward-item.claimed {
    border-color: var(--accent-green);
    opacity: 0.6;
}

.daily-reward-item.current {
    border-color: var(--accent-gold);
    box-shadow: var(--glow-gold);
}

.daily-day {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.daily-icon {
    font-size: 1.2rem;
    margin: 4px 0;
}

.daily-amount {
    font-size: 0.65rem;
    color: var(--accent-gold);
}

/* Tutorial Overlay (action-focused) */
#tutorial-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    pointer-events: none;
}

#tutorial-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    pointer-events: auto;
}

.tutorial-highlight {
    position: relative;
    z-index: 9001 !important;
    pointer-events: auto !important;
    box-shadow: 0 0 0 4px var(--accent-gold), 0 0 20px rgba(212,175,55,0.5) !important;
    border-radius: 8px;
    animation: tutorialPulse 1.5s ease-in-out infinite;
}

@keyframes tutorialPulse {
    0%, 100% { box-shadow: 0 0 0 4px var(--accent-gold), 0 0 20px rgba(212,175,55,0.4); }
    50% { box-shadow: 0 0 0 6px var(--accent-gold), 0 0 30px rgba(212,175,55,0.7); }
}

#tutorial-tooltip {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 320px);
    background: var(--bg-card);
    border: 2px solid var(--accent-purple);
    border-radius: 14px;
    padding: 16px 20px;
    text-align: center;
    z-index: 9002;
    pointer-events: auto;
    box-shadow: 0 6px 24px rgba(0,0,0,0.4);
    animation: tooltipAppear 0.3s ease-out;
}

@keyframes tooltipAppear {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

#tutorial-tooltip.pos-above { bottom: auto; top: 12px; }
#tutorial-tooltip.pos-center { top: 50%; transform: translate(-50%, -50%); }
#tutorial-tooltip.pos-below { top: auto; bottom: 12px; }

#tutorial-tooltip-icon {
    font-size: 2.2rem;
    margin-bottom: 6px;
}

#tutorial-tooltip-title {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1.15rem;
    margin-bottom: 6px;
}

#tutorial-tooltip-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
    margin-bottom: 10px;
}

#tutorial-tooltip-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#tutorial-step-indicator {
    color: var(--text-muted);
    font-size: 0.8rem;
}

#tutorial-tooltip-footer .action-btn.secondary {
    background: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-muted);
    padding: 6px 14px;
    font-size: 0.8rem;
}

#tutorial-tooltip-footer .action-btn.secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text-secondary);
}

/* Resource Tip Modal */
.resource-tip-content {
    max-width: 380px;
}

#resource-modal-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

#resource-modal-header h2 {
    color: var(--accent-purple);
    font-size: 1.3rem;
    margin-bottom: 4px;
}

.resource-rate {
    color: var(--accent-green);
    font-size: 0.9rem;
    font-weight: 500;
}

#resource-modal-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 15px;
    line-height: 1.5;
}

#resource-modal-sources h3,
#resource-modal-tips h3 {
    font-size: 0.9rem;
    margin: 15px 0 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
    color: var(--accent-gold);
}

#resource-sources-list,
#resource-tips-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#resource-sources-list li,
#resource-tips-list li {
    padding: 6px 0;
    padding-left: 20px;
    position: relative;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

#resource-sources-list li::before {
    content: '•';
    position: absolute;
    left: 5px;
    color: var(--accent-purple);
}

#resource-tips-list li::before {
    content: '💡';
    position: absolute;
    left: 0;
    font-size: 0.7rem;
}

/* Make resource counters clickable */
.hud-resource[data-resource] {
    cursor: pointer;
    transition: all 0.2s ease;
}

.hud-resource[data-resource]:hover {
    background: rgba(74, 58, 106, 0.2);
    border-color: var(--accent-purple);
    transform: scale(1.05);
}

.hud-resource[data-resource]:active {
    transform: scale(0.98);
}

/* ============================================
   NOTIFICATIONS
   ============================================ */

#notifications {
    position: fixed;
    top: 80px;
    left: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 500;
    pointer-events: none;
    align-items: flex-start;
}

.notification {
    background: var(--bg-panel);
    border: 1px solid var(--accent-purple);
    border-radius: 8px;
    padding: 10px 15px;
    animation: slideInLeft 0.3s ease;
    box-shadow: var(--glow-purple);
    max-width: 280px;
    font-size: 0.85rem;
}

.notification.achievement {
    border-color: var(--accent-gold);
}

.notification.quest {
    border-color: var(--accent-green);
}

.notification.error {
    border-color: var(--accent-red);
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ============================================
   FLOATING NUMBERS
   ============================================ */

#floating-numbers {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 400;
}

.float-number {
    position: absolute;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--accent-green);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.8);
    animation: floatUp 1s ease-out forwards;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-50px) scale(0.8); opacity: 0; }
}

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 10, 25, 0.9);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-purple-dark);
    border-radius: 3px;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    #side-panel {
        width: 100%;
    }

    #hud-resources {
        gap: 4px;
    }

    .hud-resource {
        padding: 4px 8px;
        font-size: 0.8rem;
    }

    .hud-icon {
        font-size: 0.9rem;
    }

    .hud-icon-img {
        width: 18px;
        height: 18px;
    }

    .hud-value {
        min-width: 30px;
    }

    .tab-icon-img {
        width: 36px;
        height: 36px;
    }

    #worship-btn {
        width: 70px;
        height: 70px;
    }

    #worship-btn .cult-symbol {
        font-size: 1.5rem;
    }

    .hud-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }

    #daily-rewards-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .hud-resource {
        padding: 3px 6px;
        font-size: 0.75rem;
    }

    #worship-btn {
        width: 60px;
        height: 60px;
    }

    #worship-btn .cult-symbol {
        font-size: 1.3rem;
    }

    #daily-rewards-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .merge-board-grid {
        gap: 3px;
        padding: 4px;
    }

    .merge-cell {
        min-height: 46px;
        padding: 4px 2px;
        border-width: 1.5px;
    }

    .merge-cell.empty {
        min-height: 16px;
        padding: 1px;
    }

    .merge-cell-icon {
        font-size: 1.2rem;
    }

    .merge-cell-label {
        font-size: 0.5rem;
    }

    /* Spawner tiles: tall cards with creature image dominating */
    .spawner-shop {
        gap: 6px;
    }

    .spawner-tile {
        min-height: 140px;
        align-items: center;
        justify-content: center;
        padding: 10px 6px 8px;
    }

    .spawner-tile-top {
        flex-direction: column;
        align-items: center;
        gap: 6px;
        flex: 1;
        justify-content: center;
        width: 100%;
    }

    .spawner-tile-icon {
        font-size: 1.6rem;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .spawner-tile-icon .sprite-icon,
    .spawner-tile-icon .sprite-spawner,
    .spawner-tile-icon img {
        width: 100% !important;
        height: auto !important;
        max-height: 120px;
        object-fit: contain;
        filter: brightness(1.8) drop-shadow(0 0 6px rgba(200, 200, 220, 0.5));
    }

    .spawner-tile-name {
        font-size: 0.75rem;
        text-align: center;
        font-family: var(--font-gothic);
        color: var(--accent-gold);
        letter-spacing: 0.04em;
    }

    .spawner-tile-cost {
        text-align: center;
        font-size: 0.55rem;
    }

    .spawner-tile-fuel {
        text-align: center;
    }

    /* Buildings: 2-column grid with large building art */
    #buildings-list {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .building-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 10px 6px 8px;
        min-height: 140px;
        gap: 4px;
    }

    .building-icon-wrapper {
        width: auto;
        height: auto;
        background: none;
        border-radius: 0;
        grid-row: unset;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .building-icon-wrapper .sprite-building {
        width: 100% !important;
        height: auto !important;
        max-height: 120px;
        object-fit: contain;
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
        border-radius: 0;
    }

    .building-info {
        align-items: center;
        text-align: center;
    }

    .building-name-row {
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .building-name {
        font-size: 0.75rem;
        font-family: var(--font-gothic);
        color: var(--accent-gold);
        letter-spacing: 0.04em;
    }

    .building-level-badge {
        font-size: 0.6rem;
        padding: 1px 6px;
    }

    .building-production {
        font-size: 0.6rem;
        text-align: center;
    }

    .building-workers-info {
        font-size: 0.55rem;
        text-align: center;
    }

    .building-cost {
        grid-column: unset;
        font-size: 0.6rem;
        text-align: center;
        padding-top: 4px;
        border-top: 1px solid rgba(74, 58, 106, 0.12);
        width: 100%;
    }
}

/* ============================================
   NEW FEATURES STYLES
   ============================================ */

/* Alchemy */
.conversion-item {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(138,43,226,0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.conversion-item.disabled { opacity: 0.5; }
.conversion-header { display: flex; align-items: center; gap: 8px; }
.conversion-icon { font-size: 1.3rem; }
.conversion-desc { font-size: 0.85rem; color: #b0a898; }

/* Tasks */
.task-item {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(138,43,226,0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
}
.task-item.completed {
    border-color: rgba(0,200,0,0.5);
    background: rgba(0,100,0,0.15);
}
.task-item.weekly { border-color: rgba(255,165,0,0.4); }
.task-header { font-size: 0.95rem; margin-bottom: 4px; }
.task-desc { font-size: 0.8rem; color: #aaa; margin-bottom: 6px; }
.task-progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}
.task-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #777777, #aaaaaa);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.task-footer { font-size: 0.75rem; color: #999; }

/* Champions */
.champion-card {
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(255,50,50,0.5);
    border-radius: 10px;
    padding: 12px;
}
.champion-header { font-size: 1.1rem; margin-bottom: 8px; }
.champion-hp-bar {
    height: 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 6px;
}
.champion-hp-fill {
    height: 100%;
    background: linear-gradient(90deg, #8b2020, #8a4010);
    border-radius: 8px;
    transition: width 0.5s ease;
}
.champion-stats { font-size: 0.8rem; color: #b0a898; margin-bottom: 6px; }
.champion-rewards { font-size: 0.85rem; color: #b89630; margin-bottom: 8px; }
.champion-deploy { margin-bottom: 6px; }
.deploy-creature {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    font-size: 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 4px;
}
.deploy-creature.deployed {
    border-color: var(--accent-purple);
    background: rgba(106, 90, 138, 0.08);
}
.deploy-creature-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.deploy-creature-info .creature-role {
    font-size: 0.7rem;
    color: var(--text-secondary);
}
.deploy-creature-info .deploy-stats {
    font-size: 0.7rem;
    color: var(--accent-gold);
}
.deploy-creature-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-shrink: 0;
}

/* Relics */
.relics-header {
    font-size: 0.9rem;
    color: #b0a898;
    margin-bottom: 10px;
    text-align: center;
}
.relic-item {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(138,43,226,0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.relic-item.equipped { border-color: rgba(0,200,0,0.6); background: rgba(0,100,0,0.15); }
.relic-item.rarity-common { border-left: 3px solid #aaa; }
.relic-item.rarity-uncommon { border-left: 3px solid #2ecc71; }
.relic-item.rarity-rare { border-left: 3px solid #888888; }
.relic-item.rarity-epic { border-left: 3px solid #999999; }
.relic-item.rarity-legendary { border-left: 3px solid #f39c12; }
.relic-icon { font-size: 1.5rem; }
.relic-info { flex: 1; }
.relic-rarity { font-size: 0.75rem; color: #999; }
.relic-desc { font-size: 0.8rem; color: #b0a898; }

/* Infamy */
.dungeon-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: rgba(0,0,0,0.3);
    border-bottom: 1px solid rgba(106, 90, 138, 0.2);
    gap: 8px;
}
#infamy-display {
    flex-shrink: 0;
}
.infamy-compact {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-shrink: 0;
}
.infamy-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--accent-red);
}
.infamy-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.infamy-title {
    font-size: 0.75rem;
    font-style: italic;
    color: #ff8888;
}
.dungeon-stats-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    justify-content: flex-end;
}
.infamy-next { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 4px; }
.infamy-bonus { font-size: 0.8rem; color: var(--accent-gold); text-align: center; margin-bottom: 4px; }

/* ============================================
   DUNGEON SYSTEM
   ============================================ */

.dungeon-header {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    justify-content: center;
}

.dungeon-stat {
    font-size: 0.85rem;
    color: #b0a898;
    padding: 2px 8px;
    background: rgba(0,0,0,0.3);
    border-radius: 4px;
}

.stamina-icon { color: #99bbcc; }
.star-icon { color: #b89630; }

/* Dungeon Floor Card */
.dungeon-floor-card {
    background: rgba(0,0,0,0.4);
    border: 2px solid rgba(138,43,226,0.5);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
}

.dungeon-floor-card h4 {
    color: var(--accent-purple-light);
    margin: 0 0 8px;
    border: none;
    padding: 0;
}

.floor-art { margin: -4px 0 8px; }
.floor-enemies { font-size: 0.8rem; color: #aaa; margin-bottom: 4px; }
.floor-boss { font-size: 0.85rem; color: #8b3030; margin-bottom: 4px; }
.floor-rewards { font-size: 0.8rem; color: #b89630; margin-bottom: 4px; }
.floor-cost { font-size: 0.8rem; color: #99bbcc; margin-bottom: 8px; }

.dungeon-enter-btn {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    background: linear-gradient(135deg, #666666, #888888);
}

.dungeon-enter-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #777777, #999999);
}

/* Replay List */
.dungeon-replay-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.dungeon-replay-btn {
    font-size: 0.75rem;
    padding: 6px 10px;
    text-align: left;
}

/* Battle View */
.dungeon-battle {
    background: rgba(0,0,0,0.5);
    border: 2px solid #6a1818;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    animation: battlePulse 2s ease-in-out infinite;
}

@keyframes battlePulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255,50,50,0.3); }
    50% { box-shadow: 0 0 15px rgba(255,50,50,0.6); }
}

.dungeon-battle h4 {
    color: #8b3030;
    margin: 0 0 8px;
    border: none;
    padding: 0;
}

.battle-enemy {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.battle-enemy-icon { font-size: 2rem; }
.battle-enemy-name { font-size: 1rem; font-weight: bold; color: #ff8888; }

/* HP Bars */
.hp-bar {
    height: 16px;
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2px;
}

.hp-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.3s ease;
}

.enemy-fill {
    background: linear-gradient(90deg, #8b2020, #8a4010);
}

.player-fill {
    background: linear-gradient(90deg, #2a7a3a, #3a8a4a);
}

.hp-label {
    font-size: 0.75rem;
    color: #aaa;
    margin-bottom: 6px;
}

/* Gear Cards */
.gear-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.gear-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(138,43,226,0.3);
    border-radius: 6px;
}

.gear-card.equipped {
    border-color: rgba(0,200,0,0.5);
    background: rgba(0,100,0,0.1);
}

.gear-card.empty-gear {
    opacity: 0.5;
    font-size: 0.8rem;
    color: #a09890;
    border-style: dashed;
}

.gear-icon { font-size: 1.3rem; }
.gear-info { flex: 1; font-size: 0.8rem; }
.gear-info strong { color: #e0e0e0; }
.gear-stats { font-size: 0.75rem; color: var(--accent-green); }
.gear-rarity { font-size: 0.7rem; color: #999; }
.gear-slot-label { text-transform: capitalize; }

/* Gear Rarity Colors */
.gear-card.rarity-common { border-left: 3px solid #aaa; }
.gear-card.rarity-uncommon { border-left: 3px solid #2ecc71; }
.gear-card.rarity-rare { border-left: 3px solid #888888; }
.gear-card.rarity-epic { border-left: 3px solid #999999; }
.gear-card.rarity-legendary { border-left: 3px solid #f39c12; }

/* Star Shop */
.star-shop-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.star-shop-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.star-shop-icon {
    font-size: 1.3rem;
    width: 36px;
    text-align: center;
}
.star-shop-info {
    flex: 1;
    font-size: 0.8rem;
    line-height: 1.3;
}
.star-shop-info strong {
    color: var(--text-primary);
    font-size: 0.85rem;
}
.star-shop-subheader {
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--accent-gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 6px;
    padding-left: 4px;
}
.hud-resource.stars .hud-icon {
    font-size: 0.9rem;
}

/* Manager Upgrade Section */
.manager-upgrade-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.manager-stars {
    font-size: 0.8rem;
    color: #b89630;
    margin-top: 2px;
}

/* Stamina Bar */
.stamina-bar {
    height: 8px;
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    overflow: hidden;
    margin: 4px 0;
}

.stamina-fill {
    height: 100%;
    background: linear-gradient(90deg, #99bbcc, #bbdddd);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* Section intro text */
.section-intro {
    font-size: 0.85rem;
    color: #aaa;
    margin-bottom: 10px;
    font-style: italic;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Mission cooldown */
.mission-card.on-cooldown {
    opacity: 0.5;
    pointer-events: none;
}
.mission-cooldown {
    font-size: 0.8rem;
    color: #ff8844;
    margin-top: 4px;
    font-weight: bold;
}

/* Special missions */
.mission-card.special-mission {
    border: 2px solid rgba(255,215,0,0.5);
    background: rgba(255,215,0,0.08);
}

/* Creature role labels */
.creature-role {
    font-size: 0.7rem;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: #b0a898;
    margin-left: 4px;
}

/* Creature assignment in building modal */
.creature-assign-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.creature-assign-row span:first-child {
    flex: 1;
}

.creature-assign-row .btn-sm {
    min-width: 40px;
    min-height: 40px;
    padding: 6px 12px;
    background: var(--accent-purple-dark);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.creature-assign-row .btn-sm:hover:not(:disabled) {
    background: var(--accent-purple);
}

.creature-assign-row .btn-sm:active:not(:disabled) {
    background: var(--accent-purple);
    transform: scale(0.95);
}

.creature-assign-row .btn-sm:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: var(--bg-card);
}

.creature-assign-hint {
    font-size: 0.65rem;
    color: var(--accent-purple-light);
    opacity: 0.8;
    padding: 2px 0 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

#creature-assignment-section h4 {
    margin: 10px 0 6px;
    font-size: 0.9rem;
    color: #b0a898;
}

/* ============================================
   SPRITE IMAGES
   ============================================ */

.sprite-icon {
    object-fit: contain;
    vertical-align: middle;
    image-rendering: auto;
}

/* Brighten sprites in the bottom panel menus so dark art is visible */
#bottom-panel .sprite-icon {
    filter: grayscale(0.2) brightness(1.8) drop-shadow(0 0 5px rgba(200, 195, 185, 0.4));
}

/* Building cards */
.sprite-building {
    width: 40px;
    height: 40px;
    border-radius: 6px;
}

/* Building modal */
.sprite-building-modal {
    width: 48px;
    height: 48px;
}

/* Merge board cells */
.sprite-merge {
    width: 32px;
    height: 32px;
}

/* Creature lair */
.sprite-creature {
    width: 28px;
    height: 28px;
}

/* Creature in deploy list */
.sprite-creature-sm {
    width: 20px;
    height: 20px;
}

/* Achievement list */
.sprite-achievement {
    width: 36px;
    height: 36px;
}

/* Alchemy conversions */
.sprite-alchemy {
    width: 24px;
    height: 24px;
}

/* Dungeon enemy inline (floor preview) */
.sprite-enemy-inline {
    width: 20px;
    height: 20px;
}

/* Spawner tiles */
.sprite-spawner {
    width: 18px;
    height: 18px;
}

/* Equipment (gear cards + star shop) — the gear art is dark and detailed,
   so it needs more room than the emoji it replaces to stay readable. */
.sprite-gear {
    width: 36px;
    height: 36px;
}

/* Crafting materials (essence bar + offline gains) */
.sprite-essence {
    width: 22px;
    height: 22px;
}

/* Dungeon floor banner art */
.sprite-floor {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

/* Manager avatars */
.sprite-manager {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Relic icons */
.sprite-relic {
    width: 32px;
    height: 32px;
}

/* Skill tree icons */
.sprite-skill {
    width: 28px;
    height: 28px;
}

/* Ritual icons (inline in card header) */
.sprite-ritual-inline {
    width: 20px;
    height: 20px;
}

/* Ritual quick-slot buttons */
.sprite-ritual-quick {
    width: 22px;
    height: 22px;
}

/* Event banner icon */
.sprite-event {
    width: 24px;
    height: 24px;
}

/* HUD button icons (sacrifice, daily, audio) */
.hud-btn-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    vertical-align: middle;
    pointer-events: none;
}

/* ============================================
   SAVE MIGRATION MODAL
   ============================================ */

.migration-modal-content {
    max-width: 420px;
}

.migration-subtitle {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.migration-changelog {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 16px;
    text-align: left;
}

.migration-version {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(138, 43, 226, 0.1);
    border-left: 3px solid var(--accent-purple);
    border-radius: 4px;
}

.migration-version h4 {
    color: var(--accent-gold);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.migration-version ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.migration-version li {
    color: var(--text-secondary);
    font-size: 0.8rem;
    padding: 2px 0;
}

.migration-version li::before {
    content: '+ ';
    color: var(--accent-green, #4caf50);
}

.migration-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Battle arena entities - keep full color */
.sprite-entity {
    width: 100%;
    height: 100%;
    filter: none;
}

/* ─── Desktop enhancements (769px+) ─── */
@media (min-width: 769px) {
    /* Bigger tab icons on desktop */
    .tab-icon-img {
        width: 54px;
        height: 54px;
    }

    .panel-tab {
        padding: 6px 4px;
    }

    /* Buildings: grid layout like lair */
    #buildings-list {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 4px;
    }

    .building-card {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 4px 6px;
        min-height: 100px;
        gap: 4px;
        border-radius: 8px;
    }

    .building-icon-wrapper {
        width: auto;
        height: auto;
        background: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
        grid-row: unset;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .building-icon-wrapper .sprite-building {
        width: 64px !important;
        height: 64px !important;
        object-fit: contain;
        filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.6));
        border-radius: 0;
    }

    .building-info {
        align-items: center;
        text-align: center;
        width: 100%;
    }

    .building-name-row {
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .building-name {
        font-size: 0.7rem;
        font-family: var(--font-gothic);
        color: var(--accent-gold);
        letter-spacing: 0.04em;
    }

    .building-level-badge {
        font-size: 0.6rem;
        padding: 1px 6px;
    }

    .building-production {
        font-size: 0.6rem;
        text-align: center;
    }

    .building-workers-info {
        font-size: 0.6rem;
    }

    .building-cost {
        grid-column: unset;
        font-size: 0.65rem;
        text-align: center;
        border-top: 1px solid var(--border-color);
        padding-top: 4px;
        margin-top: 2px;
        width: 100%;
    }

    /* Spawner shop: 3-column grid to match */
    .spawner-shop {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .spawner-tile {
        align-items: center;
        padding: 8px 4px 6px;
        min-height: 90px;
        justify-content: center;
        border-radius: 8px;
    }

    .spawner-tile-top {
        flex-direction: column;
        align-items: center;
        gap: 4px;
        flex: 1;
        justify-content: center;
        width: 100%;
    }

    .spawner-tile-icon {
        font-size: 1.4rem;
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .spawner-tile-icon .sprite-icon,
    .spawner-tile-icon .sprite-spawner,
    .spawner-tile-icon img {
        width: 56px !important;
        height: 56px !important;
        object-fit: contain;
        filter: brightness(1.6) drop-shadow(0 0 4px rgba(200, 200, 220, 0.4));
    }

    .spawner-tile-name {
        font-size: 0.65rem;
        text-align: center;
        font-family: var(--font-gothic);
        color: var(--accent-gold);
        letter-spacing: 0.04em;
    }

    .spawner-tile-cost {
        text-align: center;
        font-size: 0.55rem;
    }

    .spawner-tile-fuel {
        text-align: center;
    }

    /* Merge board: larger cells on desktop */
    .merge-board-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 8px;
    }

    .merge-cell {
        min-height: 70px;
        padding: 8px 4px;
    }

    .merge-cell .sprite-icon,
    .merge-cell img {
        width: 48px !important;
        height: 48px !important;
    }

    /* Decorations: 3-column grid on desktop */
    #decorations-list {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Build tab: show buildings and decorations as columns on desktop */
    #buildings-tab .creature-subtabs {
        display: none;
    }

    #panel-content > #buildings-tab.panel-section.active {
        display: flex !important;
        flex-direction: row;
    }

    #buildings-tab > .creature-subtab-content {
        display: flex !important;
        flex: 1;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        border-right: 1px solid var(--border-color);
    }

    #buildings-tab > .creature-subtab-content:last-child {
        border-right: none;
    }

    #buildings-tab > .creature-subtab-content > .scrollable-content {
        overflow-y: auto;
        flex: 1;
        min-height: 0;
        padding: 4px;
    }

    #creature-subtab-build-buildings::before {
        content: 'Buildings';
        display: block;
        padding: 6px 12px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        border-bottom: 1px solid var(--border-color);
        text-align: center;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }

    #creature-subtab-build-decorations::before {
        content: 'Decorations';
        display: block;
        padding: 6px 12px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        border-bottom: 1px solid var(--border-color);
        text-align: center;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }

    /* ─── Creatures tab: show all subtabs as columns ─── */
    #creatures-tab .creature-subtabs {
        display: none;
    }

    #creatures-tab {
        flex-direction: row !important;
        gap: 0;
    }

    #creatures-tab .creature-subtab-content {
        display: flex !important;
        flex: 1;
        min-width: 0;
        border-right: 1px solid var(--border-color);
        overflow-y: auto;
    }

    #creatures-tab .creature-subtab-content:last-child {
        border-right: none;
    }

    #creatures-tab .creature-subtab-content .scrollable-content {
        padding: 8px;
    }

    /* Column headers for creatures subtabs */
    #creature-subtab-spawn::before {
        content: 'Spawn & Merge';
        display: block;
        padding: 6px 12px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        border-bottom: 1px solid var(--border-color);
        text-align: center;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }

    #creature-subtab-lair::before {
        content: 'Lair';
        display: block;
        padding: 6px 12px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        border-bottom: 1px solid var(--border-color);
        text-align: center;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }

    /* ─── Dungeon tab: show all subtabs as 3 columns ─── */
    #champions-tab > .creature-subtabs {
        display: none !important;
    }

    #panel-content > #champions-tab.panel-section.active {
        display: grid !important;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: auto 1fr;
        overflow: hidden;
        height: 100%;
    }

    #champions-tab > #infamy-display {
        grid-column: 1 / -1;
        grid-row: 1;
    }

    #creature-subtab-dungeon-battle {
        grid-column: 1;
        grid-row: 2;
    }
    #creature-subtab-dungeon-army {
        grid-column: 2;
        grid-row: 2;
    }
    #creature-subtab-dungeon-shop {
        grid-column: 3;
        grid-row: 2;
    }

    #champions-tab > .creature-subtab-content {
        display: flex !important;
        flex-direction: column;
        min-width: 0;
        min-height: 0;
        overflow: hidden;
        border-right: 1px solid var(--border-color);
    }

    #champions-tab > .creature-subtab-content:last-child {
        border-right: none;
    }

    #champions-tab > .creature-subtab-content > .scrollable-content {
        padding: 8px;
        overflow-y: auto;
        flex: 1;
        min-height: 0;
    }

    /* Column headers for dungeon subtabs */
    #creature-subtab-dungeon-battle::before,
    #creature-subtab-dungeon-army::before,
    #creature-subtab-dungeon-shop::before {
        display: block;
        padding: 6px 12px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        border-bottom: 1px solid var(--border-color);
        text-align: center;
        letter-spacing: 0.05em;
        flex-shrink: 0;
    }
    #creature-subtab-dungeon-battle::before { content: 'Battle'; }
    #creature-subtab-dungeon-army::before { content: 'Army'; }
    #creature-subtab-dungeon-shop::before { content: 'Shop'; }

    /* ─── Quests tab: quests & achievements side by side ─── */
    #quests-tab > #chapter-progress {
        flex-shrink: 0;
        padding: 6px 12px;
        border-bottom: 1px solid var(--border-color);
    }

    #quests-tab > .scrollable-content {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
        gap: 0;
        overflow: hidden;
        flex: 1;
        min-height: 0;
    }

    #quests-tab #quest-list {
        grid-column: 1;
        grid-row: 1;
        overflow-y: auto;
        padding: 8px;
        border-right: 1px solid var(--border-color);
        grid-template-columns: 1fr;
    }

    #quests-tab #quest-list::before {
        content: 'Quests';
        display: block;
        padding: 4px 0 8px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        text-align: center;
        letter-spacing: 0.05em;
        grid-column: 1 / -1;
    }

    #quests-tab .scrollable-content > h4 {
        display: none;
    }

    #quests-tab #achievements-list {
        grid-column: 2;
        grid-row: 1;
        overflow-y: auto;
        padding: 8px;
        grid-template-columns: 1fr;
    }

    #quests-tab #achievements-list::before {
        content: 'Achievements';
        display: block;
        padding: 4px 0 8px;
        font-family: var(--font-gothic);
        font-size: 0.8rem;
        color: var(--accent-gold);
        text-align: center;
        letter-spacing: 0.05em;
        grid-column: 1 / -1;
    }

}
