:root {
    --bg-dark: #0f1219;
    --panel-bg: rgba(23, 28, 41, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);
    --text-light: #e2e8f0;
    --text-muted: #94a3b8;
    --p1-color: #3b82f6;
    --p1-glow: rgba(59, 130, 246, 0.3);
    --p2-color: #ef4444;
    --p2-glow: rgba(239, 68, 68, 0.3);
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-purple: #8b5cf6;
    --accent-stone: #78716c;
    --font-family: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

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

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-light);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header / Top Bar */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(180deg, rgba(15, 18, 25, 0.95) 0%, rgba(15, 18, 25, 0.6) 100%);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

.logo {
    font-weight: 700;
    font-size: 24px;
    letter-spacing: 1.5px;
    background: linear-gradient(90deg, var(--p1-color), var(--p2-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 10px;
}

.phase-indicator {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.phase-indicator span.active {
    color: var(--accent-yellow);
    text-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    border-color: var(--text-muted);
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, var(--p1-color) 0%, #2563eb 100%);
    border: none;
    box-shadow: 0 0 12px var(--p1-glow);
}

.btn-primary:hover {
    box-shadow: 0 0 20px var(--p1-color);
}

/* Main Content Layout */
.game-container {
    display: flex;
    flex: 1;
    height: calc(100vh - 60px);
    position: relative;
}

/* Sidebars */
.sidebar {
    width: 320px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 16px;
    overflow-y: auto;
    z-index: 5;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

/* Player Details Box */
.player-card {
    border-radius: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: box-shadow 0.3s ease;
}

.player-card.active-player-border {
    border-color: var(--active-color);
    box-shadow: 0 0 15px var(--active-glow);
}

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

.player-name {
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.player-p1 .player-name { color: var(--p1-color); }
.player-p2 .player-name { color: var(--p2-color); }

.resources-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.resource-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.resource-icon {
    width: 18px;
    height: 18px;
}

.res-food { color: var(--accent-green); }
.res-wood { color: var(--accent-yellow); }
.res-gold { color: #fbbf24; }
.res-stone { color: var(--accent-stone); }

.tech-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tech-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
}

.tech-item:hover {
    border-color: var(--border-color);
    background: rgba(255, 255, 255, 0.06);
}

.tech-item.researched {
    background: rgba(16, 185, 129, 0.1);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--accent-green);
}

/* Action Panel & Commands */
.actions-panel {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.actions-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-pb: 6px;
}

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

.btn-action {
    font-size: 12px;
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-action:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-muted);
}

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

/* Log / Action Journal */
.log-container {
    height: 150px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    padding: 8px;
    font-family: monospace;
    font-size: 11px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.log-entry {
    line-height: 1.4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    padding-bottom: 2px;
}

.log-info { color: var(--text-muted); }
.log-p1 { color: #60a5fa; }
.log-p2 { color: #f87171; }
.log-success { color: var(--accent-green); }
.log-combat { color: #f472b6; }

/* Board Area */
.board-container {
    flex: 1;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle, #1a2035 0%, #0c0e17 100%);
    overflow: hidden;
}

svg#game-map {
    width: 100%;
    height: 100%;
    max-width: 900px;
    max-height: 900px;
}

/* SVGs & Cells Style */
.hex-cell {
    fill: #1e293b;
    stroke: #334155;
    stroke-width: 1.5px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.hex-cell:hover {
    fill: #334155;
    stroke: var(--text-muted);
}

/* Terrain Types */
.tile-forest { fill: #064e3b; stroke: #047857; }
.tile-gold { fill: #78350f; stroke: #d97706; }
.tile-stone { fill: #44403c; stroke: #78716c; }
.tile-meadow { fill: #14532d; stroke: #15803d; }

.hex-cell.selected {
    stroke: var(--accent-yellow);
    stroke-dasharray: 4;
    stroke-width: 3px;
    filter: drop-shadow(0 0 8px var(--accent-yellow));
}

.hex-cell.highlight-move {
    fill: rgba(59, 130, 246, 0.25);
    stroke: var(--p1-color);
    stroke-width: 2px;
}

.hex-cell.highlight-attack {
    fill: rgba(239, 68, 68, 0.25);
    stroke: var(--p2-color);
    stroke-width: 2px;
}

.hex-cell.highlight-build {
    fill: rgba(16, 185, 129, 0.25);
    stroke: var(--accent-green);
    stroke-width: 2px;
}

/* Info Display Card overlay on map */
.tile-inspector {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 24px;
    display: flex;
    gap: 24px;
    align-items: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    z-index: 8;
    pointer-events: none;
    transition: opacity 0.2s ease;
    opacity: 0;
}

.tile-inspector.visible {
    pointer-events: auto;
    opacity: 1;
}

/* Overlay Modals */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: #111827;
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    width: 480px;
    max-width: 90%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-text {
    color: var(--text-muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

/* Pop counts */
.pop-indicator {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
}

/* Build Option Buttons in Modal */
.build-option-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--border-color);
    padding: 12px 20px;
    border-radius: 8px;
    color: var(--text-light);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}
.build-option-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-green);
}
.build-option-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.05);
}
.build-option-details {
    font-size: 12px;
    color: var(--text-muted);
}
