:root {
    --sg-primary: #333333;
    --sg-primary-light: #555555;
    --sg-accent: #e8553d;
    --sg-dark: #0d0d0d;
    --sg-darker: #050505;
    --sg-card: #151515;
    --sg-card-border: #2a2a2a;
    --sg-text: #e0e0e0;
    --sg-muted: #888888;
}

body {
    background-color: var(--sg-dark);
    background-image: url('../img/background.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--sg-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 5, 0.45);
    pointer-events: none;
    z-index: 0;
}

body > * {
    position: relative;
    z-index: 1;
}

/* Navbar / Resource Bar */
.resource-bar {
    background: linear-gradient(180deg, var(--sg-darker), var(--sg-dark));
    border-bottom: 1px solid var(--sg-accent);
    padding: 0.5rem 1rem;
}

.brand-title {
    color: var(--sg-accent) !important;
    font-weight: 700;
    font-size: 1.2rem;
}

.resource-display {
    flex-wrap: wrap;
}

.resource-item {
    background: rgba(50, 50, 50, 0.3);
    border: 1px solid var(--sg-card-border);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.85rem;
    white-space: nowrap;
}

.resource-item i {
    margin-right: 4px;
}

/* Sidebar */
.sidebar {
    background: rgba(5, 5, 5, 0.85);
    min-height: calc(100vh - 56px);
    padding-top: 1.5rem;
    border-right: 1px solid var(--sg-card-border);
}

.sidebar-right {
    background: rgba(5, 5, 5, 0.85);
    min-height: calc(100vh - 56px);
    padding-top: 1.5rem;
    border-left: 1px solid var(--sg-card-border);
}

.sidebar-section {
    margin-bottom: 1rem;
}

.sidebar-right .sidebar-section-title {
    font-size: 1.15rem;
    padding: 0.5rem 1rem 0.25rem;
}

.sidebar-right .planet-link {
    color: var(--sg-text);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
    font-size: 1.1rem;
}

.sidebar-right .planet-link:hover {
    background: rgba(50, 50, 50, 0.3);
}

.sidebar-right .planet-link.active {
    background: rgba(232, 85, 61, 0.15);
    color: var(--sg-accent);
}

.sidebar-right .planet-name {
    font-size: 1.1rem;
}

.sidebar-right .planet-coords {
    font-size: 1.1rem !important;
}

.sidebar .nav-link {
    color: var(--sg-muted);
    padding: 0.75rem 1.25rem;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.sidebar .nav-link:hover {
    color: var(--sg-text);
    background: rgba(50, 50, 50, 0.2);
}

.sidebar .nav-link.active {
    color: var(--sg-accent);
    border-left-color: var(--sg-accent);
    background: rgba(232, 85, 61, 0.1);
}

.sidebar .nav-link.disabled {
    color: #3a3a3a;
}

.sidebar .nav-link i {
    margin-right: 8px;
    width: 20px;
    text-align: center;
}

/* Main Content */
.main-content {
    padding: 1.5rem 2rem;
}

.page-title {
    color: var(--sg-accent);
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--sg-card-border);
}

/* Cards */
.game-card {
    background: var(--sg-card);
    border: 1px solid var(--sg-card-border);
    border-radius: 8px;
}

.game-card .card-header {
    background: rgba(50, 50, 50, 0.3);
    border-bottom: 1px solid var(--sg-card-border);
    color: var(--sg-accent);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Override card-header for sg-building cards */
.sg-building.game-card .card-header {
    background: linear-gradient(90deg, rgba(50, 50, 50, 0.3), rgba(50, 50, 50, 0.1));
    border-bottom: 1px solid rgba(232, 85, 61, 0.15);
}

/* Building Cards — legacy selectors kept for compat, main styles in sg-building */
.building-mini-card {
    background: rgba(50, 50, 50, 0.15);
    border: 1px solid var(--sg-card-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

/* Upgrade Costs */
.upgrade-costs {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 8px 12px;
}

.cost-item {
    display: inline-block;
    margin-right: 12px;
    font-size: 0.85rem;
}

/* Resource Rates */
.resource-rate {
    padding: 0.5rem;
}

.resource-rate i {
    font-size: 1.5rem;
}

.rate-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--sg-text);
}

.rate-label {
    font-size: 0.75rem;
    color: var(--sg-muted);
}

/* Active Build */
.active-build h5 {
    color: var(--sg-accent);
    margin-bottom: 0.25rem;
}

.countdown-text {
    font-size: 0.9rem;
    color: var(--sg-primary-light);
}

/* Auth Cards */
.auth-card {
    background: var(--sg-card);
    border: 1px solid var(--sg-card-border);
    border-radius: 12px;
    margin-top: 2rem;
}

.auth-card .form-control {
    background: var(--sg-darker);
    border-color: var(--sg-card-border);
    color: var(--sg-text);
}

.auth-card .form-control:focus {
    border-color: var(--sg-accent);
    box-shadow: 0 0 0 0.2rem rgba(232, 85, 61, 0.15);
}

.text-accent {
    color: var(--sg-accent);
}

/* Buttons */
.btn-primary {
    background-color: var(--sg-primary);
    border-color: var(--sg-primary-light);
}

.btn-primary:hover {
    background-color: var(--sg-primary-light);
    border-color: var(--sg-primary-light);
}

/* Chat */
.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 0.75rem;
}

.chat-msg {
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.chat-author {
    font-weight: 600;
    color: var(--sg-accent);
    font-size: 0.8rem;
    margin-right: 0.5rem;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--sg-muted);
}

.chat-text {
    font-size: 0.85rem;
    word-break: break-word;
}

.chat-input {
    border-top: 1px solid var(--sg-card-border);
    padding: 0.5rem;
}

.chat-input .form-control {
    background: var(--sg-darker);
    border-color: var(--sg-card-border);
    color: var(--sg-text);
}

/* Trade tabs */
.nav-tabs {
    border-bottom-color: var(--sg-card-border);
}

.nav-tabs .nav-link {
    color: var(--sg-muted);
    border-color: transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--sg-text);
    border-color: var(--sg-card-border);
}

.nav-tabs .nav-link.active {
    color: var(--sg-accent);
    background: var(--sg-card);
    border-color: var(--sg-card-border);
    border-bottom-color: var(--sg-card);
}

/* Tables */
.table-dark {
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--sg-card-border);
}

.table-dark thead {
    background: rgba(50, 50, 50, 0.2);
}

/* Textarea */
textarea.form-control {
    background: var(--sg-darker);
    border-color: var(--sg-card-border);
    color: var(--sg-text);
}

textarea.form-control:focus {
    border-color: var(--sg-accent);
    box-shadow: 0 0 0 0.2rem rgba(232, 85, 61, 0.15);
}

/* Progress Bar */
.progress {
    background: rgba(0, 0, 0, 0.3);
    height: 8px;
}

/* Alerts */
.alert-info {
    background: rgba(50, 50, 50, 0.3);
    border-color: var(--sg-primary-light);
    color: var(--sg-text);
}

/* Hero Cards */
.hero-card {
    transition: transform 0.2s, box-shadow 0.2s;
}

.hero-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(50, 50, 50, 0.3);
}

.hero-assigned {
    border-color: var(--sg-accent);
    box-shadow: 0 0 10px rgba(232, 85, 61, 0.2);
}

.hero-locked {
    opacity: 0.7;
}

.hero-portrait {
    width: 80px;
    height: 80px;
    margin: 0 auto 0.5rem;
    background: rgba(50, 50, 50, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--sg-card-border);
}

.hero-assigned .hero-portrait {
    border-color: var(--sg-accent);
}

/* Form selects */
.form-select {
    background-color: var(--sg-darker);
    border-color: var(--sg-card-border);
    color: var(--sg-text);
}

.form-select:focus {
    border-color: var(--sg-accent);
    box-shadow: 0 0 0 0.2rem rgba(232, 85, 61, 0.15);
}

/* Locked Buildings — handled by sg-building-locked */

/* Resource Colors */
.text-purple {
    color: #c792ea !important;
}
.text-titan {
    color: #4fc3f7 !important;
}
.text-cassium {
    color: #66bb6a !important;
}
.text-energy {
    color: #fdd835 !important;
}

/* Quantity Badge (for ship counts etc.) */
.sg-quantity-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(25, 135, 84, 0.25);
    border: 1px solid rgba(25, 135, 84, 0.6);
    color: #2dd47a;
    box-shadow: 0 0 8px rgba(25, 135, 84, 0.2);
}

/* Difficulty Badge */
.sg-difficulty-easy {
    background: rgba(25, 135, 84, 0.25);
    border: 1px solid rgba(25, 135, 84, 0.6);
    color: #2dd47a;
}
.sg-difficulty-medium {
    background: rgba(240, 173, 78, 0.25);
    border: 1px solid rgba(240, 173, 78, 0.6);
    color: #f0ad4e;
}
.sg-difficulty-hard {
    background: rgba(220, 53, 69, 0.25);
    border: 1px solid rgba(220, 53, 69, 0.6);
    color: #e74c5e;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.2);
}

/* Story/Daily Badge */
.sg-story-badge {
    background: rgba(232, 85, 61, 0.25);
    border: 1px solid rgba(232, 85, 61, 0.6);
    color: var(--sg-accent);
}
.sg-daily-badge {
    background: rgba(136, 136, 136, 0.2);
    border: 1px solid rgba(136, 136, 136, 0.4);
    color: var(--sg-muted);
}

/* Status Badges (active/completed/failed) */
.sg-status-active {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(25, 135, 84, 0.25);
    border: 1px solid rgba(25, 135, 84, 0.6);
    color: #2dd47a;
    box-shadow: 0 0 8px rgba(25, 135, 84, 0.2);
}
.sg-status-completed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(25, 135, 84, 0.25);
    border: 1px solid rgba(25, 135, 84, 0.6);
    color: #2dd47a;
}
.sg-status-failed {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: rgba(220, 53, 69, 0.25);
    border: 1px solid rgba(220, 53, 69, 0.6);
    color: #e74c5e;
}

/* Level Badge — Hero variant */
.sg-level-hero {
    background: rgba(13, 202, 240, 0.25);
    border: 1px solid rgba(13, 202, 240, 0.6);
    color: #0dcaf0;
    box-shadow: 0 0 8px rgba(13, 202, 240, 0.2);
}

/* Reward item */
.sg-reward-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--sg-card-border);
    border-radius: 4px;
    font-size: 0.85rem;
}
.sg-reward-positive {
    border-color: rgba(25, 135, 84, 0.3);
    color: #2dd47a;
}
.sg-reward-xp {
    border-color: rgba(240, 173, 78, 0.3);
    color: #f0ad4e;
}

/* Hero bonus badge */
.sg-bonus-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 0.75rem;
    background: rgba(70, 70, 70, 0.2);
    border: 1px solid rgba(70, 70, 70, 0.4);
    color: var(--sg-primary-light);
}

/* Hero special ability badge */
.sg-special-badge {
    background: rgba(232, 85, 61, 0.2);
    border: 1px solid rgba(232, 85, 61, 0.5);
    color: var(--sg-accent);
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Resource bar capacity */
.res-cap {
    font-size: 0.7rem;
    margin-left: 2px;
}

/* Resource warnings */
.resource-warning {
    border-color: #f0ad4e !important;
    background: rgba(240, 173, 78, 0.15) !important;
}

.resource-danger {
    border-color: #dc3545 !important;
    background: rgba(220, 53, 69, 0.15) !important;
}

.resource-ok {
    border-color: #198754 !important;
}

/* Resource rows on dashboard */
.resource-row .progress {
    height: 8px;
    border-radius: 4px;
}

/* ========================================
   SCI-FI BUILDING STYLES
   ======================================== */

/* Page Header */
.sg-page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.sg-page-header .page-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
    white-space: nowrap;
}

.sg-header-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--sg-accent), transparent);
    opacity: 0.4;
}

.sg-header-line:last-child {
    background: linear-gradient(90deg, transparent, var(--sg-accent));
}

/* Category Headers */
.sg-category-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sg-cat-title {
    color: var(--sg-accent);
    font-size: 1.1rem;
    margin: 0;
    white-space: nowrap;
    letter-spacing: 0.5px;
    text-shadow: 0 0 10px rgba(232, 85, 61, 0.3);
}

.sg-cat-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--sg-card-border), transparent);
}

.sg-cat-line:last-child {
    background: linear-gradient(90deg, transparent, var(--sg-card-border));
}

/* Energy Panel */
.sg-energy-panel {
    border: 1px solid rgba(232, 85, 61, 0.3) !important;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(232, 85, 61, 0.1), inset 0 0 20px rgba(232, 85, 61, 0.03);
}

.sg-energy-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--sg-accent), transparent);
    animation: sg-sweep 3s ease-in-out infinite;
}

.sg-energy-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.sg-energy-ok {
    background: rgba(25, 135, 84, 0.25);
    border: 1px solid rgba(25, 135, 84, 0.6);
    color: #198754;
    box-shadow: 0 0 20px rgba(25, 135, 84, 0.3), inset 0 0 8px rgba(25, 135, 84, 0.15);
    animation: sg-energy-glow-green 2.5s ease-in-out infinite;
}

.sg-energy-low {
    background: rgba(220, 53, 69, 0.25);
    border: 1px solid rgba(220, 53, 69, 0.6);
    color: #dc3545;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.3), inset 0 0 8px rgba(220, 53, 69, 0.15);
    animation: sg-pulse-danger 1.5s ease-in-out infinite;
}

.sg-energy-bar {
    height: 4px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.sg-energy-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.sg-energy-bar-danger {
    background: linear-gradient(90deg, #dc3545, #f0ad4e);
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
}

/* Status Badges */
.sg-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.sg-status-ok {
    background: rgba(25, 135, 84, 0.2);
    border: 1px solid rgba(25, 135, 84, 0.5);
    color: #2dd47a;
    box-shadow: 0 0 10px rgba(25, 135, 84, 0.2);
}

.sg-status-danger {
    background: rgba(220, 53, 69, 0.2);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #e74c5e;
    box-shadow: 0 0 10px rgba(220, 53, 69, 0.2);
    animation: sg-pulse-danger 1.5s ease-in-out infinite;
}

/* Active Build Banner */
.sg-active-build-banner {
    background: rgba(21, 21, 21, 0.92);
    border: 1px solid rgba(232, 85, 61, 0.35);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(232, 85, 61, 0.1), inset 0 0 20px rgba(232, 85, 61, 0.03);
}

.sg-active-build-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--sg-accent), transparent);
    animation: sg-scan 3s ease-in-out infinite;
}

.sg-active-build-pulse {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 50%, rgba(232, 85, 61, 0.05), transparent 60%);
    animation: sg-breathe 3s ease-in-out infinite;
    pointer-events: none;
}

.sg-hammer-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(232, 85, 61, 0.2);
    border: 1px solid rgba(232, 85, 61, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--sg-accent);
    flex-shrink: 0;
}

.sg-countdown {
    color: var(--sg-text);
    text-shadow: 0 0 8px rgba(232, 85, 61, 0.3);
}

/* Building Cards - Sci-Fi */
.sg-building {
    position: relative;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    overflow: hidden;
    border: 1px solid var(--sg-card-border);
}

.sg-building:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(50, 50, 50, 0.4), 0 0 15px rgba(232, 85, 61, 0.1);
    border-color: rgba(232, 85, 61, 0.3);
}

.sg-card-glow {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 0.4s;
    box-shadow: inset 0 0 30px rgba(232, 85, 61, 0.08);
}

.sg-building:hover .sg-card-glow {
    opacity: 1;
}

.sg-building > .card-header,
.sg-building > .card-body {
    position: relative;
    z-index: 1;
}

.sg-card-head {
    border-bottom: 1px solid rgba(232, 85, 61, 0.15) !important;
    background: linear-gradient(90deg, rgba(50, 50, 50, 0.3), rgba(50, 50, 50, 0.1)) !important;
}

/* Active Building State */
.sg-building-active {
    border-color: rgba(70, 70, 70, 0.6) !important;
    box-shadow: 0 0 20px rgba(70, 70, 70, 0.3), inset 0 0 15px rgba(70, 70, 70, 0.08) !important;
}

.sg-building-active::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 8px;
    border: 2px solid rgba(70, 70, 70, 0.5);
    animation: sg-border-pulse 2s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

/* Locked Building State */
.sg-building-locked {
    opacity: 0.55;
    filter: saturate(0.5);
}

.sg-building-locked:hover {
    transform: none;
    box-shadow: none;
}

/* Max Level State */
.sg-building-max {
    border-color: rgba(232, 85, 61, 0.4) !important;
    box-shadow: 0 0 15px rgba(232, 85, 61, 0.2), inset 0 0 10px rgba(232, 85, 61, 0.05);
}

/* Level Badge */
.sg-level-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: inherit;
}

.sg-level-active {
    background: rgba(70, 70, 70, 0.35);
    border: 1px solid rgba(70, 70, 70, 0.7);
    box-shadow: 0 0 8px rgba(70, 70, 70, 0.3);
}

.sg-level-none {
    background: rgba(136, 136, 136, 0.2);
    border: 1px solid rgba(136, 136, 136, 0.4);
    color: var(--sg-muted);
}

.sg-level-max {
    background: rgba(232, 85, 61, 0.25);
    border: 1px solid rgba(232, 85, 61, 0.6);
    color: var(--sg-accent);
    box-shadow: 0 0 10px rgba(232, 85, 61, 0.3);
    text-shadow: 0 0 6px rgba(232, 85, 61, 0.4);
}

/* Building Image Column */
.sg-building-image-col {
    width: 50%;
    min-width: 180px;
    max-width: 250px;
    aspect-ratio: 1;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.15));
    position: relative;
}

.sg-image-frame {
    width: 85%;
    height: 85%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sg-building-img {
    border-radius: 4px;
    transition: filter 0.3s ease;
}

.sg-scanline-overlay {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.15) 3px,
        rgba(0, 0, 0, 0.15) 4px
    );
    pointer-events: none;
    border-radius: 4px;
    animation: sg-scanline-move 8s linear infinite;
}

@keyframes sg-scanline-move {
    0% { background-position: 0 0; }
    100% { background-position: 0 100px; }
}

.sg-building:hover .sg-scanline-overlay {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.06) 3px,
        rgba(0, 0, 0, 0.06) 4px
    );
}

/* Construction Overlay on Image */
.sg-building-constructing-overlay {
    position: absolute;
    inset: 0;
    background: rgba(70, 70, 70, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.sg-building-constructing-overlay i {
    font-size: 2rem;
    color: var(--sg-primary-light);
    text-shadow: 0 0 15px rgba(70, 70, 70, 0.6);
}

/* Section Labels */
.sg-section-label {
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.5px;
}

.sg-level-tag {
    background: rgba(70, 70, 70, 0.3);
    border: 1px solid rgba(70, 70, 70, 0.4);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    color: var(--sg-primary-light);
}

/* Stat Items */
.sg-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    border: 1px solid transparent;
}

.sg-stat-small {
    font-size: 0.78rem;
    padding: 2px 8px;
}

.sg-stat-positive {
    background: rgba(25, 135, 84, 0.1);
    border-color: rgba(25, 135, 84, 0.25);
    color: #198754;
}

.sg-stat-negative {
    background: rgba(220, 53, 69, 0.1);
    border-color: rgba(220, 53, 69, 0.25);
    color: #dc3545;
}

.sg-stat-info {
    background: rgba(13, 202, 240, 0.1);
    border-color: rgba(13, 202, 240, 0.25);
    color: #0dcaf0;
}

/* Next Level Panel */
.sg-next-level-panel {
    background: linear-gradient(135deg, rgba(50, 50, 50, 0.15), rgba(0, 0, 0, 0.2)) !important;
    border: 1px solid rgba(50, 50, 50, 0.2);
}

/* Cost Items */
.sg-cost-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--sg-card-border);
    border-radius: 4px;
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.sg-cost-item.sg-cost-missing {
    border-color: rgba(220, 53, 69, 0.4);
    background: rgba(220, 53, 69, 0.08);
    opacity: 0.8;
}

.sg-cost-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

/* Max Level Alert */
.sg-max-alert {
    background: linear-gradient(90deg, rgba(232, 85, 61, 0.15), rgba(232, 85, 61, 0.05));
    border: 1px solid rgba(232, 85, 61, 0.3);
    border-radius: 4px;
    padding: 8px 12px;
    color: var(--sg-accent);
    text-align: center;
    font-weight: 500;
}

/* Requirement Warning */
.sg-req-warning {
    background: rgba(240, 173, 78, 0.1);
    border: 1px solid rgba(240, 173, 78, 0.25);
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.sg-req-header {
    color: #f0ad4e;
    margin-bottom: 2px;
}

/* Build Progress */
.sg-build-progress {
    background: rgba(70, 70, 70, 0.1);
    border: 1px solid rgba(70, 70, 70, 0.3);
    border-radius: 6px;
    padding: 1rem;
    text-align: center;
}

.sg-build-icon {
    font-size: 1.5rem;
    color: var(--sg-primary-light);
}

/* Build Button */
.sg-btn-build {
    background: linear-gradient(135deg, var(--sg-accent), #e8674f);
    border: 1px solid rgba(232, 85, 61, 0.7);
    color: #fff;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding: 6px 16px;
    border-radius: 4px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(232, 85, 61, 0.3);
}

.sg-btn-build:hover {
    box-shadow: 0 0 20px rgba(232, 85, 61, 0.5), 0 0 40px rgba(232, 85, 61, 0.2);
    transform: translateY(-2px);
    background: linear-gradient(135deg, #e8674f, #d44a33);
    color: #fff;
    border-color: rgba(232, 85, 61, 0.9);
}

.sg-btn-build::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
    transition: left 0.6s ease;
}

.sg-btn-build:hover::before {
    left: 100%;
}

/* Progress Bar */
.sg-progress {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(70, 70, 70, 0.2);
}

/* Animations */
@keyframes sg-sweep {
    0% { left: -40%; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}

@keyframes sg-scan {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes sg-pulse-danger {
    0%, 100% { box-shadow: 0 0 8px rgba(220, 53, 69, 0.3); }
    50% { box-shadow: 0 0 25px rgba(220, 53, 69, 0.6); }
}

@keyframes sg-energy-glow-green {
    0%, 100% { box-shadow: 0 0 15px rgba(25, 135, 84, 0.2), inset 0 0 5px rgba(25, 135, 84, 0.1); }
    50% { box-shadow: 0 0 25px rgba(25, 135, 84, 0.4), inset 0 0 10px rgba(25, 135, 84, 0.2); }
}

@keyframes sg-border-pulse {
    0%, 100% { opacity: 0.3; border-color: rgba(70, 70, 70, 0.3); }
    50% { opacity: 1; border-color: rgba(70, 70, 70, 0.8); }
}

@keyframes sg-breathe {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.sg-pulse {
    animation: sg-glow-pulse 2s ease-in-out infinite;
}

@keyframes sg-glow-pulse {
    0%, 100% { opacity: 0.6; text-shadow: none; }
    50% { opacity: 1; text-shadow: 0 0 10px currentColor; }
}

.sg-rotate {
    animation: sg-spin 3s linear infinite;
}

@keyframes sg-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--sg-card-border);
    }

    .sidebar-right {
        min-height: auto;
        border-left: none;
        border-top: 1px solid var(--sg-card-border);
    }

    .resource-display {
        font-size: 0.75rem;
    }

    .resource-item {
        padding: 2px 6px;
        font-size: 0.75rem;
    }
}

/* Messages */
.table-row-unread {
    background: rgba(50, 50, 50, 0.2);
    border-left: 3px solid var(--sg-accent);
}

/* ========== Building Detail Panel ========== */
.sg-detail-panel {
    background: var(--sg-card);
    border: 1px solid var(--sg-card-border);
    border-radius: 8px;
    min-height: 300px;
    position: relative;
    overflow: hidden;
}

.sg-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    color: var(--sg-muted, #6c757d);
}

.sg-detail-content {
    display: none;
}

.sg-detail-fade-in {
    animation: sg-detail-fade 0.25s ease-out;
}

@keyframes sg-detail-fade {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.sg-detail-image-col {
    width: 512px;
    min-width: 512px;
    background: linear-gradient(135deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    overflow: hidden;
}

.sg-detail-image-col img {
    max-width: 512px;
    max-height: 512px;
    object-fit: contain;
}

/* ========== Building Thumbnail Grid ========== */
.sg-thumb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.sg-thumb {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    border: 2px solid var(--sg-card-border);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    background: var(--sg-card);
}

.sg-thumb:hover {
    transform: translateY(-3px);
    border-color: rgba(232, 85, 61, 0.4);
    box-shadow: 0 4px 15px rgba(50, 50, 50, 0.3);
}

.sg-thumb:focus-visible {
    outline: 2px solid var(--sg-accent);
    outline-offset: 2px;
}

.sg-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.sg-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0,0,0,0.85));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.sg-thumb-name {
    font-size: 0.7rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.sg-thumb-level {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--sg-accent);
    white-space: nowrap;
}

/* Thumbnail States */
.sg-thumb-locked {
    opacity: 0.5;
    filter: saturate(0.3) brightness(0.6);
}
.sg-thumb-locked:hover {
    transform: none;
    border-color: var(--sg-card-border);
    box-shadow: none;
    cursor: not-allowed;
}

.sg-thumb-building {
    border-color: rgba(70, 70, 70, 0.7);
    animation: sg-thumb-pulse 2s ease-in-out infinite;
}
@keyframes sg-thumb-pulse {
    0%, 100% { box-shadow: 0 0 5px rgba(70, 70, 70, 0.3); }
    50% { box-shadow: 0 0 15px rgba(70, 70, 70, 0.6); }
}

.sg-thumb-max {
    border-color: rgba(232, 85, 61, 0.5);
    box-shadow: 0 0 10px rgba(232, 85, 61, 0.15);
}

.sg-thumb-selected {
    border-color: var(--sg-accent) !important;
    box-shadow: 0 0 20px rgba(232, 85, 61, 0.3) !important;
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .sg-thumb-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
    .sg-detail-panel > div > .d-flex {
        flex-direction: column;
    }
    .sg-detail-image-col {
        width: 100%;
        max-height: 512px;
        min-width: unset;
        aspect-ratio: auto;
    }
}
