/* styles.css — SimCity MP (GLM-2)
   SNES-inspired dark UI: chunky panels, pixel font, zone colors. */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-user-select: none;
  user-select: none;
}

:root {
  /* Zone colors per GDD/VISUAL_REFERENCE */
  --c-r: #c84040;
  --c-c: #4040c8;
  --c-i: #c8c840;
  --c-grass: #40a040;
  --c-water: #4080c8;
  --c-road: #808080;

  /* Player colors P1-P4 (arena convention) */
  --p1: #4aa3ff;
  --p2: #ff9f43;
  --p3: #5cd65c;
  --p4: #e056fd;

  /* UI */
  --bg: #0a0e1a;
  --panel: #1a2138;
  --panel-2: #243056;
  --border: #4a5680;
  --text: #e8eef8;
  --text-dim: #98a4c0;
  --accent: #ffd54a;
  --good: #5cd65c;
  --bad: #ff5050;
}

html, body {
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Courier New", Consolas, monospace;
  font-size: 13px;
  overflow: hidden;
  image-rendering: pixelated;
}

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

/* ─── OVERLAYS ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 20, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.overlay.hidden { display: none; }

/* ─── LOBBY ────────────────────────────────────────────────────── */
.lobby-card {
  background: var(--panel);
  border: 3px solid var(--border);
  border-radius: 6px;
  padding: 28px 32px;
  width: 380px;
  box-shadow: 0 0 40px rgba(74, 163, 255, 0.2);
  text-align: center;
}
.logo {
  font-size: 38px;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 2px 2px 0 #5a3c00;
  margin-bottom: 4px;
}
.logo span { color: var(--c-r); }
.subtitle { color: var(--text-dim); font-size: 12px; margin-bottom: 18px; }
.room-label, .room-row { display: block; text-align: left; }
.room-label { color: var(--text-dim); font-size: 11px; margin-bottom: 4px; }
#room-code-input {
  flex: 1;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 18px;
  padding: 6px 10px;
  letter-spacing: 4px;
  text-align: center;
  width: 100%;
  text-transform: uppercase;
}
.room-row { display: flex; gap: 8px; margin-bottom: 6px; }
#join-btn, #ready-btn {
  background: var(--panel-2);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-weight: bold;
  padding: 6px 14px;
  cursor: pointer;
  border-radius: 3px;
}
#join-btn:hover, #ready-btn:hover { background: var(--border); }
#ready-btn { width: 100%; padding: 10px; margin-top: 14px; font-size: 14px; }
#ready-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#ready-btn.ready { background: var(--good); color: #062a06; border-color: var(--good); }
.hint { font-size: 11px; color: var(--text-dim); margin: 8px 0; }
.hint.small { margin-top: 12px; }
.hint code { background: var(--bg); padding: 1px 5px; border-radius: 2px; color: var(--accent); }
.lobby-msg { color: var(--bad); min-height: 16px; font-size: 12px; }

.slots { margin-top: 16px; display: grid; gap: 4px; }
.slot {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-size: 12px;
}
.slot .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot.p1 { background: var(--p1); }
.dot.p2 { background: var(--p2); }
.dot.p3 { background: var(--p3); }
.dot.p4 { background: var(--p4); }
.slot.empty .dot { background: #2a3050; }
.slot .status { color: var(--text-dim); font-size: 11px; }
.slot.me { outline: 1px solid var(--accent); }

/* ─── COUNTDOWN ────────────────────────────────────────────────── */
#countdown { font-size: 120px; color: var(--accent); font-weight: bold; }

/* ─── TOP BAR ──────────────────────────────────────────────────── */
#topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 2px solid var(--border);
}
.tb-field { display: flex; flex-direction: column; gap: 1px; min-width: 70px; }
.tb-field.grow { flex: 1; }
.tb-field label { font-size: 9px; color: var(--text-dim); letter-spacing: 1px; }
.tb-field span { font-size: 14px; font-weight: bold; }
.tb-field .funds { color: var(--good); }
.tb-field .funds.low { color: var(--bad); }
.speed-controls { display: flex; gap: 2px; }
.speed-controls button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 2px 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  border-radius: 2px;
}
.speed-controls button.active { background: var(--accent); color: #2a1d00; border-color: var(--accent); }

/* ─── MAIN AREA ────────────────────────────────────────────────── */
#main { display: grid; grid-template-columns: 84px 1fr 220px; min-height: 0; }

/* Toolbar */
#toolbar {
  background: var(--panel);
  border-right: 2px solid var(--border);
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-y: auto;
  align-items: stretch;
}
#toolbar hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 3px 2px;
  width: calc(100% - 4px);
}
.tool {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 2px solid transparent;
  color: var(--text);
  padding: 3px 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 10px;
  text-align: left;
  border-radius: 3px;
  min-height: 28px;
}
.tool:hover { background: var(--panel-2); }
.tool.active { border-color: var(--accent); background: var(--panel-2); }
.tool .ico {
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: bold;
  border-radius: 2px;
}
.ico-query { background: #2a4060; color: white; }
.ico-bull { background: #660000; color: white; }
.ico-road { background: var(--c-road); }
.ico-rail { background: #604020; }
.ico-power { background: #404040; color: #ffe040; }
.ico-R { background: var(--c-r); color: white; }
.ico-C { background: var(--c-c); color: white; }
.ico-I { background: var(--c-i); color: black; }
.ico-pol { background: #2020a0; color: white; }
.ico-fire { background: #c04000; color: white; }
.ico-stad { background: #404060; color: white; }
.ico-park { background: #208020; color: white; }
.ico-coal { background: #2a2a2a; color: #ccc; }
.ico-nuc { background: #406040; color: white; }
.ico-sea { background: #205080; color: white; }
.ico-air { background: #504060; color: white; }

/* Canvas */
#canvas-wrap {
  position: relative;
  background: #000;
  overflow: hidden;
}
#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  cursor: crosshair;
}
.float-info {
  position: absolute;
  background: rgba(10, 14, 26, 0.9);
  border: 1px solid var(--border);
  padding: 3px 7px;
  font-size: 11px;
  border-radius: 3px;
  pointer-events: none;
}
#cursor-coord { top: 6px; left: 6px; }
#tile-info { bottom: 6px; left: 6px; max-width: 320px; }
.hidden { display: none !important; }

/* Sidebar */
#sidebar {
  background: var(--panel);
  border-left: 2px solid var(--border);
  padding: 6px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 6px;
}
.panel h3 {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* RCI Meter */
#rci-meter { display: flex; gap: 6px; justify-content: space-around; height: 80px; align-items: flex-end; }
.rci-col { display: flex; flex-direction: column; align-items: center; gap: 3px; height: 100%; }
.bar-wrap {
  position: relative;
  width: 18px;
  height: 60px;
  background: var(--bg);
  border: 1px solid var(--border);
  overflow: hidden;
}
.bar-wrap::after {
  /* center line */
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  border-top: 1px solid var(--text-dim);
  opacity: 0.4;
}
.bar {
  position: absolute;
  left: 0; right: 0;
  bottom: 50%;
  background: var(--good);
  transition: height 0.3s, top 0.3s, bottom 0.3s;
}
.bar.neg { background: var(--bad); }
.rci-lbl { font-size: 11px; font-weight: bold; }
.r-r { color: var(--c-r); }
.r-c { color: var(--c-c); }
.r-i { color: var(--c-i); }

/* Minimap */
#minimap {
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  background: #000;
  border: 1px solid var(--border);
}

/* Budget rows */
.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 2px 0;
  gap: 6px;
}
.row span:first-child { color: var(--text-dim); }
#tax-input { width: 80px; vertical-align: middle; }
#tax-val { display: inline-block; min-width: 28px; text-align: right; }
.net { color: var(--good); }
.net.neg { color: var(--bad); }

/* Players list */
#player-list { display: grid; gap: 3px; }
.player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px;
  background: var(--panel-2);
  border-radius: 2px;
  font-size: 11px;
}
.player-row .dot { width: 10px; height: 10px; border-radius: 50%; }
.player-row .host-tag { color: var(--accent); font-size: 9px; }

/* ─── DR. WRIGHT ───────────────────────────────────────────────── */
#wright {
  position: fixed;
  bottom: 30px;
  right: 240px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  z-index: 90;
  animation: wright-in 0.2s ease-out;
}
@keyframes wright-in {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.wright-avatar {
  font-size: 48px;
  background: var(--panel);
  border: 2px solid var(--border);
  border-radius: 50%;
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
}
.wright-bubble {
  background: var(--accent);
  color: #2a1d00;
  padding: 8px 12px;
  border-radius: 8px;
  max-width: 280px;
  font-size: 12px;
  font-weight: bold;
  position: relative;
  margin-bottom: 8px;
}
.wright-bubble::after {
  content: "";
  position: absolute;
  left: -10px; bottom: 14px;
  border: 7px solid transparent;
  border-right-color: var(--accent);
}
#wright-text { margin-bottom: 6px; }
#wright-ok {
  background: #2a1d00;
  color: var(--accent);
  border: none;
  padding: 3px 12px;
  font-family: inherit;
  font-weight: bold;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
}

/* ─── STATUS LINE ──────────────────────────────────────────────── */
#status {
  background: var(--panel);
  border-top: 2px solid var(--border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-dim);
}

/* ─── TOASTS ───────────────────────────────────────────────────── */
#toasts {
  position: fixed;
  top: 50px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 80;
  pointer-events: none;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 3px;
  max-width: 280px;
  animation: toast-in 0.2s ease-out;
}
.toast.bad { border-left-color: var(--bad); }
.toast.good { border-left-color: var(--good); }
@keyframes toast-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
