/* ───────────────────────────────────────────────────────────────────────
   SimCity MP — SNES-style UI (GLM Build 3)
   Palette inspired by SNES SimCity (1991): warm earthy tones, vivid zones.
   ─────────────────────────────────────────────────────────────────────── */

:root {
  --bg:        #1a1c2c;
  --bg-2:      #292d44;
  --panel:     #3a3151;
  --panel-2:   #4b3f6b;
  --line:      #5d527a;
  --text:      #f4f4f4;
  --text-dim:  #b8b3c8;
  --accent:    #ffcd75;   /* SNES gold */
  --accent-2:  #ef7d57;   /* SNES orange */
  --good:      #38b764;
  --bad:       #b13e53;
  --r-zone:    #c84040;
  --c-zone:    #4040c8;
  --i-zone:    #c8c840;
  --grass:     #40a040;
  --water:     #4080c8;
  --p1:        #4aa3ff;
  --p2:        #ff9f43;
  --p3:        #5cd65c;
  --p4:        #e056fd;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', ui-monospace, monospace;
  font-size: 13px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

button, input { font-family: inherit; font-size: inherit; color: inherit; }

/* ─── Lobby overlay ─────────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #1a1c2c 0%, #292d44 100%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.overlay.visible { display: flex; }

.lobby-card {
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 8px;
  padding: 28px 36px;
  width: 420px;
  max-width: 90vw;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  text-align: center;
}

.logo {
  font-size: 36px;
  letter-spacing: 2px;
  margin: 0 0 6px;
  color: var(--accent);
  text-shadow: 3px 3px 0 #00000080;
  font-weight: bold;
}
.logo-mp { color: var(--accent-2); font-size: 24px; }
.tagline { color: var(--text-dim); margin: 0 0 20px; font-size: 11px; }

.lobby-row {
  display: flex;
  align-items: center;
  margin: 10px 0;
  gap: 10px;
}
.lobby-row label { width: 80px; text-align: right; color: var(--text-dim); }
.lobby-row input {
  flex: 1;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
  outline: none;
}
.lobby-row input:focus { border-color: var(--accent); }

.primary-btn {
  margin-top: 16px;
  width: 100%;
  background: var(--accent);
  color: #2a1d10;
  border: none;
  padding: 12px;
  border-radius: 4px;
  font-weight: bold;
  letter-spacing: 1px;
  cursor: pointer;
  font-size: 14px;
}
.primary-btn:hover { background: #ffd98a; }
.primary-btn:active { transform: translateY(1px); }

.lobby-msg { margin-top: 12px; min-height: 18px; color: var(--bad); font-size: 11px; }

.lobby-divider {
  height: 1px;
  background: var(--line);
  margin: 18px 0;
}

.lobby-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
  margin-bottom: 12px;
}
.lobby-player {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  padding: 6px 10px;
  border-radius: 4px;
  border-left: 4px solid var(--p1);
}
.lobby-player .pip {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--p1);
}
.lobby-player .pname { flex: 1; }
.lobby-player .prole { font-size: 10px; color: var(--text-dim); }
.lobby-player .pready { color: var(--good); font-weight: bold; }
.lobby-player.empty { opacity: 0.4; border-left-color: var(--line); }
.lobby-player.empty .pip { background: var(--line); }

.ready-btn {
  width: 100%;
  background: var(--good);
  color: #04240f;
  border: none;
  padding: 10px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
}
.ready-btn:hover { background: #4ec97a; }
.ready-btn.is-ready { background: var(--bad); color: #2a0a0f; }

.hidden { display: none !important; }

.lobby-hint {
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 10px;
  line-height: 1.4;
}
.lobby-hint code {
  background: var(--bg-2);
  padding: 1px 4px;
  border-radius: 2px;
  color: var(--accent);
}

/* ─── Game shell layout ─────────────────────────────────────────────────── */
.game-shell {
  display: grid;
  grid-template-rows: 44px 1fr 80px;
  height: 100vh;
}

/* ─── Top bar ───────────────────────────────────────────────────────────── */
.topbar {
  background: var(--panel);
  border-bottom: 2px solid var(--accent);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 20px;
}
.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-center { flex: 1; justify-content: center; }
.topbar-right { justify-content: flex-end; }

.city-class {
  font-size: 16px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 1px;
}
.date { color: var(--text-dim); font-size: 12px; }

.stat { display: flex; align-items: baseline; gap: 4px; }
.stat-label { color: var(--text-dim); font-size: 10px; text-transform: uppercase; }
.stat-val { font-weight: bold; font-size: 14px; color: var(--text); }

.speed-controls { display: flex; gap: 2px; }
.speed-btn {
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 4px 8px;
  cursor: pointer;
  font-size: 11px;
  min-width: 32px;
}
.speed-btn.active { background: var(--accent); color: #2a1d10; border-color: var(--accent); }

.room-tag {
  background: var(--bg-2);
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px dashed var(--line);
  font-size: 11px;
  cursor: pointer;
  color: var(--text-dim);
}
.room-tag:hover { border-color: var(--accent); color: var(--accent); }
.room-tag span { color: var(--accent); font-weight: bold; }

/* ─── Main area ─────────────────────────────────────────────────────────── */
.main {
  display: grid;
  grid-template-columns: 180px 1fr 220px;
  overflow: hidden;
}

/* ─── Left sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  background: var(--panel);
  border-right: 2px solid var(--line);
  overflow-y: auto;
  padding: 8px;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-track { background: var(--bg-2); }
.sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.sidebar-section { margin-bottom: 10px; }
.section-title {
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.tool-btn, .view-btn {
  background: var(--bg-2);
  border: 2px solid transparent;
  border-radius: 3px;
  padding: 5px 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-dim);
  transition: all 0.1s;
}
.tool-btn:hover, .view-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}
.tool-btn.active, .view-btn.active {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--accent);
}
.tool-btn .icon {
  font-size: 16px;
  line-height: 1;
}
.tool-btn .lbl {
  font-size: 9px;
  text-align: center;
  line-height: 1.1;
}

.zone-r { color: var(--r-zone); font-weight: bold; }
.zone-c { color: var(--c-zone); font-weight: bold; }
.zone-i { color: var(--i-zone); font-weight: bold; }
.plant-coal { color: #888; }
.plant-nuc { color: var(--good); }

.sidebar-footer {
  margin-top: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
}
.cost-display, .selected-tool {
  display: flex;
  justify-content: space-between;
  margin: 3px 0;
}
.cost-display span:last-child, .selected-tool span:last-child {
  color: var(--accent);
  font-weight: bold;
}

/* ─── Canvas wrap ───────────────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  background: #0d0f1a;
  overflow: hidden;
}
#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.minimap {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 180px;
  height: 150px;
  background: rgba(0,0,0,0.6);
  border: 2px solid var(--accent);
  image-rendering: pixelated;
  cursor: pointer;
}

.hint-overlay {
  position: absolute;
  bottom: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 11px;
  pointer-events: none;
  transition: opacity 0.3s;
}
.hint-overlay.fade { opacity: 0; }

.player-cursors {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.player-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: left 0.08s linear, top 0.08s linear;
  box-shadow: 0 0 4px rgba(0,0,0,0.7);
}
.player-cursor::after {
  content: attr(data-name);
  position: absolute;
  left: 16px;
  top: -2px;
  font-size: 10px;
  color: white;
  background: rgba(0,0,0,0.7);
  padding: 1px 4px;
  border-radius: 2px;
  white-space: nowrap;
}

/* ─── Right panel ───────────────────────────────────────────────────────── */
.rightbar {
  background: var(--panel);
  border-left: 2px solid var(--line);
  overflow-y: auto;
  padding: 8px;
}
.rightbar::-webkit-scrollbar { width: 8px; }
.rightbar::-webkit-scrollbar-track { background: var(--bg-2); }
.rightbar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}
.panel-title {
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
}

/* RCI Meter */
.rci-meter {
  display: flex;
  gap: 6px;
  justify-content: space-around;
  align-items: flex-end;
  height: 90px;
  padding-top: 6px;
}
.rci-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 30px;
}
.rci-label {
  font-weight: bold;
  font-size: 12px;
}
.rci-label.r { color: var(--r-zone); }
.rci-label.c { color: var(--c-zone); }
.rci-label.i { color: var(--i-zone); }

.rci-tube {
  position: relative;
  width: 16px;
  height: 70px;
  background: var(--bg);
  border: 1px solid var(--line);
  overflow: hidden;
}
.rci-zero {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: var(--text-dim);
}
.rci-fill {
  position: absolute;
  left: 0; right: 0;
  transition: height 0.3s, top 0.3s, bottom 0.3s;
}
.rci-fill.r { background: var(--r-zone); }
.rci-fill.c { background: var(--c-zone); }
.rci-fill.i { background: var(--i-zone); }

/* Budget / Stats */
.budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 11px;
}
.budget-row span { color: var(--text-dim); }
.mono { font-family: 'Courier New', monospace; color: var(--text); }
#bud-net.positive { color: var(--good); }
#bud-net.negative { color: var(--bad); }

.tax-control {
  display: flex;
  align-items: center;
  gap: 4px;
}
.tax-control button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  width: 18px;
  height: 18px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.tax-control button:hover { background: var(--accent); color: #2a1d10; }

/* Players list */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  padding: 3px 4px;
  background: var(--bg);
  border-radius: 3px;
}
.player-row .pip {
  width: 10px; height: 10px; border-radius: 50%;
}
.player-row .pname { flex: 1; color: var(--text); }
.player-row .prole { font-size: 9px; color: var(--accent); }
.player-row.me { border: 1px solid var(--accent); }

/* ─── Chat bar ──────────────────────────────────────────────────────────── */
.chatbar {
  background: var(--panel);
  border-top: 2px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 4px 8px;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  font-size: 11px;
  padding: 2px 4px;
}
.chat-log::-webkit-scrollbar { width: 6px; }
.chat-log::-webkit-scrollbar-thumb { background: var(--line); }
.chat-line { padding: 1px 0; color: var(--text-dim); }
.chat-line .who { font-weight: bold; }
.chat-input {
  background: var(--bg-2);
  border: 1px solid var(--line);
  padding: 5px 8px;
  border-radius: 3px;
  color: var(--text);
  outline: none;
}
.chat-input:focus { border-color: var(--accent); }

/* ─── Dr. Wright popup ──────────────────────────────────────────────────── */
.wright-popup {
  position: fixed;
  bottom: 90px;
  right: 240px;
  background: var(--panel);
  border: 3px solid var(--accent);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 320px;
  z-index: 100;
  box-shadow: 0 6px 18px rgba(0,0,0,0.6);
  animation: wright-in 0.25s ease-out;
}
@keyframes wright-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.wright-avatar {
  font-size: 36px;
  background: var(--accent);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.wright-body { flex: 1; }
.wright-name {
  color: var(--accent);
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 4px;
}
.wright-text {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
}
.wright-close {
  margin-top: 8px;
  background: var(--accent);
  color: #2a1d10;
  border: none;
  padding: 4px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: bold;
}

/* ─── Toasts ────────────────────────────────────────────────────────────── */
.toasts {
  position: fixed;
  top: 60px;
  right: 240px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 90;
  pointer-events: none;
}
.toast {
  background: rgba(0,0,0,0.85);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 3px;
  border-left: 3px solid var(--accent);
  font-size: 11px;
  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 { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── Build effect (pulse on placement) ─────────────────────────────────── */
@keyframes build-pulse {
  from { background: rgba(255, 205, 117, 0.4); }
  to   { background: transparent; }
}

/* ─── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .main { grid-template-columns: 140px 1fr 180px; }
  .rightbar .panel { padding: 6px; }
}
@media (max-width: 768px) {
  .main { grid-template-columns: 100px 1fr; }
  .rightbar { display: none; }
  .topbar-center { display: none; }
  .tool-btn .lbl { font-size: 8px; }
}
