:root {
  --ink: #1b2430;
  --paper: #f4efe4;
  --hud: #172028;
  --hud-line: #31414c;
  --gold: #f0c14a;
  --coral: #e36a45;
  --card: #fffdf8;
  --muted: #5d6b76;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, #fff8ea 0, transparent 32%),
    var(--paper);
}

body.is-street {
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  align-items: flex-end;
  padding: 0.85rem 1.25rem;
  background: var(--hud);
  color: #f6f1e6;
  border-bottom: 4px solid var(--gold);
}

.brand {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
  letter-spacing: -0.03em;
  padding-bottom: 0.35rem;
}

.player {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.85rem;
  align-items: flex-end;
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 0.25rem;
  min-width: 10.5rem;
}

.field span,
.balance span {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c9d3da;
}

.field input {
  width: 100%;
  border: 1px solid var(--hud-line);
  background: #24323b;
  color: #fffaf1;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
}

.field input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.balance {
  margin: 0;
  min-width: 8.5rem;
  display: grid;
  gap: 0.25rem;
}

.balance strong {
  display: inline-block;
  width: fit-content;
  background: var(--gold);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.48rem 0.8rem;
  font-size: 0.98rem;
}

.lobby {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(300px, 440px);
  gap: 1.25rem;
  padding: 1.25rem;
  align-items: start;
}

.hero,
.menu-panel {
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(23, 32, 40, 0.08);
}

.hero {
  overflow: hidden;
}

.street-screen {
  padding: 1rem;
}

body.is-street .street-screen {
  display: flex;
  flex: 1;
  min-height: 0;
}

.street-view {
  position: relative;
  flex: 1;
  min-height: 320px;
  border-radius: 22px;
  overflow: hidden;
  background: #9fd0ea;
}

.street-back {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.92);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}

.street-back:focus-visible,
.command-open:focus-visible,
.command-panel button:focus-visible,
.command-panel input:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.command-open {
  position: absolute;
  top: 58px;
  left: 12px;
  z-index: 3;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.92);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}

.command-panel {
  position: absolute;
  left: 12px;
  bottom: 52px;
  z-index: 5;
  width: min(320px, calc(100% - 24px));
  display: grid;
  gap: 0.4rem;
  padding: 0.8rem;
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 12px 28px rgba(27, 36, 48, 0.18);
}

.command-panel[hidden] {
  display: none;
}

.command-panel label {
  font-weight: 700;
}

.command-panel input {
  font: inherit;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid rgba(27, 36, 48, 0.16);
  border-radius: 10px;
  background: #fffdf8;
  color: var(--ink);
}

.command-note {
  min-height: 1.2em;
  margin: 0;
  font-weight: 650;
}

.command-actions {
  display: flex;
  gap: 0.45rem;
}

.command-actions button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  background: #efe7d8;
  color: var(--ink);
}

#street-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.situation-count {
  position: absolute;
  right: 12px;
  top: 14px;
  z-index: 3;
  margin: 0;
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.95);
  color: var(--ink);
  font-weight: 700;
  white-space: nowrap;
}

.goal-note {
  position: absolute;
  left: 50%;
  top: 16px;
  z-index: 3;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.95);
  color: var(--ink);
  font-weight: 700;
}

.score-screen {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  background: rgba(23, 32, 40, 0.45);
}

.score-card {
  width: min(360px, calc(100% - 32px));
  padding: 1.2rem 1.2rem 1rem;
  border-radius: 22px;
  background: var(--card);
  text-align: center;
  box-shadow: 0 16px 40px rgba(27, 36, 48, 0.25);
}

.score-card h2 {
  font-size: 2rem;
}

#score-points {
  margin: 0.4rem 0 0.2rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 2.4rem;
}

#score-wage {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

#score-detail {
  margin: 0 0 1rem;
  color: var(--muted);
}

.score-card button {
  font: inherit;
  font-weight: 700;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1rem;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
}

.fail-screen {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  background: rgba(120, 24, 28, 0.88);
  color: #fffdf8;
  text-align: center;
}

.fail-screen p {
  margin: 0;
  font-family: Fraunces, Georgia, serif;
  font-size: clamp(2rem, 6vw, 3.4rem);
  letter-spacing: -0.03em;
}

.npc-choices {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  width: min(440px, calc(100% - 32px));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.9rem;
  border-radius: 18px;
  background: var(--card);
  box-shadow: 0 12px 28px rgba(27, 36, 48, 0.18);
}

#npc-choice-list {
  display: grid;
  gap: 0.4rem;
  align-content: start;
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.npc-choices-title {
  margin: 0 0 0.15rem;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.25rem;
}

.npc-choices button {
  font: inherit;
  font-weight: 700;
  text-align: left;
  border: 0;
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  cursor: pointer;
  background: #efe7d8;
  color: var(--ink);
}

.npc-choices button:hover,
.npc-choices button:focus-visible {
  background: #e7dcc8;
}

.npc-result {
  margin: 0.15rem 0 0;
  color: var(--ink);
  font-weight: 650;
}

.npc-close {
  justify-self: start;
  background: transparent !important;
  color: var(--muted);
  padding-inline: 0.2rem !important;
}

.street-hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  padding: 0.22rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.88);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 560;
}

.hero-copy {
  padding: 1.35rem 1.4rem 1.5rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--coral);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  font-family: Fraunces, Georgia, serif;
  letter-spacing: -0.03em;
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

.lead {
  margin: 0.75rem 0 1.15rem;
  max-width: 34rem;
  font-size: 1.08rem;
  color: var(--muted);
}

.play,
dialog button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.play {
  background: var(--ink);
  color: var(--gold);
  border-radius: 999px;
  padding: 0.85rem 1.6rem;
  font-size: 1.15rem;
  box-shadow: 6px 6px 0 var(--coral);
}

.play:hover {
  transform: translate(-1px, -1px);
}

.play:focus-visible,
dialog button:focus-visible,
.rights-menu button:focus-visible,
.shop-card button:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.shop-panel {
  grid-column: 1 / -1;
  background: var(--card);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(23, 32, 40, 0.08);
  padding: 1rem 1.1rem 1.15rem;
}

.shop-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
  flex-wrap: wrap;
}

.shop-head p,
.shop-price,
.shop-note {
  margin: 0;
  color: var(--muted);
}

.shop-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0.7rem;
  margin: 0.9rem 0 0;
  padding: 0;
}

.shop-preview {
  width: 100%;
  height: auto;
  aspect-ratio: 400 / 360;
  border-radius: 12px;
  background:
    radial-gradient(circle at 50% 82%, rgba(255, 255, 255, 0.9), rgba(243, 230, 207, 0) 46%),
    linear-gradient(#f7efe2, #efe4d0);
}

.shop-card {
  display: grid;
  gap: 0.35rem;
  align-content: start;
  padding: 0.75rem;
  border: 2px solid #efe7d8;
  border-radius: 16px;
  background: #fffaf3;
}

.shop-card.is-worn {
  border-color: var(--ink);
  background: #fff6dc;
}

.shop-name {
  margin: 0;
  font-weight: 700;
}

.shop-card button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  background: var(--ink);
  color: #fffaf1;
}

.shop-card button:disabled {
  cursor: default;
  background: var(--gold);
  color: var(--ink);
}

.shop-note {
  margin-top: 0.75rem;
  font-weight: 700;
  color: var(--ink);
}

.menu-panel {
  padding: 1rem 1rem 1.1rem;
  display: grid;
  grid-template-rows: auto minmax(180px, 46vh) auto;
  min-height: 0;
}

.menu-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.2rem 0.35rem 0.7rem;
}

.menu-head p {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.rights-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 1px solid #efe6d4;
  border-radius: 16px;
  background: #fbf7ef;
}

.rights-menu li + li {
  border-top: 1px solid #efe6d4;
}

.rights-menu button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  padding: 0.72rem 0.8rem;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.7rem;
  align-items: center;
  cursor: pointer;
}

.rights-menu button[aria-current="true"] {
  background: #fff1e4;
}

.num {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 700;
}

.right-detail {
  margin-top: 0.8rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  background: #172028;
  color: #f6f1e6;
}

.right-detail[hidden] {
  display: none;
}

.detail-kicker {
  margin: 0 0 0.25rem;
  color: var(--gold);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.right-detail h3 {
  font-size: 1.25rem;
  margin-bottom: 0.4rem;
}

.right-detail p:last-child {
  margin: 0;
  color: #d7e0e6;
}

dialog {
  border: 0;
  border-radius: 20px;
  padding: 1.4rem 1.4rem 1.2rem;
  max-width: min(26rem, calc(100vw - 2rem));
  box-shadow: 0 24px 60px rgba(23, 32, 40, 0.28);
}

dialog::backdrop {
  background: rgba(23, 32, 40, 0.55);
}

dialog h2 {
  font-size: 1.7rem;
  margin-bottom: 0.45rem;
}

dialog p {
  margin: 0 0 1rem;
  color: var(--muted);
}

dialog button {
  background: var(--ink);
  color: #fffaf1;
  border-radius: 999px;
  padding: 0.6rem 1rem;
}

@media (max-width: 860px) {
  .topbar,
  .player {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .player {
    justify-content: stretch;
  }

  .field {
    flex: 1 1 140px;
  }

  .balance strong {
    justify-self: start;
  }

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

  .menu-panel {
    grid-template-rows: auto minmax(240px, 50vh) auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .play:hover {
    transform: none;
  }
}
