:root {
    --bg-color: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --player1-color: #ff4757;
    --player2-color: #1e90ff;
    --player3-color: #2ed573;
    --player4-color: #eccc68;
    --neutral-color: #334155;
    --map-stroke: #1e293b;
}

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

html {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 64, 175, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(225, 29, 72, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    overflow: hidden; /* Prevent scrolling, full screen game */
    height: 100dvh;
    display: flex;
    flex-direction: column;
}
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.overlay-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    max-height: 95vh;
    overflow-y: auto;
    z-index: 100;
}

.menu-group {
    margin-bottom: 20px;
    text-align: left;
}

.menu-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.menu-group select, .menu-group input {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    font-family: inherit;
}

.menu-group select option {
    background: var(--bg-color);
}

.highscore-container {
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: #f1c40f;
}

.start-btn {
    width: 100%;
    padding: 15px;
    border: none;
    border-radius: 8px;
    background: linear-gradient(to right, #ff4757, #1e90ff);
    color: white;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

h1 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 15px;
    letter-spacing: 1px;
    text-transform: uppercase;
    background: linear-gradient(to right, #ff4757, #1e90ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.turn-indicator {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 15px;
}



.score-card {
    padding: 4px 10px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    transition: transform 0.2s ease, background-color 0.2s;
}

.player-name {
    font-weight: 700;
    font-size: 0.85rem;
    margin: 0;
    width: 90px;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
}

.player-stats {
    display: flex;
    gap: 6px;
    font-size: 0.85rem;
    color: #e2e8f0;
}

.player-stats span {
    display: flex;
    align-items: center;
    gap: 3px;
    background: rgba(255,255,255,0.1);
    padding: 2px 5px;
    border-radius: 4px;
}

.red-score { border-bottom: 3px solid var(--player1-color); }
.blue-score { border-bottom: 3px solid var(--player2-color); }
.green-score { border-bottom: 3px solid var(--player3-color); }
.yellow-score { border-bottom: 3px solid var(--player4-color); }

/* Home Link (Start Screen) */
.home-link {
    position: absolute;
    top: calc(14px + env(safe-area-inset-top));
    left: calc(14px + env(safe-area-inset-left));
    z-index: 120;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    padding: 0.6rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--glass-border);
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: all;
    transition: all 0.2s ease;
}
.home-link:hover {
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

/* Settings Cog Button */
#btn-settings {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    font-size: 1.2rem;
    cursor: pointer;
    outline: none;
}

/* UI Header Compact Layout */
#ui-header {
    flex: 1;
    max-width: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 6px 12px;
    position: relative;
    text-align: left;
}

#ui-title {
    font-size: 1.1rem;
    margin-bottom: 2px;
    text-align: left;
    background: linear-gradient(to right, #ff4757, #1e90ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.turn-indicator {
    font-size: 0.85rem;
    margin-bottom: 2px;
    font-weight: 600;
}

#game-status {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    animation: pulse 2s infinite;
}

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

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    flex-grow: 1;
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Beautiful custom scrollbars for game-container */
.game-container::-webkit-scrollbar {
    height: 8px;
}
.game-container::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}
.game-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}
.game-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

#map-container, #physics-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Let physics canvas handle pointer events when needed */
}

#physics-container {
    pointer-events: auto; /* Physics canvas needs to intercept drag/drop */
}

/* Map SVG Styling */
svg {
    width: 100%;
    height: 100%;
}

.province {
    fill: var(--neutral-color);
    stroke: var(--map-stroke);
    stroke-width: 1.5;
    transition: fill 0.3s ease;
}

.province:hover {
    filter: brightness(1.2);
}

.province.player1 { fill: var(--player1-color); cursor: pointer; }
.province.player2 { fill: var(--player2-color); cursor: pointer; }
.province.player3 { fill: var(--player3-color); cursor: pointer; }
.province.player4 { fill: var(--player4-color); cursor: pointer; }

.province-label {
    fill: rgba(255, 255, 255, 0.85);
    font-size: 10px;
    font-weight: 700;
    text-anchor: middle;
    pointer-events: none;
    text-shadow: 0px 0px 3px rgba(0,0,0,0.8);
}

.active-shooter-ring {
    animation: shooter-pulse 1.5s infinite;
}

@keyframes shooter-pulse {
    0% { r: 5px; opacity: 1; stroke-width: 3px; stroke: #ffffff; filter: drop-shadow(0 0 5px #000); }
    100% { r: 35px; opacity: 0; stroke-width: 6px; stroke: #ffffff; filter: drop-shadow(0 0 5px #000); }
}

/* Responsive Styles for Mobile & Landscape Views */
@media (max-width: 768px), (max-height: 580px) {
    #game-ui > div:first-child {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 6px !important;
        padding: 4px !important;
    }
    #ui-header {
        flex: 1 1 250px !important;
        max-width: 320px !important;
        width: auto !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 4px 8px !important;
    }
    #ui-header #ui-title {
        font-size: 0.95rem !important;
        margin: 0 !important;
        text-align: left !important;
    }
    #ui-header .turn-indicator {
        font-size: 0.75rem !important;
        margin: 0 !important;
        text-align: right !important;
        white-space: nowrap !important;
    }
    #ui-header .turn-indicator br {
        display: none !important;
    }
    #ui-header .turn-indicator #txt-turn-wait {
        margin-left: 8px !important;
    }
    #ui-header #game-status {
        display: none !important; /* Hide details on small heights to save space */
    }
    .score-board {
        flex: 2 1 400px !important;
        max-width: 680px !important;
        width: auto !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        gap: 4px !important;
        padding: 4px !important;
    }
    .score-card {
        padding: 3px 6px !important;
        font-size: 0.75rem !important;
        gap: 4px !important;
        flex: 1 1 0px !important; /* Single horizontal row of 4 columns */
        min-width: 0 !important;
        border-bottom-width: 2px !important;
    }
    .player-name {
        width: auto !important;
        font-size: 0.75rem !important;
        margin: 0 !important;
        white-space: nowrap !important;
    }
    .player-stats {
        font-size: 0.7rem !important;
        gap: 2px !important;
    }
    .player-stats span {
        padding: 1px 3px !important;
        gap: 1px !important;
    }
}

/* Mobile Warning Overlay */
#mobile-warning {
    display: none; /* Controlled by JS */
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color);
    z-index: 99999;
    color: white;
    text-align: center;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(at 0% 0%, rgba(30, 64, 175, 0.25) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(225, 29, 72, 0.25) 0px, transparent 50%);
}

#mobile-warning .warning-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 40px 30px;
    border-radius: 20px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    max-width: 90%;
    width: 420px;
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

#mobile-warning .warning-icon {
    font-size: 4.5rem;
    margin-bottom: 20px;
}

#mobile-warning h2 {
    margin: 0 0 15px 0;
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(to right, #ff4757, #1e90ff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

#mobile-warning p {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    margin-bottom: 0;
}
