/* Cairn of Crowns — application styles.
 *
 * The visual target is `prototype/index.html`: cinematic northern medieval,
 * dark glass panels over a blurred world backdrop, ember as the only strong
 * accent, fixed left sidebar and a centered main column. This file owns that
 * look for the Django templates; the prototype keeps its own copy so it stays
 * openable from `file://`. Conventions are documented in `docs/PROTOTYPE.md`.
 *
 * Paths are relative to /static/css/, and the game art is mounted at
 * /static/game/ (see STATICFILES_DIRS).
 */

:root {
  color-scheme: dark;
  --ink: #f0ebe3;
  --ink-soft: #b0a89c;
  --muted: #7f786e;
  --panel: rgba(16, 18, 22, 0.88);
  --panel-raised: rgba(22, 24, 28, 0.94);
  --edge: rgba(230, 220, 200, 0.12);
  --edge-strong: rgba(230, 220, 200, 0.22);
  --ember: #c99255;
  --ember-soft: rgba(201, 146, 85, 0.15);
  --ok: #8aaa82;
  --danger: #d08a7a;
  --danger-soft: rgba(208, 138, 122, 0.14);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, sans-serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --max: 1120px;
  --sidebar: 232px;
  --focus: 0 0 0 2px #0c0e12, 0 0 0 4px var(--ember);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.4;
  background: #0a0c10;
}

/* Blurred world stage — decorative only, must stay behind the HUD */
.world-bg {
  position: fixed;
  inset: -24px;
  z-index: 0;
  background: url("../game/world/backdrop.jpg") center top / cover no-repeat;
  filter: blur(14px) saturate(0.8) brightness(0.55);
  transform: scale(1.04);
  pointer-events: none;
}

.world-dim {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 70% at 50% 20%, rgba(20, 24, 30, 0.25), rgba(6, 8, 12, 0.72) 70%),
    linear-gradient(180deg, rgba(8, 10, 14, 0.35), rgba(6, 8, 12, 0.75));
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--ember);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(0.9);
  -webkit-backdrop-filter: blur(18px) saturate(0.9);
}

.panel-raised {
  background: var(--panel-raised);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Keyboard users land here first and can jump the whole navigation rail */
.skip-link {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 50;
  padding: 0.5rem 0.8rem;
  border-radius: 8px;
  background: var(--panel-raised);
  border: 1px solid var(--edge-strong);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ── Sidebar shell ─────────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.7rem 0.75rem;
  border-right: 1px solid var(--edge);
  background: rgba(10, 12, 16, 0.9);
  backdrop-filter: blur(20px) saturate(0.9);
  -webkit-backdrop-filter: blur(20px) saturate(0.9);
  overflow: hidden; /* no sidebar scrollbar — fixed left rail only */
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0.4rem 0.75rem;
  border-bottom: 1px solid var(--edge);
  margin-bottom: 0.65rem;
  min-width: 0;
  flex-shrink: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(201, 146, 85, 0.4);
  background: radial-gradient(circle at 35% 30%, rgba(201, 146, 85, 0.3), #14161a);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 14px;
  height: 14px;
  stroke: var(--ember);
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-name {
  font-family: var(--display);
  font-size: 0.95rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.nav-label {
  margin: 0 0.5rem 0.28rem;
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.65rem;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.48rem 0.55rem;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.85;
}

.nav-item:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

.nav-item.active {
  color: var(--ink);
  background: var(--ember-soft);
  border-color: rgba(201, 146, 85, 0.22);
}

.nav-item.active svg {
  stroke: var(--ember);
  opacity: 1;
}

.nav-item:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.nav-pill {
  margin-left: auto;
  font-size: 0.58rem;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--edge);
  border-radius: 999px;
  padding: 0.12rem 0.35rem;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 0.6rem;
  border-top: 1px solid var(--edge);
  flex-shrink: 0;
}

.player {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.4rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
  min-width: 0;
}

.player-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #4a5058, #1a1e24);
  border: 1px solid rgba(201, 146, 85, 0.3);
  font-size: 0.7rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  flex-shrink: 0;
  text-transform: uppercase;
}

.player-name {
  display: block;
  color: var(--ink);
  font-weight: 650;
  line-height: 1.15;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player form {
  margin-left: auto;
}

.sign-out {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.25rem 0.4rem;
  border-radius: 7px;
}

.sign-out:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

/* ── Main column ───────────────────────────────────────────── */

.main {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar);
  width: calc(100% - var(--sidebar));
  padding: 0.9rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.main > * {
  width: 100%;
  max-width: var(--max);
}

/* Both actions redirect to the panel they were fired from (`#building-farm`).
   Landing flush against the viewport edge reads as a jump, so leave the panel
   some air above it. */
.keep,
.building {
  scroll-margin-top: 0.9rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.85rem;
  padding: 0 0.1rem;
}

.page-head h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.6vw, 1.65rem);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(16, 18, 22, 0.72);
  border: 1px solid var(--edge);
  font-size: 0.76rem;
  color: var(--ink-soft);
  white-space: nowrap;
}

.status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(138, 170, 130, 0.15);
}

.status-pill.is-building .dot {
  background: var(--ember);
  box-shadow: 0 0 0 3px rgba(201, 146, 85, 0.15);
}

/* ── Resources ─────────────────────────────────────────────── */

.resources {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  padding: 0.75rem;
}

.res {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: 0.7rem;
  align-items: center;
  padding: 0.6rem 0.7rem 0.6rem 0.55rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025));
  border: 1px solid var(--edge-strong);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--shadow-sm);
  min-width: 0;
}

/* Single circle only — no extra CSS ring around the icon art */
.res-icon {
  grid-row: 1 / span 3;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  /* Zoom past empty canvas padding so the resource symbol reads larger */
  transform: scale(1.12);
  border: 0;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  background: transparent;
  display: block;
}

.res-name {
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.res-amount {
  font-size: 1.28rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
}

.res-rate {
  font-size: 0.78rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
}

/* ── Construction ──────────────────────────────────────────── */

.construction {
  margin-bottom: 0.75rem;
  padding: 0;
  overflow: hidden;
  border-color: rgba(201, 146, 85, 0.28);
  box-shadow: 0 0 0 1px rgba(201, 146, 85, 0.08), var(--shadow);
}

.construction-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--edge);
  background: linear-gradient(90deg, var(--ember-soft), transparent 55%);
}

.construction-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ember);
}

.live .pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ember);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(201, 146, 85, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(201, 146, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(201, 146, 85, 0); }
}

.construction-body {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.85rem 1.1rem;
  align-items: center;
  padding: 0.9rem 1rem 1rem;
}

.construction-thumb {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--edge-strong);
  box-shadow: var(--shadow-sm);
  background: #1a1e24;
}

.construction-info h3 {
  margin: 0 0 0.2rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.construction-info .effect {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.construction-info .effect strong {
  color: var(--ember);
  font-weight: 700;
}

.construction-timer {
  text-align: right;
  min-width: 7rem;
}

.construction-timer .time {
  font-family: var(--display);
  font-size: 1.85rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.03em;
  line-height: 1;
  color: var(--ink);
}

.progress-wrap {
  grid-column: 1 / -1;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, #6a4a28, var(--ember));
  transition: width 1s linear;
}

/* ── Keep ──────────────────────────────────────────────────── */

/* The Keep is the ceiling every producer is measured against, so it sits above
   the grid rather than inside it — one wide panel, not a fifth card. */
.keep {
  display: grid;
  grid-template-columns: 168px 1fr auto;
  gap: 0.9rem;
  align-items: center;
  padding: 0.7rem;
  margin-bottom: 0.7rem;
}

.keep-art {
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  background: #1a1e24 center center / cover no-repeat;
  border: 1px solid var(--edge);
}

.keep-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.keep-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 500;
}

.keep-level {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ember);
  font-variant-numeric: tabular-nums;
}

.keep-permits {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.keep-action {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-end;
  min-width: 15rem;
}

.keep-action .cost-row {
  margin-bottom: 0;
  justify-content: flex-end;
}

.keep-action .btn {
  width: auto;
  padding-inline: 1.4rem;
}

.keep-next {
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ── Producer cards ────────────────────────────────────────── */

.buildings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
  margin-top: 0.15rem;
}

.building {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.building:hover {
  border-color: var(--edge-strong);
  transform: translateY(-1px);
}

.building.is-building {
  border-color: rgba(201, 146, 85, 0.4);
  box-shadow: 0 0 0 1px rgba(201, 146, 85, 0.12), var(--shadow);
}

/* 16:9 card headers — composed for a short crop, not full-scene portraits */
.building-art {
  position: relative;
  aspect-ratio: 16 / 9;
  width: 100%;
  min-height: 112px;
  max-height: 148px;
  background: #1a1e24 center center / cover no-repeat;
  border-bottom: 1px solid var(--edge);
}

.building-art::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 40%;
  background: linear-gradient(transparent, rgba(10, 12, 16, 0.55));
  pointer-events: none;
}

.level-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: rgba(10, 12, 16, 0.78);
  border: 1px solid var(--edge-strong);
  font-size: 0.7rem;
  font-weight: 700;
  backdrop-filter: blur(6px);
}

.building.is-building .level-badge {
  border-color: rgba(201, 146, 85, 0.4);
  color: var(--ember);
}

.building-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.8rem 0.85rem;
  flex: 1;
}

.building-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem;
}

.building-title {
  margin: 0;
  font-family: var(--display);
  font-size: 1.08rem;
  font-weight: 500;
}

.building-prod {
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ok);
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
}

.stat {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--edge);
}

.stat .lbl {
  display: block;
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.08rem;
}

.stat .val {
  font-size: 0.9rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat .val.next {
  color: var(--ember);
}

/* Store: a producer stops when it is full, so the bar is state, not decor */
.store {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.store-meter {
  flex: 1;
  min-width: 0;
}

.store-nums {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  margin-bottom: 0.22rem;
}

.store-nums .lbl {
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.store-bar {
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.store-bar span {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(201, 146, 85, 0.55), var(--ember));
}

.store.is-full .store-nums {
  color: var(--ember);
}

.store.is-full .store-bar span {
  background: var(--ember);
}

/* A blocked upgrade states the reason as game state, never as a tooltip */
.requirement {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.6rem;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--edge-strong);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin: 0;
}

.requirement svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.upgrade-block {
  margin-top: auto;
  padding-top: 0.55rem;
  border-top: 1px solid var(--edge);
}

.upgrade-label {
  margin: 0 0 0.35rem;
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.cost-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.55rem;
}

.cost-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.18rem 0.45rem 0.18rem 0.18rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--edge);
  font-size: 0.76rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.cost-chip.short {
  background: var(--danger-soft);
  border-color: rgba(208, 138, 122, 0.3);
  color: var(--danger);
}

.cost-chip img {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  display: block;
}

/* ── Buttons ───────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.5rem;
  padding: 0.55rem 0.85rem;
  border-radius: 9px;
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-primary {
  color: #1a1410;
  background: linear-gradient(180deg, #d4a86a, var(--ember));
  border: 1px solid rgba(201, 146, 85, 0.5);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #e0b67a, #b87a3a);
}

.btn-primary:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-building {
  color: var(--ember);
  background: var(--ember-soft);
  border: 1px solid rgba(201, 146, 85, 0.28);
  cursor: default;
}

.btn-ghost {
  width: auto;
  flex-shrink: 0;
  min-height: 2rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--edge-strong);
}

.btn-ghost:hover:not(:disabled) {
  color: var(--ink);
  border-color: var(--ember);
}

.btn-ghost:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn:focus-visible {
  box-shadow: var(--focus);
}

/* ── Sign-in and empty states ──────────────────────────────── */

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem 1.4rem 1.6rem;
}

.auth-card h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.auth-card h2 {
  margin: 0.15rem 0 1.1rem;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.field {
  margin-bottom: 0.8rem;
}

.field label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 9px;
  border: 1px solid var(--edge-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  font: inherit;
}

.field input:focus {
  outline: none;
  border-color: var(--ember);
}

.form-error {
  margin: 0 0 0.9rem;
  padding: 0.5rem 0.65rem;
  border-radius: 9px;
  background: var(--danger-soft);
  border: 1px solid rgba(208, 138, 122, 0.3);
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 650;
}

/* ── Mobile ────────────────────────────────────────────────── */

.mobile-nav {
  display: none;
}

@media (max-width: 960px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 0.85rem 0.9rem 5.5rem;
    align-items: stretch;
  }

  .main > * {
    max-width: none;
  }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    padding: 0.4rem 0.35rem calc(0.4rem + env(safe-area-inset-bottom));
    background: rgba(10, 12, 16, 0.94);
    border-top: 1px solid var(--edge);
    backdrop-filter: blur(16px);
  }

  .mobile-nav a,
  .mobile-nav button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.35rem 0.2rem;
    border-radius: 8px;
    color: var(--muted);
    font-size: 0.62rem;
    font-weight: 700;
    text-decoration: none;
  }

  .mobile-nav svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .mobile-nav .active {
    color: var(--ember);
    background: var(--ember-soft);
  }

  .mobile-nav button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }
}

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

  .construction-body {
    grid-template-columns: auto 1fr;
  }

  .construction-timer {
    grid-column: 1 / -1;
    text-align: left;
    display: flex;
    align-items: baseline;
    gap: 0.65rem;
    min-width: 0;
  }

  /* The Keep's three columns stop fitting here: stack instead of squashing the
     cost chips out of the panel. */
  .keep {
    grid-template-columns: auto 1fr;
    row-gap: 0.7rem;
  }

  .keep-art {
    width: 132px;
  }

  .keep-action {
    grid-column: 1 / -1;
    align-items: stretch;
    min-width: 0;
  }

  .keep-action .cost-row {
    justify-content: flex-start;
  }

  .keep-action .btn {
    width: 100%;
  }
}

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

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

  .keep {
    grid-template-columns: 1fr;
  }

  .keep-art {
    width: 100%;
  }

  .res-icon {
    width: 48px;
    height: 48px;
  }

  .building-art {
    max-height: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live .pulse {
    animation: none;
  }

  .progress > span,
  .building {
    transition: none;
  }

  .building:hover {
    transform: none;
  }

  .world-bg {
    filter: blur(8px) saturate(0.8) brightness(0.5);
  }
}
