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

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

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* Start Screen */
#start-screen {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

#start-screen h1 {
    font-size: 4rem;
    color: #e94560;
    text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
    margin-bottom: 0.5rem;
}

.subtitle {
    font-size: 1.2rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.version {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 2.5rem;
    font-weight: 300;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2rem;
    min-width: 320px;
}

.option-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.option-group label {
    font-size: 0.9rem;
    color: #aaa;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.button-group button {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid #333;
    background: #252540;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.button-group button:hover {
    background: #333355;
    border-color: #555;
}

.button-group button.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    background: #333;
    border-radius: 4px;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: #e94560;
    border-radius: 50%;
    cursor: pointer;
}

.primary-btn {
    padding: 1rem 3rem;
    font-size: 1.2rem;
    background: #e94560;
    border: none;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.primary-btn:hover {
    background: #ff6b6b;
    transform: scale(1.05);
}

.secondary-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.victory-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Game Screen */
#game-screen {
    position: relative;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* UI Overlay */
#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

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

/* Scoreboard */
#scoreboard {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    min-width: 180px;
    max-height: 50vh;
}

.scoreboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 600;
    color: #e94560;
}

#scoreboard-content {
    max-height: calc(50vh - 40px);
    overflow-y: auto;
    padding: 10px;
    transition: max-height 0.3s ease;
}

#scoreboard-content.collapsed {
    display: none;
}

.kingdom-score {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0 2px 0;
}

.kingdom-resources:last-child {
    border-bottom: none;
}

.kingdom-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}

.kingdom-name {
    flex: 1;
    font-size: 0.85rem;
}

.kingdom-name.eliminated {
    text-decoration: line-through;
    opacity: 0.5;
}

.kingdom-points {
    font-weight: bold;
    font-size: 0.9rem;
}

.kingdom-territory {
    font-size: 0.75rem;
    color: #888;
    width: 50px;
    text-align: right;
}

.kingdom-dominance {
    font-size: 0.75rem;
    color: #4ea8de;
    width: 45px;
    text-align: right;
    font-weight: 600;
}

.kingdom-resources {
    display: flex;
    gap: 3px;
    padding: 2px 0 6px 24px;
    font-size: 0.75rem;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.kingdom-resources span {
    display: inline-block;
    width: 38px;
    text-align: left;
    white-space: nowrap;
}

/* Zoom Controls */
#zoom-controls {
    position: absolute;
    bottom: 80px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px;
    border-radius: 8px;
}

.zoom-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    background: #333;
    border: 1px solid #555;
    color: #ccc;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: bold;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.zoom-btn:hover {
    background: #444;
    border-color: #777;
}

.zoom-btn:active,
.zoom-btn.keyboard-flash {
    background: #e94560;
    border-color: #e94560;
    color: white;
    transform: scale(0.95);
}

.zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #222;
    border-color: #444;
}

/* Controls */
#controls {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border-radius: 8px;
}

#controls button {
    padding: 8px 16px;
    background: #333;
    border: 1px solid #555;
    color: #ccc;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

#controls button:hover {
    background: #444;
}

#controls button.active,
#pause-btn.paused {
    background: #e94560;
    border-color: #e94560;
    color: white;
}

#controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: #222;
    border-color: #444;
}

.speed-controls {
    display: flex;
    gap: 5px;
}

/* Layer Panel */
#layer-panel {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    min-width: 180px;
    font-size: 0.85rem;
}

.layer-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    color: #e94560;
}

.collapse-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0 4px;
    line-height: 1;
}

.collapse-btn:hover {
    color: #fff;
}

.layer-panel-content {
    padding: 8px 12px;
}

.layer-panel-content.collapsed {
    display: none;
}

.layer-toggles {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.layer-toggles label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    color: #ccc;
}

.layer-toggles label:hover {
    color: #fff;
}

.layer-toggles input[type="checkbox"] {
    accent-color: #e94560;
    width: 14px;
    height: 14px;
}

.legend-section {
    padding-top: 10px;
}

.legend-title {
    font-weight: 600;
    color: #e94560;
    margin-bottom: 8px;
}

.legend-subtitle {
    color: #888;
    font-size: 0.8rem;
    margin: 8px 0 4px 0;
}

.legend-subtitle:first-child {
    margin-top: 0;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    color: #ccc;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.legend-bonus, .legend-yield {
    margin-left: auto;
    font-size: 0.75rem;
}

.legend-bonus {
    color: #48c774;
}

.legend-yield {
    color: #4ea8de;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.legend-content.collapsed {
    display: none;
}

.legend-shape {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: inline-block;
}

.legend-capital {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e94560;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.legend-city-basic {
    width: 10px;
    height: 10px;
    background: #e94560;
    border: 1px solid #fff;
    transform: rotate(45deg);
    margin: 2px;
}

.legend-city-major {
    width: 12px;
    height: 12px;
    background: #e94560;
    border: 2px solid #fff;
    transform: rotate(45deg);
    margin: 1px;
}

.legend-port-basic {
    width: 8px;
    height: 8px;
    background: #e94560;
    border: 1px solid #fff;
    margin: 3px;
}

.legend-port-major {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e94560;
    border: 2px solid #fff;
    box-sizing: border-box;
    margin: 1px;
}

.legend-line {
    width: 24px;
    height: 2px;
    flex-shrink: 0;
    position: relative;
}

.legend-wavy {
    background: linear-gradient(
        90deg,
        transparent 0%, #e94560 10%, transparent 20%,
        #e94560 30%, transparent 40%, #e94560 50%,
        transparent 60%, #e94560 70%, transparent 80%,
        #e94560 90%, transparent 100%
    );
    background-size: 8px 2px;
    height: 4px;
    border-radius: 2px;
}

.legend-dashed {
    background: repeating-linear-gradient(
        90deg,
        #e94560 0px, #e94560 3px,
        transparent 3px, transparent 7px
    );
}

/* Minimap Panel */
#minimap-panel {
    position: absolute;
    bottom: 80px;
    right: 75px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    min-width: 150px;
    font-size: 0.85rem;
}

.minimap-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    color: #e94560;
}

.minimap-content {
    padding: 8px;
}

.minimap-content.collapsed {
    display: none;
}

#minimap-canvas {
    width: 150px;
    height: 112px;
    border-radius: 4px;
    cursor: pointer;
    background: #1a1a2e;
}

/* Turn counter in controls */
#controls #turn-counter {
    padding: 8px 12px;
    color: #4ea8de;
    font-weight: 600;
    border-right: 1px solid rgba(255,255,255,0.2);
    margin-right: 5px;
}

/* Victory Overlay */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-content {
    text-align: center;
    padding: 3rem;
    background: #252540;
    border-radius: 12px;
    border: 2px solid #e94560;
}

.overlay-content h2 {
    font-size: 3rem;
    color: #e94560;
    margin-bottom: 1rem;
}

.overlay-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
}

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

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* Help Button */
.button-row {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.secondary-btn {
    padding: 1rem 2.5rem;
    font-size: 1.1rem;
    background: #4a4a6a;
    border: 2px solid #6a6a8a;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 600;
}

.secondary-btn:hover {
    background: #5a5a7a;
    border-color: #8a8aaa;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(106, 106, 138, 0.5);
}

/* Help Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    pointer-events: all;
}

.modal-content {
    background: #1a1a2e;
    border: 2px solid #e94560;
    border-radius: 10px;
    max-width: 900px;
    max-height: 90vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 40px rgba(233, 69, 96, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #333;
}

.modal-header h2 {
    margin: 0;
    color: #e94560;
    font-size: 1.8rem;
}

.close-btn {
    background: none;
    border: none;
    color: #888;
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover {
    color: #e94560;
    transform: scale(1.2);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    color: #ddd;
    line-height: 1.6;
}

/* Help content formatting */
.modal-body h1 {
    color: #e94560;
    font-size: 2rem;
    margin: 2rem 0 1rem 0;
    border-bottom: 2px solid #333;
    padding-bottom: 0.5rem;
}

.modal-body h1:first-child {
    margin-top: 0;
}

.modal-body h2 {
    color: #4ea8de;
    font-size: 1.5rem;
    margin: 1.5rem 0 0.75rem 0;
}

.modal-body h3 {
    color: #48c774;
    font-size: 1.2rem;
    margin: 1rem 0 0.5rem 0;
}

.modal-body h4 {
    color: #ffdd57;
    font-size: 1rem;
    margin: 0.75rem 0 0.5rem 0;
}

.modal-body p {
    margin: 0.5rem 0;
}

.modal-body ul, .modal-body ol {
    margin: 0.5rem 0 0.5rem 2rem;
}

.modal-body li {
    margin: 0.25rem 0;
}

.modal-body code {
    background: #252540;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    color: #48c774;
    font-size: 0.9em;
}

.modal-body pre {
    background: #252540;
    padding: 1rem;
    border-radius: 5px;
    overflow-x: auto;
    margin: 1rem 0;
    border-left: 4px solid #e94560;
}

.modal-body pre code {
    background: none;
    padding: 0;
    color: #ddd;
}

.modal-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.modal-body table th {
    background: #252540;
    color: #e94560;
    padding: 0.75rem;
    text-align: left;
    border: 1px solid #333;
}

.modal-body table td {
    padding: 0.75rem;
    border: 1px solid #333;
}

.modal-body table tr:nth-child(even) {
    background: #1e1e30;
}

.modal-body hr {
    border: none;
    border-top: 1px solid #333;
    margin: 2rem 0;
}

.modal-body blockquote {
    border-left: 4px solid #4ea8de;
    padding-left: 1rem;
    margin: 1rem 0;
    color: #aaa;
    font-style: italic;
}

.modal-body strong {
    color: #e94560;
    font-weight: 600;
}

.modal-body em {
    color: #4ea8de;
}

/* Help Modal Tabs */
.help-modal-content {
    display: flex;
    flex-direction: column;
    max-height: 85vh;
}

.help-tabs {
    display: flex;
    gap: 0.25rem;
    padding: 0 1rem;
    background: #252540;
    border-bottom: 2px solid #333;
    flex-shrink: 0;
    overflow-x: auto;
}

.help-tab {
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.help-tab:hover {
    color: #ddd;
    background: rgba(255, 255, 255, 0.05);
}

.help-tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
    background: rgba(233, 69, 96, 0.1);
}

.help-modal-content .modal-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Hide Table of Contents in tabbed view */
.help-toc-hidden {
    display: none !important;
}

/* Restart Confirmation Modal */
.confirm-modal {
    max-width: 500px;
}

.confirm-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

.confirm-buttons button {
    min-width: 150px;
}

/* Victory Screen */
.victory-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin: 1rem 0;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    color: #fff;
    font-size: 1.5rem;
    font-weight: bold;
}

.resources-section {
    margin-top: 1rem;
}

.resources-title {
    display: block;
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.victory-resources {
    width: 100%;
    border-collapse: collapse;
    margin: 0 auto;
    max-width: 500px;
}

.victory-resources th {
    background: #252540;
    color: #ddd;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    font-weight: normal;
    border: 1px solid #333;
}

.victory-resources td {
    background: #1a1a2e;
    color: #48c774;
    padding: 0.75rem;
    font-size: 1.1rem;
    font-weight: bold;
    text-align: center;
    border: 1px solid #333;
}

/* Language Switcher */
.language-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #333;
    background: #252540;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 4px;
}

.lang-btn:hover {
    background: #333355;
    border-color: #555;
    color: #ccc;
}

.lang-btn.active {
    background: #e94560;
    border-color: #e94560;
    color: white;
}
