:root {
  --bg: #1a1c1f;
  --panel: #23262a;
  --panel-2: #2d3136;
  --text: #e6e6e6;
  --accent: #8ad4ff;
  --good: #59d185;
  --warn: #f2c44d;
  --bad: #f06a6a;
  --muted: #9aa1a8;
  --pixel: "Press Start 2P", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Tahoma", "Verdana", sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

#app {
  display: grid;
  grid-template-rows: 56px 1fr 60px;
  height: 100vh;
}

.splash {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 16, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.splash.hidden {
  display: none;
}

.splash-card {
  width: min(960px, 92vw);
  background: #161a1f;
  border: 1px solid #95C623;
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

.splash-hero {
  background: #0e1116;
  border-radius: 10px;
  border: 1px solid #2f343c;
  overflow: hidden;
  aspect-ratio: 16 / 9;
}

.splash-hero img {
  width: 100%;
  height: auto;
  display: block;
}

.splash-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.splash-actions button {
  background: var(--panel-2);
  color: #8ad4ff;
  border: 1px solid #3a4048;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.splash-credit {
  margin-top: 10px;
  color: #95C623;
  font-size: 12px;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: linear-gradient(90deg, #2a2f36, #22272e);
  border-bottom: 1px solid #95C623;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #95C623;
  font-size: 18px;
}

.version-tag {
  font-size: 12px;
  margin-left: 6px;
  color: rgba(149, 198, 35, 0.6);
  font-weight: 600;
}

.stats {
  display: flex;
  gap: 16px;
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 8px;
}

.fps-indicator {
  display: none;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid #3a4048;
  padding: 6px 8px;
  border-radius: 6px;
  align-self: center;
}

.controls button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid #3a4048;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.main {
  display: grid;
  grid-template-columns: 220px 1fr 240px;
  gap: 8px;
  padding: 8px;
  min-height: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid #95C623;
  border-radius: 8px;
  padding: 12px;
  overflow-y: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04),
    inset 0 -1px 0 rgba(0, 0, 0, 0.4);
}

.sidebar-split {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}

.sidebar-section {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.sidebar-section.pnl {
  border-top: 1px solid #3a4048;
  padding-top: 12px;
}

.panel h2 {
  margin: 8px 0 12px;
  font-size: 16px;
}

.panel.right h2 {
  color: #95C623;
}

.panel.left h2 {
  color: #95C623;
}

.scenario-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #2f343c;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid #3a4048;
  cursor: default;
}

.panel h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  color: var(--muted);
}

.tool-group {
  display: grid;
  gap: 8px;
}

.onboarding-tip {
  position: absolute;
  left: 16px;
  bottom: auto;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid #3a4048;
  border-radius: 10px;
  background: rgba(20, 24, 30, 0.86);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  z-index: 3;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.onboarding-tip::after {
  content: "";
  position: absolute;
  left: -8px;
  top: var(--arrow-top, 18px);
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-right: 8px solid rgba(20, 24, 30, 0.86);
}

.onboarding-tip.hidden {
  display: none;
}

.tool,
.overlay {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #3a4048;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  font-size: 13px;
}

.cost {
  color: #6f7881;
  font-weight: 400;
  margin-left: 6px;
  white-space: nowrap;
}

.tool-group select {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #3a4048;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
}

.scenario-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.tool.active,
.overlay.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(138, 212, 255, 0.4);
}

.canvas-wrap {
  position: relative;
  background: linear-gradient(135deg, #14171b 0%, #101318 60%, #0d1014 100%);
  border-radius: 8px;
  border: 1px solid #95C623;
  overflow: hidden;
  overscroll-behavior: contain;
}

.canvas-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(
    rgba(255, 255, 255, 0.04) 1px,
    transparent 1px
  );
  background-size: 100% 4px;
  opacity: 0.15;
}

.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: grid;
  gap: 6px;
  z-index: 2;
}

.zoom-controls button {
  width: 36px;
  height: 36px;
  font-size: 18px;
  background: rgba(35, 38, 42, 0.75);
  color: var(--text);
  border: 1px solid #3a4048;
  border-radius: 8px;
  cursor: pointer;
  touch-action: manipulation;
}

.zoom-controls button:hover {
  background: rgba(45, 49, 54, 0.85);
}

.pan-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.pan-row {
  display: flex;
  gap: 6px;
}

.pan-controls button {
  width: 36px;
  height: 36px;
  font-size: 16px;
  font-family: var(--pixel);
  background: rgba(35, 38, 42, 0.75);
  color: var(--text);
  border: 1px solid #3a4048;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  touch-action: manipulation;
}

.pan-controls button:hover {
  background: rgba(45, 49, 54, 0.85);
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  touch-action: none;
}

#hover-card {
  position: absolute;
  pointer-events: none;
  background: rgba(32, 35, 40, 0.95);
  border: 1px solid #3a4048;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  display: none;
}

.legend {
  margin-top: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.legend-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #3a4048;
}

.legend-box.land {
  background: #3f7a4b;
}

.legend-box.water {
  background: #264b6e;
}

.legend-box.link {
  background: #8ad4ff;
}

.legend-box.demand {
  background: #f2c44d;
}

.legend-box.infra {
  background: #59d185;
}

.bottombar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  height: 60px;
  background: #1e2227;
  border-top: 1px solid #95C623;
  font-size: 12px;
}

.tutorial {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.tutorial.hidden {
  display: none;
}

.tutorial-card {
  width: min(520px, 90vw);
  background: #1d2025;
  border: 1px solid #3a4048;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.tutorial-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #95C623;
}

.tutorial-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.tutorial-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.tutorial-actions button {
  flex: 1;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #3a4048;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.dialog {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 12, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 12;
}

.dialog.hidden {
  display: none;
}

.dialog-card {
  width: min(420px, 90vw);
  background: #1d2025;
  border: 1px solid #3a4048;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.dialog-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.instructions-title {
  color: #95C623;
}

.dialog-body {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.dialog-body p {
  margin: 0 0 8px;
}

.dialog-note {
  font-size: 12px;
  color: #7f8a96;
}

.dialog-actions button {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid #3a4048;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.alerts-title {
  font-weight: 700;
  color: var(--accent);
}

#alerts {
  display: flex;
  gap: 16px;
  overflow: hidden;
  white-space: nowrap;
  color: var(--muted);
}

#alerts span {
  max-width: 320px;
  text-overflow: ellipsis;
  overflow: hidden;
}

#alerts span {
  transition: opacity 0.6s ease;
}

#alerts span.alert-fade {
  opacity: 0;
}

.alert-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-right: 6px;
  border-radius: 3px;
  background: #f2c44d;
  color: #1a1c1f;
  font-weight: 700;
  font-size: 11px;
}

.alert-clickable {
  cursor: pointer;
}


#info {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.4;
}

.info-title {
  color: var(--text);
  font-weight: 700;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  background: #2f343c;
  color: var(--muted);
}

@media (max-width: 1000px) {
  .main {
    grid-template-columns: 1fr;
  }

  .panel.left,
  .panel.right {
    display: none;
  }
}
