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

body {
    background: #0a0a1a;
    color: #e0e0ff;
    font-family: 'Segoe UI', system-ui, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
}

/* Animated star background */
#stars-bg {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 40% 70%, rgba(200,200,255,0.6), transparent),
        radial-gradient(1.5px 1.5px at 60% 20%, rgba(180,220,255,0.7), transparent),
        radial-gradient(1px 1px at 80% 60%, rgba(255,200,255,0.5), transparent),
        radial-gradient(1px 1px at 10% 80%, rgba(200,255,255,0.6), transparent),
        radial-gradient(1.5px 1.5px at 90% 40%, rgba(220,200,255,0.7), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255,255,200,0.5), transparent),
        radial-gradient(1px 1px at 30% 90%, rgba(200,255,200,0.4), transparent);
    background-size: 300px 300px;
    animation: twinkle 8s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

@keyframes twinkle {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}

/* UI Panel */
#ui-panel {
    position: relative;
    z-index: 10;
    width: 260px;
    padding: 20px;
    background: rgba(10, 10, 40, 0.9);
    border-right: 1px solid rgba(100, 150, 255, 0.2);
    display: flex;
    flex-direction: column;
    gap: 14px;
    backdrop-filter: blur(10px);
}

#ui-panel h1 {
    font-size: 1.3rem;
    color: #80dfff;
    text-shadow: 0 0 10px rgba(100, 200, 255, 0.5);
    text-align: center;
}

#energy-display {
    background: rgba(0, 200, 255, 0.1);
    border: 1px solid rgba(0, 200, 255, 0.3);
    border-radius: 8px;
    padding: 10px 14px;
    text-align: center;
}

#energy-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #00e5ff;
    text-shadow: 0 0 8px rgba(0, 229, 255, 0.5);
}

#energy-rate {
    font-size: 0.85rem;
    color: #80dfff;
    margin-left: 4px;
}

.label {
    font-size: 0.85rem;
    color: #aab;
    margin-right: 6px;
}

#tile-info {
    text-align: center;
    font-size: 0.9rem;
    color: #aab;
}

#hover-info {
    text-align: center;
    font-size: 0.85rem;
    min-height: 2.5em;
    color: #ccf;
    padding: 8px;
    background: rgba(50, 50, 100, 0.4);
    border-radius: 6px;
}

/* Win/lose progress bar */
#win-lose-bar {
    height: 12px;
    background: rgba(50, 50, 80, 0.6);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    border: 1px solid rgba(100, 100, 200, 0.3);
}

#player-bar {
    height: 100%;
    background: linear-gradient(90deg, #00bcd4, #00e5ff);
    transition: width 0.3s ease;
    width: 0%;
}

#enemy-bar {
    height: 100%;
    background: linear-gradient(90deg, #e040fb, #ff4081);
    transition: width 0.3s ease;
    width: 0%;
    margin-left: auto;
}

#bar-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #889;
}

#game-status {
    text-align: center;
    font-size: 1.1rem;
    font-weight: bold;
    min-height: 1.5em;
}

#restart-btn {
    background: rgba(0, 200, 255, 0.2);
    border: 1px solid rgba(0, 200, 255, 0.5);
    color: #80dfff;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

#restart-btn:hover {
    background: rgba(0, 200, 255, 0.35);
    box-shadow: 0 0 12px rgba(0, 200, 255, 0.3);
}

/* Difficulty selector */
#difficulty-select {
    text-align: center;
}

#diff-buttons {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.diff-btn {
    flex: 1;
    padding: 6px 8px;
    font-size: 0.8rem;
    background: rgba(50, 50, 100, 0.4);
    border: 1px solid rgba(100, 150, 255, 0.3);
    color: #aab;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    background: rgba(80, 80, 150, 0.5);
    color: #ccf;
}

.diff-btn.active {
    background: rgba(0, 200, 255, 0.2);
    border-color: rgba(0, 200, 255, 0.6);
    color: #00e5ff;
    box-shadow: 0 0 8px rgba(0, 200, 255, 0.2);
}

/* Hex Map */
#hex-map {
    position: relative;
    z-index: 5;
    flex: 1;
    cursor: pointer;
}

.hex-tile {
    stroke: rgba(80, 120, 200, 0.3);
    stroke-width: 1;
    fill: rgba(20, 25, 50, 0.6);
    transition: fill 0.2s, filter 0.2s, opacity 0.2s;
}

.hex-tile:hover {
    stroke: rgba(150, 200, 255, 0.7);
    stroke-width: 2;
    filter: brightness(1.3) !important;
}

.hex-tile.flash-reject {
    filter: brightness(0.5) !important;
}

.hex-tile.owned-player {
    fill: rgba(0, 188, 212, 0.5);
    stroke: rgba(0, 229, 255, 0.8);
    stroke-width: 1.5;
}

.hex-tile.owned-enemy-0 {
    fill: rgba(156, 39, 176, 0.5);
    stroke: rgba(224, 64, 251, 0.8);
    stroke-width: 1.5;
}

.hex-tile.owned-enemy-1 {
    fill: rgba(76, 175, 80, 0.5);
    stroke: rgba(105, 240, 110, 0.8);
    stroke-width: 1.5;
}

.hex-tile.owned-enemy-2 {
    fill: rgba(255, 152, 0, 0.5);
    stroke: rgba(255, 200, 50, 0.8);
    stroke-width: 1.5;
}

/* Frontier edges — glow only on sides touching enemy */
.frontier-edge {
    stroke-width: 3;
    stroke-linecap: round;
    animation: frontier-edge-pulse 1.8s ease-in-out infinite;
}

.frontier-edge-player {
    stroke: #ffffff;
    filter: drop-shadow(0 0 5px rgba(0, 229, 255, 0.8));
}

.frontier-edge-enemy0 {
    stroke: #ffffff;
    filter: drop-shadow(0 0 5px rgba(224, 64, 251, 0.8));
}

.frontier-edge-enemy1 {
    stroke: #ffffff;
    filter: drop-shadow(0 0 5px rgba(105, 240, 110, 0.8));
}

.frontier-edge-enemy2 {
    stroke: #ffffff;
    filter: drop-shadow(0 0 5px rgba(255, 200, 50, 0.8));
}

@keyframes frontier-edge-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.hex-tile.unaffordable:hover {
    stroke: rgba(255, 80, 80, 0.7);
}

.hex-tile.start-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

/* Capture progress ring */
.capture-ring {
    fill: none;
    stroke: #00e5ff;
    stroke-width: 3;
    stroke-linecap: round;
    filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.8));
    transform-origin: center;
    transition: stroke-dashoffset 0.05s linear;
    pointer-events: none;
}

.capture-ring.capture-complete {
    stroke: #ffffff;
    stroke-width: 5;
    filter: drop-shadow(0 0 12px rgba(255, 255, 255, 0.9));
    opacity: 0;
    transition: opacity 0.3s, stroke-width 0.3s;
}

.ai-ring {
    stroke-width: 2.5;
    opacity: 0.85;
}

/* Area Capture */
.area-capture-highlight {
    fill: rgba(0, 229, 255, 0.25) !important;
    stroke: #00e5ff !important;
    stroke-width: 2;
    animation: area-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes area-pulse {
    from { fill: rgba(0, 229, 255, 0.15); }
    to { fill: rgba(0, 229, 255, 0.35); }
}

#area-capture-indicator {
    margin-top: 8px;
    padding: 6px 10px;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.4);
    border-radius: 6px;
    text-align: center;
}

#area-capture-indicator .ac-label {
    color: #00e5ff;
    font-size: 0.85rem;
    font-weight: bold;
    text-shadow: 0 0 6px rgba(0, 229, 255, 0.5);
}

#area-capture-indicator .ac-progress-bar {
    display: none;
}

