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

body {
  background: #0d1117;
  color: #c9d1d9;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  position: sticky;
  top: 0;
  z-index: 60;
}
.navbar-brand { font-weight: bold; font-size: 16px; }
.navbar-right { display: flex; align-items: center; gap: 10px; }
.navbar-user { color: #8b949e; font-size: 13px; }
.navbar-micro-btns { display: flex; align-items: center; gap: 2px; }
.micro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 15px;
  color: inherit;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}
.micro-btn:hover { background: #21262d; border-color: #30363d; }

.btn {
  padding: 5px 12px;
  border: 1px solid #30363d;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
  background: #21262d;
  color: #c9d1d9;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: #30363d; }
.btn-primary { background: #238636; border-color: #2ea043; color: #fff; }
.btn-primary:hover { background: #2ea043; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

.messages { padding: 8px 16px; }
.message { padding: 8px 12px; border-radius: 5px; margin-bottom: 6px; font-size: 13px; background: #21262d; border: 1px solid #30363d; }
.message-error { background: #3d1a1a; border-color: #da3633; color: #ff7b72; }
.message-success { background: #0d2a0d; border-color: #238636; color: #56d364; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: #0d1117;
  border-bottom: 1px solid #21262d;
  position: sticky;
  top: 84px;
  z-index: 55;
}
.toolbar-hint { font-size: 12px; color: #e3b341; }

/* Resource bar */
.resources-bar {
  display: flex;
  gap: 8px;
  padding: 6px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-wrap: wrap;
  align-items: center;
  position: sticky;
  top: 48px;
  z-index: 50;
}
.resource-item {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  background: #21262d;
  border-radius: 4px;
  border: 1px solid #30363d;
  font-size: 12px;
}
.resource-tier-special { border-color: #a371f7; }
.resource-tier-advanced { border-color: #da3633; }
.resource-tier-component { border-color: #388bfd; }
.resource-tier-refined { border-color: #3fb950; }
.resource-tier-token { border-color: #e3b341; background: #1a1708; }
.resource-tier-liquid { border-color: #1f6feb; background: #0d1520; }
/* Power display */
.power-display {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #0d2a0d;
  border: 1px solid #2ea043;
  border-radius: 4px;
  font-size: 12px;
  color: #56d364;
}
.power-display.power-low {
  background: #2a1a00;
  border-color: #e3b341;
  color: #e3b341;
}
.power-display.power-off {
  background: #3d1a1a;
  border-color: #da3633;
  color: #ff7b72;
}
.power-icon { font-size: 13px; }
.power-value { font-variant-numeric: tabular-nums; }
.power-pct { font-size: 11px; opacity: 0.8; }
.resource-divider { color: #30363d; font-size: 14px; }
.resource-icon { font-size: 13px; display: flex; align-items: center; }
.resource-icon img.resource-sprite { width: 14px; height: 14px; image-rendering: pixelated; }
.resource-icon img.building-sprite { width: 14px; height: 14px; image-rendering: pixelated; }
.resource-value { font-variant-numeric: tabular-nums; min-width: 28px; }

/* Grid */
.grid-wrapper { padding: 16px; overflow: auto; display: flex; justify-content: center; align-items: flex-start; position: relative; }
.game-grid { display: grid; gap: 2px; width: fit-content; }
#zoom-indicator { position: absolute; bottom: 8px; right: 8px; font-size: 10px; color: #8b949e; background: #161b22cc; padding: 2px 6px; border-radius: 3px; pointer-events: none; opacity: 0; transition: opacity 0.5s; z-index: 10; }
#zoom-indicator.visible { opacity: 1; transition: opacity 0s; }
#game-grid.zoom-small .cell-level, #game-grid.zoom-small .cell-icon img, #game-grid.zoom-small .cell-icon { font-size: 0; }
#game-grid.zoom-small .cell-remove { display: none; }
.grid-cell {
  width: 40px;
  height: 40px;
  border: 1px solid #21262d;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  user-select: none;
}
.grid-cell.empty { background: #0d1117; }
.grid-cell.empty:hover { background: #1c2128; border-color: #30363d; }

/* Ore veins */
.grid-cell.vein {
  background: #1a0d08;
  border-color: #6e3a0a;
}
.grid-cell.vein:hover { border-color: #e3b341; }
.vein-icon {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: -0.5px;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.vein-icon img.vein-sprite { width: 14px; height: 14px; image-rendering: pixelated; display: block; }
.vein-iron_ore   .vein-icon { color: #e07060; }
.vein-coal       .vein-icon { color: #9e9e9e; }
.vein-copper_ore .vein-icon { color: #e07830; }
.vein-silicon    .vein-icon { color: #60a0d0; }
.vein-crystal    .vein-icon { color: #b070e0; }
.vein-titanium_ore .vein-icon { color: #80d0c0; }
.vein-water      .vein-icon { color: #40a0e0; }
.vein-oil        .vein-icon { color: #a06030; }
.grid-cell.vein.vein-iron_ore { background: #1a1210; }
.grid-cell.vein.vein-coal { background: #111111; }
.grid-cell.vein.vein-copper_ore { background: #1a1008; }
.grid-cell.vein.vein-silicon { background: #0d1520; }
.grid-cell.vein.vein-crystal { background: #150d20; }
.grid-cell.vein.vein-titanium_ore { background: #151518; }
.grid-cell.vein.vein-water { background: #0d1520; border-color: #1f6feb; }
.grid-cell.vein.vein-oil { background: #1a1008; border-color: #6e3a0a; }
.grid-cell.vein.depleted { opacity: 0.3; pointer-events: none; }

@keyframes place-pulse { 0% { box-shadow: 0 0 6px #56d364; } 100% { box-shadow: none; } }
.game-grid.foundation-mode .grid-cell.foundation { animation: place-pulse 0.6s ease-out; }

/* Foundation */
.grid-cell.foundation {
  background: #1a1208;
  border-color: #3d2f0a;
}
.grid-cell.foundation:hover { background: #261b0c; border-color: #6e4c0f; }
.grid-cell.occupied { background: #0d2137; border-color: #1f6feb; }
.grid-cell.occupied.on-foundation { background: #0a1f10; border-color: #2ea043; }
.grid-cell.occupied.on-vein { background: #1a1008; border-color: #e3b341; }
.grid-cell.occupied:hover { border-color: #388bfd; }

/* Status dot — real span, top-right of anchor cell */
.status-dot-grid {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #484f58;
  pointer-events: none;
  z-index: 2;
  flex-shrink: 0;
}
.status-dot-grid.status-active { background: #2ea043; animation: status-pulse 2s ease-in-out infinite; }
.status-dot-grid.status-no_power { background: #da3633; }
.status-dot-grid.status-idle_no_input { background: #da3633; }
.status-dot-grid.status-output_full { background: #e3b341; }
#game-grid.zoom-small .status-dot-grid { display: none; }

@keyframes status-pulse {
  0%, 100% { box-shadow: 0 0 3px #2ea043; }
  50% { box-shadow: 0 0 7px #2ea043; opacity: 0.7; }
}

.game-grid.foundation-mode .grid-cell.empty:hover { background: #261b0c; border-color: #e3b341; }
.grid-cell.drag-place { background: #2d2010 !important; border-color: #e3b341 !important; outline: 1px solid #e3b341; }
.grid-cell.drag-remove { background: #3d1a1a !important; border-color: #da3633 !important; outline: 1px solid #da3633; }
.grid-cell.drag-conveyor { background: #1a2a1a !important; border-color: #56d364 !important; outline: 1px solid #56d364; }
.grid-cell.drag-conveyor::after { content: '▶'; position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); color: #e3b341; font-size: 10px; pointer-events: none; }
.grid-cell.drag-conveyor[data-drag-dir="N"]::after { content: '▲'; }
.grid-cell.drag-conveyor[data-drag-dir="S"]::after { content: '▼'; }
.grid-cell.drag-conveyor[data-drag-dir="W"]::after { content: '◀'; }
.grid-cell.drag-conveyor[data-drag-dir="E"]::after { content: '▶'; }
.grid-cell.drag-conveyor-overwrite { background: #1e1a0a !important; border-color: #e3b341 !important; outline: 1px solid #e3b341; }
.game-grid.conveyor-mode { cursor: crosshair; }
.game-grid.conveyor-mode .grid-cell.foundation:not(.occupied):hover { background: #1a2a1a; border-color: #56d364; }
.game-grid.foundation-mode .grid-cell.foundation:hover { background: #3d1a1a; border-color: #da3633; }
.game-grid.placing .grid-cell { opacity: 0.3; }
.game-grid.placing .grid-cell.place-valid { opacity: 1; border-color: #56d364; box-shadow: 0 0 4px #56d364; }

.cell-icon { pointer-events: auto; cursor: pointer; }
.cell-icon img.building-sprite { width: 24px; height: 24px; image-rendering: pixelated; display: block; pointer-events: none; }
.rate-badge { position: absolute; bottom: 13px; left: 50%; transform: translateX(-50%); font-size: 7px; color: #56d364; background: #0d1117bb; padding: 0 2px; border-radius: 2px; white-space: nowrap; pointer-events: none; line-height: 1.3; }
#game-grid.zoom-small .rate-badge { display: none; }
.cell-level { position: absolute; bottom: 1px; right: 3px; font-size: 9px; color: #8b949e; pointer-events: none; }
.cell-direction {
  position: absolute;
  top: 50%; left: 50%;
  width: 24px; height: 24px;
  margin: -12px 0 0 -12px;
  background: url('/static/img/sprites/conveyor-belt-strip.png') 0 0 no-repeat;
  animation: conveyor-strip 0.64s steps(8) infinite;
  pointer-events: none;
  image-rendering: pixelated;
}
.cell-direction[data-dir="N"] { transform: rotate(-90deg); }
.cell-direction[data-dir="S"] { transform: rotate(90deg); }
.cell-direction[data-dir="W"] { transform: rotate(180deg); }
@keyframes conveyor-strip { to { background-position-x: -192px; } }
@keyframes belt-dot-E { 0% { transform: translate(-18px,-50%); } 100% { transform: translate(18px,-50%); } }
@keyframes belt-dot-W { 0% { transform: translate(18px,-50%); } 100% { transform: translate(-18px,-50%); } }
@keyframes belt-dot-N { 0% { transform: translate(-50%,18px); } 100% { transform: translate(-50%,-18px); } }
@keyframes belt-dot-S { 0% { transform: translate(-50%,-18px); } 100% { transform: translate(-50%,18px); } }
.belt-item { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--item-color,#8b949e); top: 50%; left: 50%; pointer-events: none; z-index: 2; animation: belt-dot-E 0.8s linear infinite; }
.belt-item-sprite { width: 8px; height: 8px; border-radius: 0; background: none; image-rendering: pixelated; }
.belt-item[data-dir="E"] { animation-name: belt-dot-E; }
.belt-item[data-dir="W"] { animation-name: belt-dot-W; }
.belt-item[data-dir="N"] { animation-name: belt-dot-N; }
.belt-item[data-dir="S"] { animation-name: belt-dot-S; }
#game-grid.zoom-small .belt-item { display: none; }
.cell-remove {
  display: none;
  position: absolute; top: -5px; right: -5px;
  width: 15px; height: 15px;
  background: #da3633; color: #fff; border: none; border-radius: 50%;
  font-size: 9px; line-height: 1; cursor: pointer;
  align-items: center; justify-content: center; z-index: 2;
}
.grid-cell.occupied:hover .cell-remove { display: flex; }

/* Overlays */
.build-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 100;
  justify-content: center; align-items: center;
}
.build-overlay.active { display: flex; }

.build-panel {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 20px;
  min-width: 380px;
  max-width: 700px;
  max-height: 80vh;
  overflow-y: auto;
}
.build-panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.build-panel-header h5 { font-size: 15px; }
.close-btn { background: none; border: 1px solid #30363d; color: #c9d1d9; padding: 3px 9px; border-radius: 4px; cursor: pointer; font-size: 15px; line-height: 1; }
.close-btn:hover { background: #21262d; }
.empty-msg { color: #8b949e; font-size: 13px; }

.building-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.building-card { background: #0d1117; border: 1px solid #30363d; border-radius: 6px; padding: 12px; display: flex; flex-direction: column; gap: 5px; transition: border-color 0.1s; }
.building-card:not(.disabled):hover { border-color: #388bfd; }
.building-card.disabled { opacity: 0.45; }
.building-icon { font-size: 28px; text-align: center; display: flex; justify-content: center; align-items: center; height: 32px; }
.building-icon img.building-sprite { width: 32px; height: 32px; image-rendering: pixelated; }
.build-panel-header h5 img.building-sprite, .buffer-item img.building-sprite, .power-group-header img.building-sprite { width: 18px; height: 18px; image-rendering: pixelated; vertical-align: middle; }
.building-name { font-weight: 600; font-size: 13px; text-align: center; }
.building-desc { font-size: 11px; color: #8b949e; line-height: 1.4; }
.building-stats { font-size: 11px; color: #3fb950; display: flex; flex-direction: column; gap: 2px; }
.building-stats .consumption { color: #ff7b72; }
.building-cost { font-size: 11px; color: #e3b341; display: flex; flex-wrap: wrap; gap: 4px; }
.cost-item-sm { font-size: 10px; color: #e3b341; }

.btn-build { width: 100%; padding: 6px; background: #238636; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 12px; margin-top: 6px; }
.btn-build:hover:not(:disabled) { background: #2ea043; }
.btn-build:disabled { background: #21262d; color: #8b949e; cursor: not-allowed; }

.direction-picker { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: #8b949e; }
.dir-label { display: flex; align-items: center; gap: 2px; cursor: pointer; }
.dir-label input { margin: 0; }

/* Building detail */
.detail-section { margin-bottom: 14px; }
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: #8b949e; margin-bottom: 5px; }
.detail-buffers { display: flex; flex-wrap: wrap; gap: 6px; }
.buffer-item { background: #21262d; border: 1px solid #30363d; border-radius: 4px; padding: 3px 8px; font-size: 12px; }
.rate-item { color: #3fb950; border-color: #2ea043; }
.detail-progress-wrap { width: 100%; height: 8px; background: #21262d; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.detail-progress-fill { height: 100%; background: #388bfd; border-radius: 4px; transition: width 0.3s; }
.detail-progress-text { font-size: 11px; color: #8b949e; }
.detail-cost { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.cost-item { background: #21262d; border: 1px solid #e3b341; border-radius: 4px; padding: 2px 7px; font-size: 12px; color: #e3b341; }
.detail-recipe-active { font-size: 13px; margin-bottom: 6px; }
.recipe-picker { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.direction-set { display: flex; gap: 6px; }
.dir-btn { min-width: 36px; padding: 4px 8px; font-size: 16px; }
.dir-btn.active { background: #1f6feb; border-color: #388bfd; color: #fff; }

/* Tech tree */
.tech-wrapper { padding: 20px; max-width: 1200px; overflow-x: auto; }
.tech-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.tech-header h2 { font-size: 18px; }
.tech-graph { display: flex; align-items: flex-start; gap: 0; }
.tech-column { display: flex; flex-direction: column; gap: 12px; min-width: 200px; }
.tech-connector { display: flex; align-items: center; width: 40px; min-height: 80px; flex-shrink: 0; }
.tech-connector svg { width: 40px; height: 80px; }
.tier-label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: #8b949e; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid #21262d; }
.tech-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 6px; transition: border-color 0.1s; }
.tech-card:not(.disabled):not(.completed):hover { border-color: #388bfd; }
.tech-card.completed { border-color: #2ea043; opacity: 0.7; }
.tech-card.disabled { opacity: 0.45; }
.tech-icon { font-size: 28px; text-align: center; }
.tech-name { font-weight: 600; font-size: 13px; text-align: center; }
.tech-desc { font-size: 11px; color: #8b949e; line-height: 1.4; }
.tech-effects { font-size: 11px; color: #3fb950; }
.tech-cost { display: flex; flex-wrap: wrap; gap: 4px; font-size: 11px; color: #e3b341; }
.completed-badge { color: #56d364; font-size: 12px; }
.research-active { padding: 12px; background: #0d2137; border: 1px solid #1f6feb; border-radius: 6px; margin-bottom: 20px; }
.rocket-complete { text-align: center; padding: 40px; }
.rocket-complete .rocket-icon { font-size: 64px; margin-bottom: 16px; }
.rocket-complete h2 { color: #56d364; margin-bottom: 8px; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 16px; text-align: center; }
.stat-value { font-size: 24px; font-weight: bold; color: #c9d1d9; }
.stat-label { font-size: 12px; color: #8b949e; margin-top: 4px; }
.stats-resource-grid { display: flex; flex-direction: column; gap: 6px; }
.stat-resource-row { display: flex; align-items: center; gap: 8px; padding: 4px 8px; background: #161b22; border-radius: 4px; }
.stat-resource-name { min-width: 100px; font-size: 12px; }
.stat-resource-amount { min-width: 50px; font-size: 12px; font-variant-numeric: tabular-nums; text-align: right; }
.stat-bar { flex: 1; height: 6px; background: #21262d; border-radius: 3px; overflow: hidden; }
.stat-bar-fill { height: 100%; background: #388bfd; border-radius: 3px; max-width: 100%; }

/* Craft queue */
.craft-queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
}
.craft-queue-item.crafting { border-color: #388bfd; }
.craft-queue-icon { font-size: 16px; }
.craft-queue-name { min-width: 80px; }
.craft-cancel-btn {
  background: none;
  border: 1px solid #da3633;
  color: #da3633;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  cursor: pointer;
  line-height: 1;
}
.craft-cancel-btn:hover { background: #da3633; color: #fff; }
.craft-qty-row { display: flex; gap: 4px; margin-top: 6px; }
.btn-craft-qty { flex: 1; padding: 4px; font-size: 11px; }

/* Login */
.login-container { max-width: 360px; margin: 80px auto; padding: 28px; background: #161b22; border: 1px solid #30363d; border-radius: 8px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-size: 13px; color: #8b949e; }
.form-control { width: 100%; padding: 8px 10px; background: #0d1117; border: 1px solid #30363d; border-radius: 5px; color: #c9d1d9; font-size: 14px; }
.form-control:focus { outline: none; border-color: #388bfd; }

/* Tooltips */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #30363d;
  z-index: 201;
  pointer-events: none;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 12px);
  left: 50%;
  transform: translateX(-50%);
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  white-space: pre-line;
  max-width: 260px;
  width: max-content;
  word-wrap: break-word;
  z-index: 200;
  color: #c9d1d9;
  pointer-events: none;
  line-height: 1.5;
  text-align: left;
}

/* Game layout with sidebar */
.game-layout { display: flex; justify-content: center; min-height: calc(100vh - 140px); }
.game-layout .grid-wrapper { flex: 1; min-width: 0; }

/* Inventory sidebar */
.inventory-sidebar {
  width: 200px;
  background: #161b22;
  border-left: 1px solid #30363d;
  padding: 12px;
  overflow-y: auto;
  max-height: calc(100vh - 120px);
  transition: width 0.2s, padding 0.2s;
}
.inventory-sidebar.collapsed { width: 0; padding: 0; overflow: hidden; border: none; }
.inventory-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.inventory-header h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: #8b949e; }
.inventory-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 12px;
}
.inventory-icon { font-size: 14px; display: flex; align-items: center; }
.inventory-icon img.resource-sprite, .inventory-icon img.building-sprite { width: 16px; height: 16px; image-rendering: pixelated; }
.inventory-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inventory-qty { color: #e3b341; font-weight: 600; font-variant-numeric: tabular-nums; }
.inventory-places { font-size: 10px; color: #8b949e; display: block; width: 100%; margin-top: 2px; }

/* Tutorial overlay */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
}
.tutorial-tooltip {
  background: #161b22;
  border: 1px solid #388bfd;
  border-radius: 8px;
  padding: 20px;
  max-width: 340px;
  text-align: center;
}
.tutorial-step-count { font-size: 11px; color: #8b949e; margin-bottom: 6px; }
.tutorial-title { font-size: 15px; margin-bottom: 8px; }
.tutorial-text { font-size: 13px; color: #c9d1d9; line-height: 1.5; margin-bottom: 14px; }
.tutorial-buttons { display: flex; justify-content: center; gap: 8px; }

/* Building footprints */
.grid-cell.footprint-ext { opacity: 0.6; }
.grid-cell.footprint-ext:hover .cell-remove { display: none; }

/* Module slots */
.module-slots { display: flex; gap: 8px; flex-wrap: wrap; }
.module-slot { display: flex; align-items: center; gap: 4px; padding: 4px 8px; background: #21262d; border: 1px solid #30363d; border-radius: 4px; }
.module-icon { font-size: 16px; }
.module-empty { color: #484f58; font-size: 12px; }

/* Event banner */
/* Research progress strip */
.research-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 16px;
  background: #0d1a2d;
  border-bottom: 1px solid #1f6feb;
  position: sticky;
  top: 132px;
  z-index: 45;
  font-size: 12px;
  color: #c9d1d9;
}
.research-strip-label { white-space: nowrap; }
.research-strip-bar {
  flex: 1;
  height: 6px;
  background: #21262d;
  border-radius: 3px;
  overflow: hidden;
  min-width: 80px;
}
.research-strip-fill {
  height: 100%;
  background: #388bfd;
  border-radius: 3px;
  transition: width 0.5s ease;
}
.research-strip-pct { color: #8b949e; font-variant-numeric: tabular-nums; white-space: nowrap; }

.event-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #3d1a1a;
  border-bottom: 1px solid #da3633;
  font-size: 13px;
  animation: event-pulse 2s ease-in-out infinite;
}
@keyframes event-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.7; } }
.event-label { font-weight: 600; color: #ff7b72; }
.event-desc { color: #c9d1d9; }
.event-timer { margin-left: auto; color: #8b949e; font-variant-numeric: tabular-nums; }

/* Save slots */
.save-slot { padding: 12px; border: 1px solid #30363d; border-radius: 6px; margin-bottom: 8px; }
.save-slot-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.save-slot-info { font-size: 12px; color: #8b949e; }
.save-slot-actions { display: flex; gap: 6px; }

/* Milestones */
.milestones-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.milestone-card { background: #161b22; border: 1px solid #30363d; border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 6px; text-align: center; }
.milestone-card.completed { border-color: #e3b341; opacity: 0.8; }
.milestone-icon { font-size: 28px; }
.milestone-name { font-weight: 600; font-size: 13px; }
.milestone-desc { font-size: 11px; color: #8b949e; line-height: 1.4; }
.milestone-reward { font-size: 11px; color: #3fb950; }

/* Grid upgrade */
.btn-grid-upgrade { border-color: #a371f7; color: #a371f7; }
.btn-grid-upgrade:hover { background: #1a0d30; }

.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }

/* Power detail — non-intrusive fixed side panel, no backdrop */
.power-panel-wrap {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  z-index: 90;
  pointer-events: none;
}
.power-panel-wrap.active { display: block; }
.power-panel-wrap > * { pointer-events: auto; }
.power-panel-wrap .build-panel {
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  border-right: none;
  border-top: none;
  border-bottom: none;
  overflow-y: auto;
  box-shadow: -4px 0 16px rgba(0,0,0,0.5);
}

/* Power detail summary */
.power-summary-grid {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.power-summary-cell {
  flex: 1;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 8px;
  text-align: center;
}
.power-summary-value { font-size: 18px; font-weight: 700; }
.power-summary-label { font-size: 10px; color: #8b949e; margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }
.power-production .power-summary-value { color: #3fb950; }
.power-consumption .power-summary-value { color: #f85149; }
.power-low .power-summary-value { color: #e3b341; }

/* Power section collapsibles */
.power-section { margin-bottom: 12px; border: 1px solid #30363d; border-radius: 6px; overflow: hidden; }
.power-section-header {
  width: 100%;
  background: #21262d;
  border: none;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: #c9d1d9;
  text-align: left;
}
.power-section-header:hover { background: #2d333b; }
.power-section-total { margin-left: auto; font-weight: 600; }
.power-section-body { padding: 6px 0; }

.power-group { border-top: 1px solid #21262d; }
.power-group:first-child { border-top: none; }
.power-group-header {
  width: 100%;
  background: none;
  border: none;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
  color: #8b949e;
  text-align: left;
}
.power-group-header:hover { background: #21262d; color: #c9d1d9; }
.power-group-count { color: #484f58; font-size: 11px; }
.power-group-total { margin-left: auto; font-weight: 600; }

/* Building rows in power panel */
.power-building-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 24px 4px 28px;
  font-size: 11px;
  cursor: default;
  border-radius: 3px;
  margin: 1px 4px;
}
.power-building-row:hover { background: #21262d; }
.power-building-row.power-starved { background: rgba(248, 81, 73, 0.08); }
.power-row-pos { color: #8b949e; min-width: 46px; font-variant-numeric: tabular-nums; }
.power-row-level { color: #8b949e; }
.power-row-value { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.power-starved-badge { font-size: 10px; color: #f85149; }

/* Status dot */
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #484f58;
  flex-shrink: 0;
}
.status-dot.status-active { background: #2ea043; }
.status-dot.status-no_power { background: #484f58; }
.status-dot.status-idle_no_input,
.status-dot.status-no_input { background: #e3b341; }
.status-dot.status-output_full { background: #a371f7; }
.status-dot.status-idle { background: #8b949e; }

/* Power positive/negative colours */
.power-positive { color: #3fb950; }
.power-negative { color: #f85149; }

/* Grid cell highlight from power panel hover */
.grid-cell.power-highlight {
  outline: 2px solid #f0a000;
  outline-offset: -2px;
  z-index: 10;
  position: relative;
}

/* Toggle arrows */
.toggle-arrow { font-size: 10px; color: #8b949e; flex-shrink: 0; }

/* Save toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 8px 16px;
  background: #1c2128;
  border: 1px solid #2ea043;
  border-radius: 6px;
  color: #3fb950;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
}
.toast.toast-active {
  animation: toast-fade 2.5s ease forwards;
}
@keyframes toast-fade {
  0%   { opacity: 1; transform: translateY(0); }
  70%  { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(6px); }
}

/* Minimap */
#minimap-wrap { position: fixed; bottom: 16px; right: 16px; z-index: 85; border: 1px solid #30363d; border-radius: 4px; overflow: hidden; background: #0d1117; box-shadow: 0 2px 8px rgba(0,0,0,0.5); }
#minimap { display: block; cursor: crosshair; }
#minimap:hover { opacity: 0.9; }
