:root {
  color-scheme: dark;
  --bg: #070907;
  --panel: #101510;
  --panel-strong: #172017;
  --line: #31513a;
  --line-hot: #4df27d;
  --text: #e8ffe9;
  --muted: #a9c8ad;
  --green: #46f06f;
  --amber: #f6bb47;
  --cyan: #45c8f4;
  --red: #ff5c5c;
  --paper: #f2e9c8;
  --shadow: rgba(0, 0, 0, 0.42);
  --radius: 8px;
  font-family: "Courier New", Courier, monospace;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(70, 240, 111, 0.12), transparent 34rem),
    linear-gradient(135deg, #070907 0%, #0b120d 44%, #130f0a 100%);
  color: var(--text);
  overflow-x: hidden;
}

button {
  font: inherit;
}

.scanlines {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 10;
  opacity: 0.17;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.09),
    rgba(255, 255, 255, 0.09) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: soft-light;
}

.app-shell {
  width: min(1440px, calc(100vw - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.topbar,
.statusline,
.panel,
.terminal-panel {
  border: 1px solid var(--line);
  background: rgba(16, 21, 16, 0.94);
  box-shadow: 0 14px 36px var(--shadow), inset 0 0 0 1px rgba(77, 242, 125, 0.05);
}

.topbar {
  min-height: 82px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 16px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border: 2px solid var(--green);
  display: grid;
  place-items: center;
  color: var(--amber);
  font-weight: 900;
  letter-spacing: 0;
  background:
    linear-gradient(90deg, rgba(70, 240, 111, 0.12) 50%, transparent 50%) 0 0 / 8px 8px,
    #0b0f0b;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.16rem, 2.1vw, 1.9rem);
  line-height: 1.12;
  letter-spacing: 0;
  color: var(--green);
  text-shadow: 0 0 14px rgba(70, 240, 111, 0.3);
}

#tagline {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.94rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button {
  min-width: 42px;
  height: 42px;
  padding: 0 12px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #0b120d;
  color: var(--text);
  cursor: pointer;
}

.music-button {
  width: auto;
  min-width: 118px;
  white-space: nowrap;
}

.tips-button {
  width: auto;
  min-width: 112px;
  white-space: nowrap;
}

.tips-button.off {
  color: var(--muted);
}

.rating-button {
  width: auto;
  min-width: 90px;
  white-space: nowrap;
}

.account-button {
  width: auto;
  min-width: 86px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--line-hot);
  color: var(--green);
  outline: none;
}

.game-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 360px);
  grid-template-areas:
    "terminal side"
    "map map";
  align-items: start;
  gap: 12px;
}

.panel,
.terminal-panel {
  border-radius: var(--radius);
}

.panel {
  min-width: 0;
  padding: 12px;
}

.panel-heading,
.terminal-header,
.statusline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--amber);
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  font-size: 0.85rem;
}

.map-panel {
  grid-area: map;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-art {
  width: 100%;
  min-height: 150px;
  max-height: 240px;
  object-fit: contain;
  image-rendering: pixelated;
  border: 1px solid rgba(69, 200, 244, 0.32);
  border-radius: 6px;
  background: #07100f;
}

.city-map {
  position: relative;
  width: 100%;
  min-height: 300px;
  max-height: 380px;
  overflow: hidden;
  border: 1px solid rgba(69, 200, 244, 0.32);
  border-radius: 6px;
  background:
    radial-gradient(circle at 8% 18%, rgba(69, 200, 244, 0.16), transparent 22%),
    linear-gradient(90deg, transparent 0 16%, rgba(49, 81, 58, 0.35) 16% 17%, transparent 17% 34%, rgba(49, 81, 58, 0.35) 34% 35%, transparent 35% 54%, rgba(49, 81, 58, 0.35) 54% 55%, transparent 55% 75%, rgba(49, 81, 58, 0.35) 75% 76%, transparent 76%),
    linear-gradient(0deg, transparent 0 24%, rgba(49, 81, 58, 0.35) 24% 25%, transparent 25% 48%, rgba(49, 81, 58, 0.35) 48% 49%, transparent 49% 72%, rgba(49, 81, 58, 0.35) 72% 73%, transparent 73%),
    #07100f;
}

.map-river {
  position: absolute;
  left: 2%;
  top: 48%;
  width: 82%;
  height: 7px;
  border-radius: 999px;
  background: var(--cyan);
  opacity: 0.62;
  transform: rotate(-18deg);
  box-shadow: 0 0 18px rgba(69, 200, 244, 0.28);
}

.map-road {
  position: absolute;
  height: 3px;
  border-radius: 999px;
  background: rgba(246, 187, 71, 0.86);
  transform-origin: left center;
}

.road-a {
  left: 8%;
  top: 73%;
  width: 80%;
  transform: rotate(-23deg);
}

.road-b {
  left: 28%;
  top: 30%;
  width: 58%;
  transform: rotate(21deg);
}

.road-c {
  left: 36%;
  top: 84%;
  width: 56%;
  transform: rotate(-52deg);
  opacity: 0.68;
}

.map-label,
.map-hint {
  position: absolute;
  color: rgba(169, 200, 173, 0.78);
  font-size: 0.72rem;
  text-transform: uppercase;
  pointer-events: none;
}

.akadem-label {
  left: 4%;
  bottom: 7%;
}

.center-label {
  left: 52%;
  top: 50%;
}

.east-label {
  right: 5%;
  top: 7%;
}

.map-hint {
  left: 12px;
  top: 10px;
  color: var(--amber);
}

.map-point {
  position: absolute;
  z-index: 2;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 5px;
  min-height: 46px;
  width: 104px;
  padding: 4px 7px 4px 4px;
  border: 2px solid var(--green);
  border-radius: 5px;
  background: rgba(7, 16, 13, 0.96);
  color: var(--text);
  cursor: pointer;
  transform: translate(-50%, -50%);
  text-align: left;
}

.map-point span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 22px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: var(--amber);
  font-weight: 900;
}

.map-point b {
  overflow: hidden;
  color: var(--green);
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-point small {
  grid-column: 2;
  display: block;
  margin-top: -2px;
  color: var(--amber);
  font-size: 0.72rem;
}

.map-point:hover,
.map-point:focus-visible,
.map-point.current {
  outline: none;
  box-shadow: 0 0 0 2px rgba(70, 240, 111, 0.28), 0 0 18px rgba(70, 240, 111, 0.3);
}

.map-point.done {
  border-color: var(--amber);
}

.district-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.district-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px;
  border: 1px solid rgba(49, 81, 58, 0.9);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.48);
}

.district-item[role="button"] {
  cursor: pointer;
}

.district-item[role="button"]:hover,
.district-item[role="button"]:focus-visible {
  border-color: var(--line-hot);
  outline: none;
}

.district-item.current {
  border-color: var(--green);
  box-shadow: inset 0 0 18px rgba(70, 240, 111, 0.08);
}

.district-item.done {
  border-color: rgba(246, 187, 71, 0.62);
  color: var(--paper);
}

.district-num {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 1px solid currentColor;
  color: var(--cyan);
  border-radius: 4px;
}

.district-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.district-title strong {
  display: block;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.2;
}

.district-title span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.25;
}

.district-status {
  color: var(--amber);
  font-size: 0.8rem;
}

.terminal-panel {
  grid-area: terminal;
  position: sticky;
  top: 12px;
  min-height: min(620px, calc(100vh - 168px));
  max-height: calc(100vh - 132px);
  display: grid;
  grid-template-rows: auto minmax(92px, auto) auto 1fr auto;
  padding: 14px;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(70, 240, 111, 0.04) 50%, transparent 50%) 0 0 / 10px 10px,
    rgba(7, 10, 7, 0.96);
}

.terminal-header {
  min-height: 34px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.terminal-led {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 16px var(--green);
}

.scene-art {
  min-height: 96px;
  margin: 14px 0 4px;
  color: var(--cyan);
  font-size: clamp(0.62rem, 1.35vw, 0.9rem);
  line-height: 1.05;
  white-space: pre;
  overflow: hidden;
}

.shift-strip:empty {
  display: none;
}

.shift-strip {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(260px, 1fr);
  gap: 8px;
  margin-top: 6px;
}

.shift-metrics,
.shift-event {
  border: 1px solid rgba(49, 81, 58, 0.85);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.shift-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.shift-metrics span,
.shift-event {
  min-height: 38px;
  padding: 7px 8px;
}

.shift-metrics span + span {
  border-left: 1px solid rgba(49, 81, 58, 0.75);
}

.shift-metrics b,
.shift-event b {
  display: block;
  color: var(--amber);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.shift-metrics span,
.shift-event span {
  color: var(--paper);
  font-size: 0.78rem;
  line-height: 1.25;
}

.shift-event {
  display: grid;
  align-content: center;
}

.scene-copy {
  align-self: start;
  padding: 12px 0 18px;
}

.scene-copy h2 {
  margin-bottom: 12px;
  color: var(--paper);
  font-size: clamp(1.2rem, 2vw, 1.7rem);
  line-height: 1.16;
  letter-spacing: 0;
}

.scene-copy p {
  margin-top: 10px;
  color: var(--text);
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.scene-copy .meta {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin-bottom: 12px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--amber);
  background: rgba(246, 187, 71, 0.08);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.roll-line {
  margin-top: 14px;
  color: var(--cyan);
  font-size: 0.92rem;
}

.effects-line {
  margin-top: 12px;
  color: var(--amber);
  font-size: 0.92rem;
}

.battle-meter {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  padding: 10px;
  border: 1px solid rgba(49, 81, 58, 0.9);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.battle-meter div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.battle-meter small {
  color: var(--muted);
}

.choice-grid {
  display: grid;
  gap: 10px;
}

.choice-button,
.hero-button,
.route-card,
.small-action {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-strong);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  line-height: 1.25;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.choice-button,
.hero-button,
.route-card {
  padding: 11px 12px;
}

.choice-button:hover,
.choice-button:focus-visible,
.hero-button:hover,
.hero-button:focus-visible,
.route-card:hover,
.route-card:focus-visible,
.small-action:hover,
.small-action:focus-visible {
  transform: translateY(-1px);
  border-color: var(--green);
  background: #132015;
  outline: none;
}

.choice-button[disabled],
.hero-button[disabled] {
  cursor: default;
  opacity: 0.58;
}

.choice-button[disabled]:hover,
.hero-button[disabled]:hover {
  transform: none;
  border-color: var(--line);
  background: var(--panel-strong);
}

.choice-button b,
.hero-button b,
.route-card b {
  color: var(--green);
}

.choice-button span,
.hero-button span,
.route-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.choice-button small {
  display: block;
  margin-top: 3px;
  color: rgba(246, 187, 71, 0.86);
  font-size: 0.74rem;
  line-height: 1.25;
}

.guest-screen .terminal-panel {
  min-height: 0;
  align-content: start;
  align-items: start;
  grid-template-columns: minmax(150px, 0.34fr) minmax(0, 1fr);
  grid-template-rows: min-content min-content min-content min-content;
  row-gap: 8px;
}

.guest-screen .terminal-header,
.guest-screen .scene-copy,
.guest-screen .choice-grid {
  grid-column: 1 / -1;
}

.guest-screen .scene-art {
  grid-column: 1;
  grid-row: 2;
  align-self: center;
  min-height: 70px;
  margin: 0;
  font-size: clamp(0.52rem, 1vw, 0.78rem);
  line-height: 0.95;
}

.guest-screen .shift-strip {
  grid-column: 2;
  grid-row: 2;
  align-self: center;
  margin-top: 0;
}

.guest-screen .scene-copy {
  padding: 0 0 2px;
}

.guest-screen .scene-copy .meta {
  min-height: 22px;
  margin-bottom: 7px;
  padding: 3px 7px;
  font-size: 0.74rem;
}

.guest-screen .scene-copy h2 {
  margin-bottom: 7px;
  font-size: clamp(1.05rem, 1.55vw, 1.38rem);
}

.guest-screen .scene-copy p {
  margin-top: 6px;
  line-height: 1.34;
}

.guest-screen .battle-meter {
  gap: 5px;
  margin: 6px 0 0;
  padding: 8px;
}

.guest-screen .battle-meter small {
  font-size: 0.76rem;
}

.guest-screen .choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  align-content: start;
}

.guest-screen .choice-button {
  min-height: 54px;
  padding: 8px 10px;
}

.guest-screen .choice-button b {
  display: block;
  overflow: hidden;
  font-size: clamp(0.78rem, 1vw, 0.96rem);
  line-height: 1.12;
  text-overflow: ellipsis;
}

.guest-screen .choice-button span {
  margin-top: 4px;
  font-size: 0.72rem;
  line-height: 1.18;
}

.guest-screen .choice-button small {
  display: none;
}

.guest-screen .choice-button[data-action="finishGuest"] {
  grid-column: 1 / -1;
  min-height: 44px;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-message {
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid rgba(246, 187, 71, 0.8);
  border-radius: 6px;
  background: rgba(246, 187, 71, 0.1);
  color: var(--amber);
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.text-input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #070907;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}

.text-input:focus {
  border-color: var(--line-hot);
  outline: none;
}

.auth-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.auth-hint {
  grid-column: 1 / -1;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid rgba(49, 81, 58, 0.82);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.auth-hint b {
  color: var(--paper);
}

.auth-hint span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.leaderboard-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.leaderboard-summary div,
.leaderboard-row,
.leaderboard-empty {
  border: 1px solid rgba(49, 81, 58, 0.82);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.leaderboard-summary div {
  min-height: 62px;
  padding: 10px;
}

.leaderboard-summary b {
  display: block;
  color: var(--paper);
  font-size: 1.18rem;
}

.leaderboard-summary span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.76rem;
}

.leaderboard-table {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 38px minmax(140px, 1fr) minmax(120px, 0.85fr) minmax(120px, 0.85fr) minmax(82px, 0.52fr) minmax(120px, 0.7fr);
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
}

.leaderboard-head {
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.leaderboard-row.me {
  border-color: var(--green);
  box-shadow: inset 0 0 0 1px rgba(70, 240, 111, 0.22);
}

.leaderboard-row.bot {
  border-color: rgba(69, 200, 244, 0.52);
}

.leaderboard-row b {
  color: var(--paper);
}

.leaderboard-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.22;
}

.rank-cell {
  color: var(--amber);
  font-weight: 700;
}

.leaderboard-empty {
  padding: 14px;
  color: var(--muted);
}

.route-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.route-card {
  min-height: 138px;
}

.route-card[disabled] {
  cursor: default;
  opacity: 0.62;
}

.route-card[disabled]:hover {
  transform: none;
  border-color: var(--line);
  background: var(--panel-strong);
}

.route-card .route-meta {
  color: var(--amber);
  font-size: 0.76rem;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.rule-card {
  min-height: 72px;
  padding: 9px;
  border: 1px solid rgba(49, 81, 58, 0.8);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.rule-card b {
  display: block;
  color: var(--paper);
  margin-bottom: 4px;
}

.side-stack {
  grid-area: side;
  min-height: 0;
  max-height: calc(100vh - 132px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  overflow: auto;
}

.stat-bars {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: minmax(92px, 0.8fr) minmax(88px, 1fr) 54px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar {
  height: 14px;
  border: 1px solid var(--line);
  background: #070907;
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green), var(--amber));
}

.bar-fill.energy-low {
  background: linear-gradient(90deg, var(--red), var(--amber));
}

.stat-row strong {
  color: var(--paper);
  text-align: right;
}

.stat-row em {
  display: inline-block;
  min-width: 24px;
  margin-left: 4px;
  color: var(--green);
  font-style: normal;
  text-align: right;
}

.stat-row em.down {
  color: var(--red);
}

.stat-row.changed .bar {
  border-color: var(--amber);
  box-shadow: 0 0 12px rgba(246, 187, 71, 0.18);
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mini-stat {
  min-height: 48px;
  padding: 8px;
  border: 1px solid rgba(49, 81, 58, 0.8);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.mini-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.mini-stat strong {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-size: 1rem;
}

.log-list {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.perk-button {
  width: 100%;
  border: 1px solid rgba(49, 81, 58, 0.82);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
  color: var(--text);
  cursor: pointer;
}

.perk-button:hover,
.perk-button:focus-visible {
  border-color: var(--line-hot);
  outline: none;
}

.perk-button.learned {
  border-color: rgba(246, 187, 71, 0.9);
}

.perk-button.locked {
  opacity: 0.62;
}

.perk-button .perk-icon {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: var(--cyan);
  font-weight: 900;
}

.perk-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.perk-button {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 6px;
}

.perk-button small {
  display: block;
  margin-top: 3px;
  color: var(--amber);
  font-size: 0.68rem;
}

.perk-button.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(70, 240, 111, 0.18);
}

.perk-detail {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 9px;
  border: 1px solid rgba(49, 81, 58, 0.8);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.perk-detail b {
  display: block;
  margin-bottom: 3px;
  color: var(--paper);
}

.help-flow,
.help-map,
.help-matrix {
  margin-top: 14px;
}

.help-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.help-flow div,
.help-card,
.help-matrix div {
  border: 1px solid rgba(49, 81, 58, 0.82);
  border-radius: 6px;
  background: rgba(7, 9, 7, 0.42);
}

.help-flow div {
  min-height: 70px;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
}

.help-flow b {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  color: var(--cyan);
}

.help-flow span {
  color: var(--paper);
  font-size: 0.78rem;
}

.help-map,
.help-matrix {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.help-card,
.help-matrix div {
  padding: 10px;
  min-height: 86px;
}

.help-card b,
.help-matrix b {
  display: block;
  margin-bottom: 5px;
  color: var(--green);
}

.help-card span,
.help-matrix span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.log-panel {
  min-height: 210px;
  overflow: hidden;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding-right: 4px;
}

.log-list li {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.log-list li:first-child {
  color: var(--text);
}

.small-action {
  min-height: 40px;
  padding: 8px 10px;
  text-align: center;
}

.statusline {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  min-width: min(360px, calc(100vw - 32px));
  max-width: min(560px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--green);
  border-radius: 6px;
  background: #0d160f;
  color: var(--text);
  transform: translate(-50%, 22px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.coach-focus {
  position: relative;
  z-index: 20;
  border-color: var(--amber) !important;
  box-shadow: 0 0 0 3px rgba(246, 187, 71, 0.28), 0 0 26px rgba(246, 187, 71, 0.44) !important;
}

.coach-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  padding: 18px;
  background: rgba(1, 4, 2, 0.18);
}

.coach-overlay.show {
  display: grid;
  align-items: start;
  justify-items: center;
}

.coach-card {
  pointer-events: auto;
  position: relative;
  z-index: 31;
  width: min(520px, calc(100vw - 28px));
  margin-top: 92px;
  padding: 16px;
  border: 2px solid var(--amber);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(246, 187, 71, 0.08) 50%, transparent 50%) 0 0 / 10px 10px,
    #161407;
  box-shadow: 0 24px 56px rgba(0, 0, 0, 0.58), 0 0 30px rgba(246, 187, 71, 0.28);
}

.coach-kicker {
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.coach-card h2 {
  margin-top: 6px;
  color: var(--paper);
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  line-height: 1.2;
}

.coach-card p {
  margin-top: 8px;
  color: var(--text);
  line-height: 1.42;
}

.coach-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.coach-actions button {
  min-height: 40px;
  border: 1px solid rgba(246, 187, 71, 0.8);
  border-radius: 6px;
  background: rgba(246, 187, 71, 0.12);
  color: var(--paper);
  cursor: pointer;
}

.coach-actions button:hover,
.coach-actions button:focus-visible {
  border-color: var(--green);
  outline: none;
}

.danger {
  color: var(--red);
}

.good {
  color: var(--green);
}

.amber {
  color: var(--amber);
}

@media (max-width: 1080px) {
  .game-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "terminal"
      "side"
      "map";
  }

  .side-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    max-height: none;
  }

  .terminal-panel {
    position: static;
    max-height: none;
  }

  .log-list {
    max-height: 170px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100vw - 18px, 680px);
    margin: 9px auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    align-self: stretch;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .game-grid,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .game-grid {
    grid-template-areas:
      "terminal"
      "side"
      "map";
  }

  .terminal-panel {
    position: static;
    min-height: 560px;
    max-height: none;
  }

  .city-map {
    min-height: 320px;
  }

  .guest-screen .terminal-panel {
    min-height: 0;
    grid-template-columns: 1fr;
    grid-template-rows: min-content min-content min-content min-content min-content;
  }

  .guest-screen .terminal-header,
  .guest-screen .scene-art,
  .guest-screen .shift-strip,
  .guest-screen .scene-copy,
  .guest-screen .choice-grid {
    grid-column: 1;
    grid-row: auto;
  }

  .shift-strip {
    grid-template-columns: 1fr;
  }

  .shift-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .guest-screen .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }

  .guest-screen .choice-button {
    min-height: 48px;
    padding: 7px;
  }

  .guest-screen .choice-button span {
    font-size: 0.64rem;
  }

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

  .auth-actions {
    grid-template-columns: 1fr;
  }

  .route-grid,
  .rule-grid,
  .help-map,
  .help-matrix {
    grid-template-columns: 1fr;
  }

  .leaderboard-summary {
    grid-template-columns: 1fr;
  }

  .leaderboard-head {
    display: none;
  }

  .leaderboard-row {
    grid-template-columns: 34px 1fr;
  }

  .leaderboard-row > span:nth-child(n + 3) {
    grid-column: 2;
  }

  .help-flow {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .stat-row {
    grid-template-columns: minmax(86px, 0.7fr) minmax(90px, 1fr) 52px;
  }

  .statusline {
    align-items: flex-start;
    flex-direction: column;
  }

  .coach-card {
    margin-top: 76px;
  }

  .coach-actions {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
