:root {
  --ink: #16120e;
  --paper: #efe4d2;
  --paper-2: #e4d4bc;
  --rule: rgba(22, 18, 14, 0.12);
  --muted: #6d6256;
  --housing: #c46a3a;
  --commerce: #d4a017;
  --industry: #5d6b78;
  --green: #3f7a52;
  --civic: #3d6f8a;
  --transit: #b85a28;
  --water: #3a7d8c;
  --historic: #8a5a3a;
  --good: #2f7d4a;
  --bad: #b33a2b;
  --shadow: 0 18px 50px rgba(22, 18, 14, 0.18);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "Outfit", "Avenir Next", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(212, 160, 23, 0.18), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(61, 111, 138, 0.16), transparent 46%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
}
body { min-height: 100dvh; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: 0.45; }

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: calc(18px + var(--safe-t)) 0 calc(28px + var(--safe-b));
}

.screen { display: none; }
.screen.on { display: block; animation: rise 0.35s ease; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.mast {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.brand {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 620;
  letter-spacing: -0.03em;
}
.brand span { color: var(--housing); }
.eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}

.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 28px;
  align-items: center;
  background: linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0.22));
  border: 1px solid var(--rule);
  border-radius: 28px;
  padding: 36px 34px;
  box-shadow: var(--shadow);
}
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.4rem, 5vw, 4.2rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  margin: 8px 0 14px;
}
.lede { color: #3d342c; font-size: 1.05rem; line-height: 1.55; max-width: 36rem; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 650;
  background: var(--ink);
  color: var(--paper);
}
.btn:hover { transform: translateY(-1px); }
.btn.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid rgba(22, 18, 14, 0.22);
}
.btn.paper { background: #fff; color: var(--ink); border: 1px solid var(--rule); }
.btn.warn { background: var(--bad); }

.skyline {
  height: 280px;
  border-radius: 22px;
  background:
    linear-gradient(#8fb7c4, #8fb7c4) 0 62% / 100% 2px no-repeat,
    linear-gradient(180deg, #7ea9b8 0%, #c9dce2 42%, #d7c4a2 42%, #c4ad86 100%);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.bldg {
  position: absolute;
  bottom: 38%;
  background: var(--ink);
  border-radius: 3px 3px 0 0;
}
.bldg.a { left: 10%; width: 34px; height: 78px; background: #2b4450; }
.bldg.b { left: 22%; width: 48px; height: 118px; background: var(--housing); }
.bldg.c { left: 38%; width: 28px; height: 64px; background: var(--civic); }
.bldg.d { left: 50%; width: 56px; height: 96px; background: #3d342c; }
.bldg.e { left: 68%; width: 40px; height: 72px; background: var(--green); }
.park-blob {
  position: absolute;
  left: 72%;
  bottom: 28%;
  width: 70px;
  height: 28px;
  background: #4c8a5e;
  border-radius: 40px;
  opacity: 0.85;
}
.water-band {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28%;
  background: repeating-linear-gradient(
    90deg,
    #3a7d8c 0 12px,
    #468999 12px 24px
  );
  opacity: 0.55;
}

.how {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 18px;
}
.how article {
  background: rgba(255,255,255,0.46);
  border: 1px solid var(--rule);
  border-radius: 18px;
  padding: 16px 16px 18px;
}
.how h3 { font-family: var(--serif); font-size: 1.15rem; margin-bottom: 6px; }
.how p { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.lvl {
  text-align: left;
  border: 1px solid var(--rule);
  background: #fff8ee;
  border-radius: 20px;
  padding: 16px;
  min-height: 148px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(22, 18, 14, 0.05);
}
.lvl:disabled { opacity: 0.42; filter: grayscale(0.35); }
.lvl .kicker { font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
.lvl b { font-family: var(--serif); font-size: 1.25rem; font-weight: 620; }
.lvl .stars { color: var(--commerce); letter-spacing: 2px; margin-top: auto; }

.play-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.play-top h2 {
  font-family: var(--serif);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  letter-spacing: -0.03em;
}
.brief { max-width: 46rem; color: #3d342c; line-height: 1.5; margin-top: 4px; }

.layout {
  display: grid;
  grid-template-columns: 240px 1fr 220px;
  gap: 14px;
  align-items: start;
}
.panel {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--rule);
  border-radius: 20px;
  padding: 14px;
}
.panel h3 {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.metric {
  background: #fff;
  border-radius: 14px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
}
.metric small { display: block; color: var(--muted); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; }
.metric b { font-family: var(--serif); font-size: 1.2rem; }
.metric.over b { color: var(--bad); }
.metric.good b { color: var(--good); }

.check { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-top: 1px solid var(--rule); font-size: 0.88rem; }
.check:first-of-type { border-top: 0; }
.check .ok { color: var(--good); font-weight: 700; }
.check .no { color: var(--bad); font-weight: 700; }

.board-wrap {
  display: flex;
  justify-content: center;
  padding: 12px;
  background:
    linear-gradient(rgba(22,18,14,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,18,14,0.04) 1px, transparent 1px),
    #f6ecda;
  background-size: 18px 18px;
  border: 1px solid var(--rule);
  border-radius: 22px;
  min-height: 420px;
}
.board {
  display: grid;
  gap: 6px;
  width: min(100%, 560px);
}
.cell {
  aspect-ratio: 1;
  border: 0;
  border-radius: 12px;
  position: relative;
  color: #fff;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.cell:hover { transform: translateY(-1px); }
.cell.held, .cell.valid { outline: 2px solid var(--ink); outline-offset: 1px; }
.cell.locked { cursor: default; }
.cell .mark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  font-weight: 700;
}
.cell .cap {
  position: absolute;
  left: 6px;
  bottom: 5px;
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.88;
}

.tone-lot { background: #d7c6a8; color: #5a4e3e; }
.tone-housing { background: linear-gradient(160deg, #e08956, var(--housing)); }
.tone-commerce { background: linear-gradient(160deg, #e8be4a, var(--commerce)); color: #2c2208; }
.tone-industry { background: linear-gradient(160deg, #7d8b98, var(--industry)); }
.tone-green { background: linear-gradient(160deg, #5a9a68, var(--green)); }
.tone-civic { background: linear-gradient(160deg, #5b93ad, var(--civic)); }
.tone-transit { background: linear-gradient(160deg, #d47a48, var(--transit)); }
.tone-water {
  background: repeating-linear-gradient(135deg, #3a7d8c 0 10px, #4a8d9b 10px 20px);
}
.tone-historic { background: linear-gradient(160deg, #b07a54, var(--historic)); }

.palette { display: grid; gap: 6px; }
.swatch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--rule);
  background: #fff;
  border-radius: 12px;
  padding: 8px 10px;
  text-align: left;
}
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.swatch .dot { width: 12px; height: 12px; border-radius: 4px; }
.swatch small { color: var(--muted); }
.tools { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.play-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.hint { color: var(--muted); font-size: 0.88rem; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(22, 18, 14, 0.42);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 20;
}
.modal.on { display: grid; }
.sheet {
  width: min(460px, 100%);
  background: var(--paper);
  border-radius: 24px;
  padding: 26px 24px;
  box-shadow: var(--shadow);
}
.sheet h2 { font-family: var(--serif); font-size: 2rem; margin-bottom: 8px; }
.sheet p { color: #3d342c; line-height: 1.5; margin-bottom: 16px; }
.star-row { font-size: 1.6rem; letter-spacing: 4px; color: var(--commerce); margin-bottom: 14px; }

.ledger {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
}
.yr {
  flex: 1;
  height: 8px;
  border-radius: 99px;
  background: #d7c6a8;
  overflow: hidden;
}
.yr i { display: block; height: 100%; background: var(--good); }
.yr.neg i { background: var(--bad); }

@media (max-width: 980px) {
  .hero, .layout, .how, .level-grid { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .palette { grid-template-columns: 1fr 1fr; }
  .tools { flex-direction: row; flex-wrap: wrap; }
  .skyline { height: 200px; }
  .play-top, .play-foot { flex-direction: column; align-items: stretch; }
}
