:root {
  --bg: #05060a;
  --fg: #e8ecf5;
  --dim: #8a93a6;
  --blue: #3d8bff;
  --red: #ff4d4d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  touch-action: none;          /* gestures are handled by src/client/input */
  -webkit-user-select: none;
  user-select: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;        /* re-enable on interactive HUD elements only */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.hud-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: linear-gradient(to bottom, rgba(5, 6, 10, 0.85), transparent);
  font-variant-numeric: tabular-nums;
}

#hud-core { color: var(--blue); font-weight: 600; }
#hud-enemy { color: var(--red); font-weight: 600; }

.hud-debug {
  position: absolute;
  left: 12px;
  top: 40px;
  color: var(--dim);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}

/* Start menu and lobby */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(5, 6, 10, 0.92);
  touch-action: auto;
}
.overlay[hidden] { display: none; }
.card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.card .title { font-size: 28px; font-weight: 700; letter-spacing: 0.04em; }
.card .subtitle { color: var(--dim); font-size: 12px; word-break: break-all; }
.card .error { color: #ff9b9b; font-size: 13px; }
.card .player { padding: 6px 10px; background: #0d1220; border-radius: 6px; }
.card .status { color: var(--dim); min-height: 1.3em; }
.card label { display: flex; flex-direction: column; gap: 4px; color: var(--dim); font-size: 12px; }
.card input {
  font: inherit;
  font-size: 16px; /* 16px keeps iOS Safari from zooming on focus */
  padding: 10px 12px;
  color: var(--fg);
  background: #0d1220;
  border: 1px solid #2a3550;
  border-radius: 8px;
  -webkit-user-select: text;
  user-select: text;
}
button {
  font: inherit;
  color: var(--fg);
  padding: 12px 14px;
  background: #162038;
  border: 1px solid #2a3550;
  border-radius: 8px;
  touch-action: manipulation;
}
button:disabled { opacity: 0.4; }

/* In-game controls */
#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}
#controls > * { pointer-events: auto; }
#controls [hidden] { display: none; }
.palette { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 11px; }
.tool-cost { color: #ffd76a; font-variant-numeric: tabular-nums; font-size: 12px; }
.tool.active, .segment.active { border-color: var(--blue); background: #1b2c52; }
.tool.poor, .action.poor { opacity: 0.45; }
.attack-row { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segment { padding: 8px; font-size: 13px; }
.panel { background: rgba(13, 18, 32, 0.92); border: 1px solid #2a3550; border-radius: 8px; padding: 8px 10px; }
.panel-title { font-weight: 600; margin-bottom: 6px; }
.panel-row { display: flex; gap: 6px; flex-wrap: wrap; }
.action { display: flex; gap: 8px; align-items: center; padding: 8px 12px; font-size: 13px; }
.toast {
  align-self: center;
  max-width: 90%;
  padding: 6px 12px;
  background: rgba(13, 18, 32, 0.95);
  border: 1px solid #2a3550;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; }
#banner {
  position: absolute;
  top: 28%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  text-shadow: 0 0 12px rgba(61, 139, 255, 0.8);
}
#banner[hidden] { display: none; }

/* Creep orders, groups and path mode */
.order-row { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; align-items: stretch; }
.order-row:empty { display: none; }
.segments { display: flex; gap: 6px; }
.segments .segment { flex: 1; }
.action.active { border-color: var(--blue); background: #1b2c52; }
.queue { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.queue:empty { display: none; }
.queue-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.queue-row .cancel { padding: 4px 10px; }
