@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&display=swap');

:root {
    --bg-color: #030a16;
    --panel-bg: rgba(13, 20, 36, 0.85);
    --accent-color: #58a6ff;
    --gold: #f2cc60;
    --production: #ff7b72;
    --science: #79c0ff;
    --culture: #bc8cff;
    --food: #7ee787;
    --text-main: #e6edf3;
    --text-dim: rgba(230, 237, 243, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
}

#playable-area {
    position: relative;
    margin: 0 auto;
    width: 100vmin;
    height: 100vmin;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    z-index: 10;
    user-select: none;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
}

#playable-area * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

#game-canvas {
    display: block;
    cursor: grab;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
}

#ui-layer>* {
    pointer-events: auto;
}

.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

/* --- HUD (Top) --- */
#hud {
    position: absolute;
    top: 2%;
    left: 2%;
    right: 2%;
    height: 8%;
    min-height: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2%;
    z-index: 100;
    border-bottom: 2px solid rgba(88, 166, 255, 0.3);
}

.civ-info {
    display: flex;
    flex-direction: column;
}

#civ-name {
    font-weight: 800;
    color: var(--accent-color);
    font-size: 0.9rem;
    letter-spacing: 1px;
}

#game-year {
    font-size: 0.7rem;
    color: var(--text-dim);
}

.stats-group {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 700;
    font-size: 0.75rem;
}

.rate {
    font-size: 0.6rem;
    color: var(--text-dim);
    font-weight: normal;
}

#stat-gold {
    color: var(--gold);
}

#stat-science {
    color: var(--science);
}

#stat-happiness {
    color: #7ee787;
}

#stat-culture {
    color: var(--culture);
}

.turn-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.premium-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 4px 12px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.7rem;
    text-transform: uppercase;
}

.premium-btn.primary {
    background: linear-gradient(135deg, rgba(88, 166, 255, 0.2), rgba(88, 166, 255, 0.4));
    border: 1px solid var(--accent-color);
}

/* --- SELECTION (Bottom Left) --- */
#selection-pane {
    position: absolute;
    bottom: 4%;
    left: 2%;
    width: 45%;
    max-width: 400px;
    height: auto;
    max-height: 42%;
    padding: 1.5%;
    overflow-y: auto;
    border-left: 3px solid var(--accent-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

#selection-pane.city-view {
    height: 42%;
}

.pane-header {
    display: flex;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
    align-items: center;
}

#selection-icon {
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 4px;
}

.pane-title-group {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#selection-header {
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#selection-sub {
    font-size: 0.65rem;
    color: var(--text-dim);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.3rem;
    font-size: 0.65rem;
}

.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

#selection-pane .premium-btn {
    padding: 6px 4px !important;
    font-size: 0.65rem !important;
    min-height: 32px !important;
    line-height: 1.2;
}

.action-btn {
    padding: 4px !important;
    font-size: 0.6rem !important;
    min-height: 26px !important;
}

#minimap-container {
    position: absolute;
    bottom: 2%;
    right: 2%;
    width: 35%;
    max-width: 250px;
    height: 32%;
    /* Increased slightly to fit top buttons */
    padding: 0;
    /* Remove padding to allow absolute controls to stick to edges */
    background: rgba(0, 0, 0, 0.9);
    border: 1px solid var(--accent-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.minimap-top-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    gap: 4px;
    padding: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

.help-icon-btn {
    min-width: 24px !important;
    height: 24px !important;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem !important;
    border-radius: 50% !important;
}

.end-turn-btn {
    flex: 1;
    font-size: 0.6rem !important;
    padding: 0 4px !important;
    min-height: 24px !important;
    letter-spacing: 0.5px;
}

#minimap-canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    background: #000;
}

.auto-play-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 10;
}

.auto-play-label {
    font-size: 0.65rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* --- OTHERS --- */
#research-tracker {
    position: absolute;
    top: 12%;
    right: 2%;
    width: 30%;
    max-width: 180px;
    padding: 1.5%;
}

.tracker-header {
    font-size: 0.6rem;
    font-weight: 800;
    color: var(---science);
    margin-bottom: 4px;
}

.progress-bar-container {
    height: 4px;
    background: #000;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--science);
    transition: width 0.3s;
}

#notifications {
    position: absolute;
    bottom: 32%;
    left: 2%;
    width: 50%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}

#cities-panel {
    display: none;
}

/* Hide on small square view, or sim*/
#playable-area #tooltip {
    position: absolute;
    z-index: 1000;
    pointer-events: none;
    padding: 0.5rem 0.8rem;
    font-size: 0.75rem;
    min-width: 140px;
    max-width: 180px;
    line-height: 1.4;
    transition: none;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: none;
}

#playable-area .city-item {
    padding: 0.5rem;
    margin-bottom: 0.4rem;
    background: rgba(0, 0, 0, 0.95);
    /* Added from original #tooltip */
    border: 1px solid var(--accent-color);
    /* Added from original #tooltip */
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

#playable-area .city-item:hover {
    background: rgba(88, 166, 255, 0.1);
    border-color: var(--accent-color);
}

#playable-area .city-item-name {
    font-weight: 800;
    font-size: 0.8rem;
    color: #fff;
}

#playable-area .city-item-stats {
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 0.1rem;
}

#modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal {
    width: 85%;
    max-width: 600px;
    height: 80%;
    max-height: 80%;
    background: #111;
    border: 1px solid var(--accent-color);
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--accent-color);
}

.modal header h2 {
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.modal-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) transparent;
}

.production-option-btn {
    color: #fff !important;
}

.hidden {
    display: none !important;
}

/* --- MOBILE SPECIFIC OVERRIDES --- */
@media (max-width: 480px) {
    #selection-pane {
        width: 60%;
    }

    #minimap-container {
        width: 35%;
        height: 20%;
    }

    .stat .rate {
        display: none;
    }

    #civ-name {
        font-size: 0.75rem;
    }
}