:root {
    --bg: #05070d;
    --panel: #10141f;
    --border: #232a3d;
    --text: #eef2ff;
    --text-dim: #8994b3;
    --accent: #5fd0ff;
    --accent-2: #ffb454;
    --danger: #ff6b6b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, Segoe UI, Roboto, sans-serif;
    background: radial-gradient(circle at top, #0e1730, var(--bg) 60%);
    color: var(--text);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* AUTH */
#auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    width: 320px;
    text-align: center;
}
.auth-box h1 { color: var(--accent); margin-top: 0; }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form input {
    background: #0b0f1a;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px;
    border-radius: 8px;
}
.auth-form button {
    background: var(--accent);
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}
.auth-switch { font-size: 13px; color: var(--text-dim); }
.auth-switch a { color: var(--accent); }
.auth-error { color: var(--danger); font-size: 13px; min-height: 16px; }

/* GAME LAYOUT */
#game-screen { display: flex; flex-direction: column; min-height: 100vh; }

#resource-bar {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.resource-pill {
    background: #0b0f1a;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 13px;
    display: flex;
    gap: 6px;
}
.resource-pill .resource-name { color: var(--text-dim); }
.resource-premium { border-color: var(--accent-2); }

.game-body { flex: 1; display: flex; gap: 16px; padding: 16px; }

.colony-viewport { flex: 1; display: flex; align-items: center; justify-content: center; }

.colony-grid {
    display: grid;
    gap: 6px;
    background: #0b0f1a;
    border: 1px solid var(--border);
    padding: 8px;
    border-radius: 12px;
}

.colony-tile {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    text-align: center;
    padding: 2px;
}
.tile-void { background: repeating-linear-gradient(45deg, #10141f, #10141f 6px, #0b0f1a 6px, #0b0f1a 12px); cursor: default; }
.tile-unbuilt {
    background: repeating-linear-gradient(45deg, #131a2b, #131a2b 6px, #0e1421 6px, #0e1421 12px);
    border: 1px dashed var(--border);
    color: var(--text-dim);
}
.tile-unbuilt:hover { border-color: var(--accent); color: var(--text); }
.tile-building {
    background: linear-gradient(160deg, #1b2740, #0f1626);
    border: 1px solid var(--border);
    color: var(--text);
}
.tile-constructing { opacity: 0.6; }
.tile-label { font-weight: 600; }
.tile-level { color: var(--accent); font-size: 9px; }
.tile-countdown { color: var(--accent-2); font-size: 9px; }

/* Add custom art per building later, e.g.:
   .building-habitat { background-image: url('/assets/img/habitat.png'); background-size: cover; }
*/

.side-panel {
    width: 240px;
    flex-shrink: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    overflow-y: auto;
}
.side-panel h2 { margin-top: 0; font-size: 15px; color: var(--accent); }

.build-card {
    background: #0b0f1a;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}
.build-card-selected { border-color: var(--accent); }
.build-desc { color: var(--text-dim); font-size: 11px; }
.build-cost { color: var(--accent-2); font-size: 12px; }

.bottom-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--panel);
    border-top: 1px solid var(--border);
}
.bottom-bar button {
    background: var(--accent);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
#admin-panel-link {
    background: var(--accent-2);
    color: #1a1200;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
}
#username-label { margin-left: auto; color: var(--text-dim); }

/* MODALS */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal-content {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: 380px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-header button { background: none; border: none; color: var(--text); font-size: 18px; cursor: pointer; }

.shop-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.shop-row button {
    background: var(--accent-2);
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}
.shop-row button:disabled { opacity: 0.4; cursor: not-allowed; }

.modal button#modal-upgrade,
.modal button#modal-instant-build {
    background: var(--accent);
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    margin-top: 8px;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #16321f;
    border: 1px solid #3fb950;
    color: var(--text);
    padding: 10px 18px;
    border-radius: 8px;
    z-index: 100;
}
.toast-error { background: #33161a; border-color: var(--danger); }

@media (max-width: 720px) {
    .game-body { flex-direction: column; }
    .side-panel { width: 100%; }
    .colony-tile { width: 48px; height: 48px; }
}
