/* Horde Defense - Tower Defense Game Styles */

/* Game-specific variables */
:root {
    --bg-primary: var(--color-bg, #1e2520);
    --bg-secondary: var(--color-bg-dark, #161c18);
    --bg-panel: rgba(10, 10, 15, 0.95);
    --border-primary: #8a6a3a;
    --border-secondary: #6a4a2a;
    --accent-gold: #D4A017;
    --accent-gold-dim: #b08a18;
    --text-primary: #f0e6d0;
    --text-secondary: #b8a68e;
    --danger: #8b2020;
    --danger-light: #8b2c2c;
    --success: #2d5a27;
    --success-light: #3d7a37;
    --health-green: #4CAF50;
    --health-red: #c62828;
    --mana-blue: #1976D2;
}

/* Game-specific body overrides */
body {
    overflow: hidden;
}

/* Hide noise texture over game canvas */
body::before {
    display: none;
}

/* Site nav override for game page */
.site-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
}

/* Screens */
.screen {
    position: fixed;
    top: 33px;
    left: 0;
    width: 100%;
    height: calc(100% - 33px);
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    background: rgba(10, 10, 15, 0.9);
    overflow-y: auto;
    padding: 20px 0;
}

.screen.hidden {
    display: none;
}

.screen-content {
    text-align: center;
    padding: 40px;
    background: var(--bg-panel);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    margin: auto;
}

/* Typography */
.game-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    color: var(--accent-gold);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
    letter-spacing: 4px;
}

.subtitle {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

h2, h3 {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin-bottom: 15px;
}

/* Buttons */
.primary-btn {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    padding: 15px 40px;
    background: linear-gradient(180deg, var(--border-primary), var(--border-secondary));
    border: 2px solid var(--accent-gold);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.primary-btn:hover {
    background: linear-gradient(180deg, var(--accent-gold-dim), var(--border-primary));
    transform: scale(1.05);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.secondary-btn {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    padding: 10px 25px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

/* Map Selection */
.map-selection {
    margin: 30px 0;
}

.map-options {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.map-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 25px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 150px;
}

.map-btn:hover {
    border-color: var(--accent-gold);
}

.map-btn.selected {
    border-color: var(--accent-gold);
    background: rgba(138, 106, 58, 0.3);
}

.map-name {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    margin-bottom: 5px;
}

.map-difficulty {
    font-size: 0.8rem;
    padding: 2px 10px;
    border-radius: 10px;
}

.map-difficulty.easy {
    background: var(--success);
}

.map-difficulty.medium {
    background: var(--accent-gold-dim);
}

.map-difficulty.hard {
    background: var(--danger);
}

.map-bonus {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000;
    font-weight: bold;
    margin-left: 5px;
}

/* Tutorial Section */
.tutorial-section {
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    max-width: 500px;
}

.tutorial-section h3 {
    color: var(--accent-gold);
    margin-bottom: 15px;
    font-family: 'Cinzel', serif;
    text-align: center;
}

.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.tutorial-step {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px;
    background: rgba(138, 106, 58, 0.15);
    border-radius: 5px;
    border-left: 3px solid var(--accent-gold);
}

.step-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.step-text {
    flex: 1;
}

.step-text strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 3px;
    font-family: 'Cinzel', serif;
}

.step-text p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
    margin: 0;
}

.step-text .highlight {
    color: var(--accent-gold);
    font-weight: bold;
}

.tutorial-step.nft-bonus {
    border-left-color: var(--accent-gold);
    background: rgba(212, 160, 23, 0.15);
}

/* High Scores / Leaderboard */
.high-scores {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-secondary);
}

.high-scores h3 {
    margin-bottom: 15px;
    color: var(--accent-gold);
}

.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.lb-tab {
    flex: 1;
    padding: 8px 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-secondary);
    border-radius: 5px;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.lb-tab:hover {
    background: rgba(138, 106, 58, 0.3);
    border-color: var(--accent-gold-dim);
}

.lb-tab.active {
    background: var(--accent-gold-dim);
    border-color: var(--accent-gold);
    color: var(--text-primary);
}

.leaderboard {
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    padding: 10px;
}

.score-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-secondary);
    gap: 10px;
}

.score-entry:last-child {
    border-bottom: none;
}

.score-entry .rank {
    color: var(--accent-gold);
    font-weight: bold;
    min-width: 25px;
}

.score-entry .player-name {
    flex: 1;
    color: var(--text-primary);
}

.score-entry .map-name {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.score-entry .score-value {
    color: var(--accent-gold);
    font-weight: bold;
    font-family: 'Cinzel', serif;
}

/* High Score Entry Form */
.highscore-entry {
    margin: 20px 0;
    padding: 15px;
    background: rgba(212, 160, 23, 0.1);
    border: 2px solid var(--accent-gold);
    border-radius: 5px;
    text-align: center;
}

.new-highscore {
    color: var(--accent-gold);
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 10px;
    animation: pulse 1s ease-in-out infinite;
}

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

.highscore-entry input {
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    padding: 10px 15px;
    border: 1px solid var(--border-primary);
    background: rgba(0, 0, 0, 0.5);
    color: var(--text-primary);
    border-radius: 3px;
    margin-right: 10px;
    width: 150px;
}

.highscore-entry input::placeholder {
    color: var(--text-secondary);
}

.final-stat.highlight {
    background: rgba(212, 160, 23, 0.2);
    border: 1px solid var(--accent-gold);
    border-radius: 5px;
}

.final-stat.highlight span {
    color: var(--accent-gold);
}

.final-stat.speed-bonus {
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid #00ffff;
    border-radius: 5px;
    padding: 10px 15px;
}

.final-stat.speed-bonus span:last-child {
    color: #00ffff;
}

/* NFT Section */
.nft-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-secondary);
}

.wallet-btn {
    font-family: 'Cinzel', serif;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--accent-gold);
    color: var(--accent-gold);
    cursor: pointer;
    transition: all 0.3s ease;
}

.wallet-btn:hover {
    background: rgba(212, 160, 23, 0.2);
}

#wallet-status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Game Screen */
#game-screen {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    background: rgba(10, 10, 15, 0.95);
}

#game-screen.hidden {
    display: none;
}

/* Top Bar */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border-primary);
}

.stat-group {
    display: flex;
    gap: 20px;
}

.stat {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.2rem;
    font-weight: 600;
}

.stat-icon {
    width: 24px;
    height: 24px;
    display: inline-block;
}

.gold-icon {
    background: radial-gradient(circle, var(--accent-gold) 40%, var(--accent-gold-dim) 100%);
    border-radius: 50%;
    box-shadow: 0 0 5px var(--accent-gold);
}

.lives-icon {
    background: var(--health-red);
    clip-path: path('M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z');
    transform: scale(1.2);
}

.wave-info {
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: var(--accent-gold);
}

.controls {
    display: flex;
    gap: 10px;
}

.control-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.control-btn:hover {
    border-color: var(--accent-gold);
    background: var(--border-secondary);
}

/* Game Container */
#game-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

#game-canvas {
    flex: 1;
    background: #1c1e1a;
    cursor: crosshair;
    touch-action: none;
}

/* Tower Panel */
#tower-panel {
    width: 220px;
    background: var(--bg-panel);
    border-left: 2px solid var(--border-primary);
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#tower-panel h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
    text-align: center;
}

#tower-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
}

.tower-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.tower-btn:hover:not(:disabled) {
    border-color: var(--accent-gold);
}

.tower-btn.selected {
    border-color: var(--accent-gold);
    background: rgba(138, 106, 58, 0.4);
}

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

.tower-icon {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.tower-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tower-info {
    flex: 1;
}

.tower-name {
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    display: block;
}

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

/* Selected Tower Info */
#selected-tower-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    padding: 15px;
    margin-top: 15px;
}

#selected-tower-info.hidden {
    display: none;
}

#selected-tower-name {
    font-family: 'Cinzel', serif;
    color: var(--accent-gold);
    margin-bottom: 10px;
    font-size: 1rem;
}

#selected-tower-stats {
    font-size: 0.85rem;
    margin-bottom: 15px;
}

#selected-tower-stats .stat-line {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid var(--border-secondary);
}

.tower-actions {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 8px;
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-btn:hover:not(:disabled) {
    border-color: var(--accent-gold);
}

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

.action-btn.sell {
    border-color: var(--danger);
}

.action-btn.sell:hover {
    background: var(--danger);
}

/* Wave Controls */
#wave-controls {
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid var(--border-secondary);
}

#wave-controls .primary-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

#next-wave-preview {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

#enemy-preview {
    display: flex;
    gap: 5px;
    margin-top: 5px;
    flex-wrap: wrap;
}

.enemy-preview-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-secondary);
}

/* Game Over / Victory Screens */
#gameover-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    color: var(--danger-light);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

.victory-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    color: var(--accent-gold) !important;
    text-shadow: 0 0 20px var(--accent-gold), 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-bottom: 10px;
}

.final-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 30px 0;
    flex-wrap: wrap;
}

.final-stat {
    text-align: center;
}

.final-stat .label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.final-stat span:last-child {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    color: var(--accent-gold);
}

.gameover-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Pause Overlay */
.overlay {
    position: fixed;
    top: 33px;
    left: 0;
    width: 100%;
    height: calc(100% - 33px);
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    background: var(--bg-panel);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 30px;
}

.overlay-content button {
    display: block;
    width: 200px;
    margin: 10px auto;
}

/* Tower Colors */
.tower-grunt { background: #6B8E23; }
.tower-archer { background: #8B4513; }
.tower-berserker { background: #8B0000; }
.tower-shaman { background: #4B0082; }
.tower-warlord { background: #DAA520; }
.tower-siege { background: #2F4F4F; }

/* Enemy Colors */
.enemy-squire { background: #C0C0C0; }
.enemy-knight { background: #708090; }
.enemy-archer { background: #228B22; }
.enemy-cavalry { background: #8B4513; }
.enemy-mage { background: #4169E1; }
.enemy-boss { background: #FFD700; }

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-gold-dim);
}

/* Responsive */
@media (max-width: 900px) {
    #game-container {
        flex-direction: column;
    }

    #tower-panel {
        width: 100%;
        max-height: 250px;
        border-left: none;
        border-top: 2px solid var(--border-primary);
    }

    #tower-list {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .tower-btn {
        flex: 1;
        min-width: 100px;
    }
}

@media (max-width: 600px) {
    .game-title {
        font-size: 2rem;
    }

    .map-options {
        flex-direction: column;
    }

    .map-btn {
        width: 100%;
    }

    .final-stats {
        flex-direction: column;
        gap: 15px;
    }

    #top-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    .stat {
        font-size: 1rem;
    }

    .controls {
        width: 100%;
        justify-content: center;
    }

    .primary-btn,
    .secondary-btn {
        width: 100%;
        min-height: 44px;
    }
}

@media (max-width: 400px) {
    .game-title {
        font-size: 1.6rem;
        letter-spacing: 2px;
    }

    .tower-btn {
        min-width: 80px;
        padding: 8px;
        gap: 6px;
    }

    .tower-icon {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }

    .tower-name {
        font-size: 0.8rem;
    }

    .stat {
        font-size: 0.9rem;
        gap: 4px;
    }
}

/* Range indicator */
.range-indicator {
    pointer-events: none;
}

/* Floating damage text animation would be done in JS/Canvas */

/* NFT tower glow effect */
.tower-btn.nft-tower {
    border-color: var(--accent-gold);
    box-shadow: 0 0 10px var(--accent-gold);
}

.tower-btn.nft-tower::after {
    content: 'NFT';
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--accent-gold);
    color: var(--bg-primary);
    font-size: 0.6rem;
    padding: 2px 5px;
    border-radius: 3px;
}

/* Loading Screen */
.loading-screen {
    z-index: 200;
    background: rgba(10, 10, 15, 0.98);
}

.loading-content {
    text-align: center;
    padding: 40px;
}

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

.loading-bar-container {
    width: 300px;
    height: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto 15px;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-gold-dim), var(--accent-gold));
    border-radius: 8px;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-gold);
}

#loading-percent {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    color: var(--text-secondary);
}

#loading-overlay.hidden {
    display: none;
}

/* Game wrapper */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}
