/* NuvolaCity v4 — Light-Mode Stylesheet */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
    background: #f4f6fa;
    color: #1a2438;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: #2a7adc; text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #e8edf5; padding: 1px 5px; border-radius: 3px; font-size: 0.9em; color: #1a3a6a; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border: 1px solid #d0d8e4;
    background: #ffffff;
    color: #1a2438;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 1px 2px rgba(20,40,80,0.04);
}
.btn:hover { background: #f4f8ff; border-color: #2a7adc; color: #2a7adc; box-shadow: 0 2px 6px rgba(42,122,220,0.15); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(180deg, #4fa8ee, #2a7adc);
    border-color: #2a7adc;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(42,122,220,0.3);
}
.btn-primary:hover { background: linear-gradient(180deg, #5cb6f8, #3284e4); color: #fff; }
.btn-secondary { background: #e8f1fc; border-color: #b8d4f0; color: #1a5db8; }
.btn-danger { background: #ffe8e8; border-color: #f5b8b8; color: #c83838; }
.btn-danger:hover { background: #ffd0d0; border-color: #c83838; color: #c83838; }
.btn-sm { padding: 4px 12px; font-size: 12px; border-radius: 6px; }
.btn-block { display: block; width: 100%; margin-bottom: 6px; }

/* Auth */
.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse at 20% 0%, #d0e4fa 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, #ffe0d0 0%, transparent 50%),
        linear-gradient(135deg, #f0f6ff 0%, #fff8f0 100%);
    padding: 16px;
}
.auth-card {
    background: rgba(255,255,255,0.95);
    border: 1px solid #d8e2f0;
    border-radius: 18px; padding: 36px;
    width: 100%; max-width: 400px;
    box-shadow: 0 20px 60px rgba(20,40,80,0.12), 0 4px 12px rgba(20,40,80,0.06);
    backdrop-filter: blur(10px);
}
.auth-title { margin: 0 0 4px; font-size: 28px; color: #2a7adc; font-weight: 700; letter-spacing: -0.5px; }
.auth-sub { color: #6a7890; margin: 0 0 28px; font-size: 14px; }
.auth-error { background: #ffe8e8; border: 1px solid #f5b8b8; color: #c83838; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #4a5870; font-weight: 500; }
.auth-form input { padding: 11px 14px; background: #f4f8ff; border: 1px solid #d8e2f0; color: #1a2438; font-size: 14px; border-radius: 8px; transition: all 0.15s; }
.auth-form input:focus { outline: none; border-color: #2a7adc; background: #fff; box-shadow: 0 0 0 3px rgba(42,122,220,0.1); }
.auth-form button { margin-top: 10px; padding: 11px; }
.auth-register { margin-top: 24px; padding-top: 20px; border-top: 1px solid #e8edf5; }
.auth-register summary { color: #6a7890; cursor: pointer; font-size: 13px; user-select: none; font-weight: 500; }
.auth-register summary:hover { color: #2a7adc; }
.auth-register .auth-form { margin-top: 14px; }
.auth-hint { color: #8a98b0; font-size: 12px; margin: 18px 0 0; line-height: 1.6; }

/* Topbar */
.app-topbar {
    height: 56px;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid #e0e6ee;
    display: flex; align-items: center; gap: 18px;
    padding: 0 20px; position: sticky; top: 0; z-index: 50;
    box-shadow: 0 1px 3px rgba(20,40,80,0.04);
}
.app-topbar .logo { font-size: 18px; font-weight: 700; color: #2a7adc; flex-shrink: 0; letter-spacing: -0.3px; }
.app-topbar .nav { display: flex; gap: 4px; flex: 1; align-items: center; }
.app-topbar .nav a { padding: 7px 14px; border-radius: 8px; font-size: 14px; color: #4a5870; transition: all 0.12s; font-weight: 500; }
.app-topbar .nav a:hover { background: #f0f4fa; color: #1a2438; text-decoration: none; }
.app-topbar .nav a.active { background: #e8f1fc; color: #2a7adc; }
.app-topbar .city-title-bar { color: #4a5870; font-size: 14px; padding-left: 14px; border-left: 1px solid #e0e6ee; margin-left: 8px; font-weight: 500; }
.app-topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.app-topbar .user-name { color: #1a2438; font-weight: 500; }
.app-topbar .user .role-badge { padding: 3px 9px; border-radius: 12px; font-size: 10px; font-weight: 700; background: #e8f1fc; color: #2a7adc; text-transform: uppercase; letter-spacing: 0.4px; }
.app-topbar .user .role-badge.admin { background: #fce8f0; color: #d04080; }

/* Container */
.container { max-width: 1200px; margin: 0 auto; padding: 28px 20px; }
.container-wide { max-width: 1600px; margin: 0 auto; padding: 28px 20px; }

.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-row label { font-size: 13px; color: #4a5870; font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
    padding: 10px 14px;
    background: #f4f8ff;
    border: 1px solid #d8e2f0;
    color: #1a2438; font-size: 14px; border-radius: 8px;
    font-family: inherit; transition: all 0.15s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none; border-color: #2a7adc; background: #fff; box-shadow: 0 0 0 3px rgba(42,122,220,0.1);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.notice { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13px; background: #e8f1fc; border: 1px solid #b8d4f0; color: #1a5db8; }
.notice.warn { background: #fff4e0; border-color: #f5d088; color: #b06820; }
.notice.error { background: #ffe8e8; border-color: #f5b8b8; color: #c83838; }
.notice.success { background: #e8f8e8; border-color: #b8e0b8; color: #3a8a3a; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 12px; font-size: 10px; font-weight: 700; letter-spacing: 0.4px; background: #e8edf5; color: #4a5870; text-transform: uppercase; }
.badge-private { background: #fce8f0; color: #d04080; }

/* === Hub === */
.hub-tabs {
    display: flex; gap: 4px; margin-bottom: 28px;
    border-bottom: 1px solid #e0e6ee;
    padding-bottom: 0;
    overflow-x: auto;
}
.hub-tab {
    padding: 12px 20px;
    background: transparent;
    border: 1px solid transparent;
    border-bottom: none;
    color: #6a7890;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    -webkit-tap-highlight-color: transparent;
    white-space: nowrap;
    transition: all 0.15s;
}
.hub-tab:hover { color: #1a2438; background: #f0f4fa; }
.hub-tab.active {
    color: #2a7adc;
    background: #fff;
    border-color: #d8e2f0;
    border-bottom: 1px solid #fff;
    margin-bottom: -1px;
    box-shadow: 0 -2px 6px rgba(20,40,80,0.04);
}

.hub-section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 12px; flex-wrap: wrap; }
.hub-section-head h2 { margin: 0; font-size: 22px; color: #1a2438; font-weight: 700; letter-spacing: -0.3px; }

.city-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }

.city-card {
    background: #fff;
    border: 1px solid #e0e6ee;
    border-radius: 14px;
    padding: 20px;
    transition: all 0.18s;
    box-shadow: 0 1px 3px rgba(20,40,80,0.04);
}
.city-card:hover { border-color: #2a7adc; transform: translateY(-2px); box-shadow: 0 8px 20px rgba(20,40,80,0.08); }
.city-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.city-card-head h3 { margin: 0; font-size: 17px; color: #1a2438; font-weight: 600; }
.city-stats { font-size: 13px; color: #4a5870; display: flex; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.city-meta { font-size: 12px; color: #8a98b0; margin-bottom: 14px; }
.city-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty-state { text-align: center; padding: 70px 20px; color: #6a7890; grid-column: 1 / -1; background: #fff; border-radius: 14px; border: 1px dashed #d8e2f0; }
.empty-icon { font-size: 56px; margin-bottom: 14px; opacity: 0.7; }
.loading { padding: 50px; text-align: center; color: #8a98b0; grid-column: 1 / -1; }

/* === Modals === */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20,40,80,0.4);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
}
.modal-backdrop.show { display: block; }
.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border: 1px solid #e0e6ee;
    border-radius: 16px;
    padding: 28px;
    width: 92%; max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 210;
    display: none;
    box-shadow: 0 24px 60px rgba(20,40,80,0.2), 0 4px 12px rgba(20,40,80,0.08);
}
.modal.show { display: block; }
.modal h3 { margin: 0 0 8px; color: #1a2438; font-weight: 700; font-size: 20px; }
.modal .modal-sub { color: #6a7890; font-size: 13px; margin: 0 0 18px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.hint { color: #6a7890; font-size: 12px; margin: 4px 0 14px; }

/* === Toast === */
.toast {
    position: fixed;
    top: 70px; right: 20px;
    padding: 12px 20px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #2a7adc;
    color: #1a2438;
    z-index: 300;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 8px 24px rgba(20,40,80,0.12);
    transition: opacity 0.4s;
}
.toast.warn { border-color: #d08020; color: #b06820; background: #fff8e8; }
.toast.success { border-color: #3a8a3a; color: #2a7a2a; background: #effaef; }

/* === Game Layout === */
.game-layout { display: grid; grid-template-columns: 240px 1fr; height: calc(100vh - 56px); }
.game-sidebar {
    background: #fff;
    border-right: 1px solid #e0e6ee;
    overflow-y: auto;
    padding: 12px;
    transition: transform 0.25s;
    box-shadow: 1px 0 3px rgba(20,40,80,0.03);
}
.sidebar-h { margin: 6px 0 10px; font-size: 11px; color: #8a98b0; letter-spacing: 0.6px; font-weight: 700; text-transform: uppercase; }
.sidebar-hr { border: none; border-top: 1px solid #e8edf5; margin: 12px 0; }
.game-canvas-wrap { position: relative; overflow: hidden; touch-action: none; background: #a8d8ee; }
.game-canvas-wrap canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.game-hud {
    position: absolute; top: 12px; left: 12px; right: 12px;
    display: flex; gap: 8px; pointer-events: none; flex-wrap: wrap;
}
.game-hud .stat {
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(10px);
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #1a2438;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(20,40,80,0.1);
    border: 1px solid rgba(255,255,255,0.6);
}
.game-hud .stat .label {
    color: #8a98b0;
    font-size: 10px;
    font-weight: 500;
    margin-right: 8px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.sidebar-cat-btn {
    display: block; width: 100%; padding: 8px 12px;
    background: #f4f8ff;
    border: 1px solid transparent;
    color: #4a5870; font-size: 12px; text-align: left; cursor: pointer;
    border-radius: 8px; margin-bottom: 4px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.12s;
    font-weight: 500;
}
.sidebar-cat-btn.active { background: #e8f1fc; color: #2a7adc; border-color: #b8d4f0; font-weight: 600; }
.sidebar-cat-btn:hover { background: #e8edf5; }

.sidebar-item {
    display: flex; gap: 10px; align-items: center;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
    border: 1px solid transparent; font-size: 12px; color: #4a5870;
    -webkit-tap-highlight-color: transparent; transition: all 0.12s;
    margin-bottom: 3px;
}
.sidebar-item:hover { background: #f0f4fa; color: #1a2438; }
.sidebar-item.active { background: #e8f1fc; color: #2a7adc; border-color: #b8d4f0; }
.sidebar-item .icon { font-size: 18px; }
.sidebar-item .name { flex: 1; font-weight: 500; }
.sidebar-item .name .fp {
    display: inline-block; margin-left: 6px; padding: 1px 5px;
    background: #fff4e0; color: #b06820; border-radius: 4px;
    font-size: 9px; font-weight: 700; letter-spacing: 0.3px;
}
.sidebar-item .name .lvl-badge {
    display: inline-block; margin-left: 4px; padding: 1px 5px;
    background: #e8f8e8; color: #2a7a2a; border-radius: 4px;
    font-size: 9px; font-weight: 700;
}
.sidebar-item .cost { color: #d08020; font-size: 11px; font-weight: 600; }
.bld-empty { padding: 12px; color: #8a98b0; font-size: 12px; text-align: center; }

.save-indicator {
    margin-top: 12px; padding: 7px 10px;
    font-size: 11px; color: #8a98b0; text-align: center;
    background: #f4f8ff; border-radius: 6px;
    border: 1px solid #e0e6ee;
}
.world-info {
    margin-top: 10px; padding: 10px;
    font-size: 11px; color: #1a5db8;
    background: #e8f1fc;
    border: 1px solid #b8d4f0;
    border-radius: 8px; line-height: 1.5;
}

.mobile-toggle {
    display: none; position: absolute; top: 64px; left: 12px;
    width: 42px; height: 42px;
    background: rgba(255,255,255,0.95); backdrop-filter: blur(10px);
    border: 1px solid #d8e2f0; color: #2a7adc;
    border-radius: 10px; font-size: 20px; cursor: pointer; z-index: 90;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 8px rgba(20,40,80,0.1);
}
.controls-help {
    position: absolute; bottom: 12px; left: 12px; right: 12px;
    background: rgba(255,255,255,0.85); backdrop-filter: blur(10px);
    color: #4a5870; padding: 8px 14px; border-radius: 8px;
    font-size: 11px; pointer-events: none; text-align: center;
    border: 1px solid rgba(255,255,255,0.6);
    box-shadow: 0 2px 6px rgba(20,40,80,0.06);
}
.controls-help strong { color: #1a2438; }

/* Mobile */
@media (max-width: 720px) {
    .app-topbar { gap: 10px; padding: 0 12px; height: 50px; }
    .app-topbar .logo { font-size: 15px; }
    .app-topbar .nav { gap: 0; }
    .app-topbar .nav a { padding: 6px 10px; font-size: 13px; }
    .app-topbar .city-title-bar { display: none; }
    .app-topbar .user-name { display: none; }
    .app-topbar .user .role-badge { display: none; }

    .game-layout { grid-template-columns: 1fr; height: calc(100vh - 50px); }
    .game-sidebar {
        position: absolute; top: 0; left: 0; height: 100%; width: 260px; z-index: 100;
        transform: translateX(-100%);
        box-shadow: 4px 0 24px rgba(20,40,80,0.15);
    }
    .game-sidebar.mobile-open { transform: translateX(0); }
    .mobile-toggle { display: block; }

    .game-hud .stat { font-size: 12px; padding: 6px 10px; }
    .controls-help { font-size: 10px; padding: 6px 10px; }

    .container, .container-wide { padding: 14px 12px; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .city-grid { grid-template-columns: 1fr; }
}
