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

body {
    background: #0d1117;
    color: #e6e6e6;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: column;
    background: #161b22;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

#top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    background: #21262d;
    border-bottom: 2px solid #f85149;
}

#turn-info {
    font-size: 15px;
    font-weight: 600;
    color: #8b949e;
}

#player-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f85149;
    border: 2px solid #fff;
}

#player-info {
    font-size: 15px;
    font-weight: 700;
}

button {
    padding: 7px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s, transform 0.1s;
}

button:hover {
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

#end-turn-btn {
    background: #f85149;
    color: white;
    margin-left: auto;
}

#end-turn-btn:hover {
    background: #ff6b63;
}

#leave-btn {
    background: #6e40c9;
    color: white;
}

#leave-btn:hover {
    background: #8957e5;
}

#your-color-badge {
    font-size: 13px;
    font-weight: 700;
}

.worker-action-btn {
    margin-top: 6px;
    width: 100%;
    padding: 6px 8px;
    background: #1f4f2e;
    border: 1px solid #3fb950;
    color: #3fb950;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.worker-action-btn:hover {
    background: #2a6b3e;
}

#resource-display {
    display: flex;
    gap: 10px;
    font-size: 13px;
    font-weight: 700;
}

#iron-display {
    color: #c8922a;
}

#oil-display {
    color: #7ec8e3;
}

/* Production panel cost indicators */
.prod-btn.unaffordable {
    opacity: 0.45;
    cursor: not-allowed;
    border-color: #444;
}

.cost-ok {
    color: #3fb950;
    font-weight: 700;
}

.cost-short {
    color: #f85149;
    font-weight: 700;
}

/* ---- LOBBY SCREEN ---- */
#lobby-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

#lobby-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    min-width: 380px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#lobby-box h1 {
    font-size: 36px;
    color: #f0f6fc;
    margin-bottom: 4px;
}

.lobby-subtitle {
    color: #8b949e;
    font-size: 14px;
    margin-bottom: 32px;
}

.lobby-btn {
    display: block;
    width: 100%;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.lobby-btn.primary {
    background: #f85149;
    color: #fff;
}

.lobby-btn.primary:hover { background: #ff6b63; }

.lobby-btn.secondary {
    background: #238636;
    color: #fff;
}

.lobby-btn.secondary:hover { background: #2ea043; }

.lobby-btn.small {
    width: auto;
    display: inline-block;
    padding: 8px 20px;
    font-size: 13px;
    background: #30363d;
    color: #c9d1d9;
    margin-top: 12px;
}

.lobby-btn.small:hover { background: #484f58; }

.lobby-divider {
    display: flex;
    align-items: center;
    margin: 16px 0;
    color: #484f58;
    font-size: 12px;
}

.lobby-divider::before,
.lobby-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #30363d;
}

.lobby-divider span {
    padding: 0 12px;
    color: #8b949e;
}

.lobby-join-row {
    display: flex;
    gap: 8px;
}

.lobby-join-row input {
    flex: 1;
    padding: 10px 14px;
    font-size: 16px;
    font-family: 'Segoe UI', monospace;
    font-weight: 700;
    letter-spacing: 3px;
    text-align: center;
    text-transform: uppercase;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #f0f6fc;
    outline: none;
}

.lobby-join-row input:focus {
    border-color: #58a6ff;
}

.lobby-join-row .lobby-btn {
    width: auto;
    padding: 10px 24px;
    background: #58a6ff;
    color: #0d1117;
}

.lobby-join-row .lobby-btn:hover { background: #79c0ff; }

#lobby-status {
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

#lobby-status-text {
    color: #c9d1d9;
    font-size: 15px;
}

#lobby-room-code {
    margin-top: 4px;
}

#lobby-room-code strong {
    font-size: 28px;
    letter-spacing: 6px;
    color: #58a6ff;
    font-family: monospace;
}

.error-text {
    color: #f85149;
    font-size: 13px;
    margin-top: 12px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#main-area {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

#canvas-scroll {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

#game-canvas {
    display: block;
    cursor: pointer;
}

#side-panel {
    width: 260px;
    background: #0d1117;
    border-left: 1px solid #30363d;
    overflow-y: auto;
}

#info-panel {
    padding: 16px;
}

.panel-section {
    margin-bottom: 16px;
}

.panel-section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #f0f6fc;
    border-bottom: 1px solid #21262d;
    padding-bottom: 6px;
}

.panel-section h4 {
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 6px;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.panel-section p, .panel-section .stat-line {
    font-size: 13px;
    color: #c9d1d9;
    margin-bottom: 4px;
}

.hint {
    color: #8b949e;
    font-style: italic;
    line-height: 1.5;
}

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 12px;
    margin-top: 6px;
}

.stat-label {
    color: #8b949e;
    font-size: 12px;
}

.stat-value {
    color: #f0f6fc;
    font-size: 12px;
    font-weight: 600;
    text-align: right;
}

.hp-bar-container {
    width: 100%;
    height: 8px;
    background: #21262d;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 6px;
}

.hp-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s;
}

.hp-bar.high { background: #3fb950; }
.hp-bar.mid { background: #d29922; }
.hp-bar.low { background: #f85149; }

.progress-bar-container {
    width: 100%;
    height: 6px;
    background: #21262d;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar {
    height: 100%;
    background: #58a6ff;
    border-radius: 3px;
    transition: width 0.3s;
}

.prod-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin-bottom: 4px;
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.prod-btn:hover {
    background: #30363d;
    border-color: #58a6ff;
}

.prod-btn.active {
    background: #1f3a5f;
    border-color: #58a6ff;
    color: #f0f6fc;
}

.prod-btn .unit-name {
    font-weight: 600;
    font-size: 13px;
}

.prod-btn .unit-stats {
    color: #8b949e;
    font-size: 11px;
    margin-top: 2px;
}

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

.cargo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 13px;
    color: #c9d1d9;
    border-bottom: 1px solid #21262d;
}

.cargo-item:last-child {
    border-bottom: none;
}

.cargo-unload-btn {
    background: #1f3a5f;
    border: 1px solid #388bfd;
    color: #58a6ff;
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
}

.cargo-unload-btn:hover {
    background: #2d4f80;
}

#message-bar {
    padding: 8px 20px;
    background: #21262d;
    border-top: 1px solid #30363d;
    font-size: 13px;
    color: #8b949e;
    min-height: 34px;
}

#message-bar.important {
    color: #f0f6fc;
    background: #1f3a5f;
}

.victory-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.victory-box {
    background: #161b22;
    border: 2px solid #3fb950;
    border-radius: 12px;
    padding: 40px 60px;
    text-align: center;
}

.victory-box h2 {
    font-size: 28px;
    margin-bottom: 12px;
}

.victory-box button {
    margin-top: 20px;
    padding: 10px 30px;
    font-size: 16px;
    background: #3fb950;
    color: #fff;
}

/* ---- Player config section in lobby ---- */
.create-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.config-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    text-align: left;
}

.config-row label {
    font-size: 14px;
    color: #c9d1d9;
    white-space: nowrap;
}

.config-row select {
    flex: 1;
    padding: 8px 10px;
    background: #21262d;
    color: #f0f6fc;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.config-row select:focus {
    outline: none;
    border-color: #58a6ff;
}

/* ---- Auto end-turn suggestion ---- */
.end-turn-suggestion {
    position: fixed;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: #21262d;
    border: 1px solid #58a6ff;
    border-radius: 10px;
    padding: 14px 22px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: suggestion-in 0.15s ease-out;
}

@keyframes suggestion-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.end-turn-suggestion p {
    color: #c9d1d9;
    font-size: 14px;
    margin: 0;
}

.end-turn-suggestion-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.end-turn-suggestion-btns button {
    padding: 7px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
}

#ets-yes { background: #f85149; color: #fff; }
#ets-yes:hover { background: #ff6b63; }
#ets-no  { background: #30363d; color: #c9d1d9; }
#ets-no:hover  { background: #484f58; }

/* Node assignment dialog */
.assign-node-dialog {
    position: fixed;
    bottom: 52px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    background: #21262d;
    border: 1px solid #3fb950;
    border-radius: 10px;
    padding: 14px 22px;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: suggestion-in 0.15s ease-out;
}

.assign-node-dialog p {
    color: #c9d1d9;
    font-size: 14px;
    margin: 0;
}

.assign-node-btns {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.assign-node-btns button {
    padding: 7px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.15s;
}

#and-yes { background: #3fb950; color: #fff; }
#and-yes:hover { background: #56d469; }
#and-no  { background: #30363d; color: #c9d1d9; }
#and-no:hover  { background: #484f58; }

/* Disabled End Turn button */
#end-turn-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ---- Save button ---- */
#save-btn {
    background: #1a3a5c;
    color: #58a6ff;
    border: 1px solid #388bfd;
}

#save-btn:hover {
    background: #2d4f80;
}

/* ---- AUTH SCREEN ---- */
#auth-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

#auth-box {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    min-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}

#auth-box h1 {
    font-size: 36px;
    color: #f0f6fc;
    margin-bottom: 4px;
}

#auth-tabs {
    display: flex;
    gap: 0;
    margin: 24px 0 20px;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: #0d1117;
    color: #8b949e;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
    background: #21262d;
    color: #f0f6fc;
}

.auth-tab:hover:not(.active) {
    background: #161b22;
    color: #c9d1d9;
}

#auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#auth-form input {
    padding: 11px 14px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    color: #f0f6fc;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

#auth-form input:focus {
    border-color: #58a6ff;
}

/* ---- LOBBY HEADER (username + logout) ---- */
#lobby-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 4px;
}

#lobby-header h1 {
    font-size: 36px;
    color: #f0f6fc;
}

#lobby-user-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #8b949e;
}

#lobby-user-bar .lobby-btn.small {
    margin-top: 0;
    padding: 5px 12px;
    font-size: 12px;
}

/* ---- SAVED GAMES ---- */
#saved-games-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.saved-game-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 10px 12px;
    gap: 10px;
}

.saved-game-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    text-align: left;
    min-width: 0;
}

.saved-game-name {
    font-size: 14px;
    font-weight: 600;
    color: #f0f6fc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-game-meta {
    font-size: 12px;
    color: #8b949e;
}

.saved-game-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.saved-game-actions .lobby-btn.small {
    margin-top: 0;
    padding: 6px 14px;
}

.lobby-btn.small.resume-btn {
    background: #1f4f2e;
    color: #3fb950;
    border: 1px solid #3fb950;
}

.lobby-btn.small.resume-btn:hover {
    background: #2a6b3e;
}

.lobby-btn.small.danger {
    background: #3d1f1f;
    color: #f85149;
    border: 1px solid #f85149;
}

.lobby-btn.small.danger:hover {
    background: #5a2020;
}

/* ---- GLOBAL WAR ---- */
.gw-btn {
    background: linear-gradient(135deg, #6e40c9, #388bfd);
    color: #fff;
    font-size: 16px;
}

.gw-btn:hover {
    background: linear-gradient(135deg, #8957e5, #58a6ff);
}

#gw-info {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 13px;
    font-weight: 700;
    margin-left: auto;
}

#ap-display {
    color: #bc8cff;
}

#round-display {
    color: #8b949e;
}

#round-timer {
    color: #e3b341;
    font-family: monospace;
    font-size: 14px;
    min-width: 45px;
    text-align: right;
}

#round-timer.pulse {
    animation: roundPulse 0.6s ease-out;
}

@keyframes roundPulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
    100% { opacity: 1; transform: scale(1); }
}

#ap-display {
    letter-spacing: 2px;
    min-width: 80px;
}

.lobby-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}
