:root {
  --bg-deep: #071117;
  --bg-surface: #11242d;
  --bg-panel: #17303a;
  --bg-panel-alt: #21414c;
  --text-main: #f6f4e9;
  --text-muted: #cfd7cf;
  --text-soft: #9baba3;
  --accent: #f1c77f;
  --accent-strong: #d79f4a;
  --danger: #e66652;
  --ok: #59b886;
  --warning: #f6cf74;
  --line: #2a4c58;
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 8px 18px rgba(0, 0, 0, 0.22);
  --panel-glow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --panel-pad: 0.82rem;
  --focus-ring: #ffedb2;
  --layout-max: 1640px;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
  --texture-overlay: url('../assets/ui/topo-overlay-blueprint.png');
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text-main);
  background:
    radial-gradient(circle at 18% 18%, rgba(124, 169, 188, 0.16), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(214, 164, 86, 0.2), transparent 40%),
    linear-gradient(176deg, #050d12 0%, #0b1a22 55%, #0d1f29 100%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 34%, rgba(248, 221, 169, 0.11), transparent 56%),
    var(--texture-overlay) center/640px repeat;
  mix-blend-mode: screen;
  opacity: 0.26;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 50% 46%, transparent 42%, rgba(1, 8, 11, 0.56) 100%);
}

a,
button,
input,
select,
textarea {
  font-family: inherit;
}

button,
input,
select,
textarea {
  color: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #28424d 0%, #20353f 100%);
  color: var(--text-main);
  padding: 0.58rem 0.86rem;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: #54727f;
  box-shadow: var(--shadow-soft);
}

button:active {
  transform: translateY(0);
  box-shadow: none;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

button.primary {
  background: linear-gradient(180deg, #e2b560 0%, #cc8c36 100%);
  color: #151008;
  border-color: #f3cf8a;
}

button.danger {
  background: linear-gradient(180deg, #963f31 0%, #742c22 100%);
  border-color: #c26352;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  box-shadow: 0 0 0 3px rgba(12, 20, 24, 0.72);
}

input[type="checkbox"] {
  accent-color: var(--accent-strong);
}

#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 1rem;
  max-width: var(--layout-max);
  margin: 0 auto;
}

.topbar {
  display: grid;
  grid-template-areas:
    'main'
    'meta'
    'pulse'
    'alerts';
  gap: 0.7rem;
  background:
    linear-gradient(156deg, rgba(18, 38, 48, 0.92), rgba(11, 25, 31, 0.94)),
    var(--texture-overlay) center/680px repeat;
  background-blend-mode: normal, soft-light;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow), var(--panel-glow);
  padding: 0.72rem 0.9rem;
  margin-bottom: 0.95rem;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.topbar-main {
  grid-area: main;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.topbar-brand p {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.topbar-actions button {
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
}

.topbar-meta {
  grid-area: meta;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.34rem;
}

.topbar-pulse {
  grid-area: pulse;
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto auto auto;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid rgba(245, 219, 164, 0.22);
  border-radius: 999px;
  padding: 0.34rem 0.5rem;
  background: linear-gradient(180deg, rgba(14, 24, 31, 0.82), rgba(9, 18, 23, 0.82));
}

.pulse-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 0.28rem;
  font-size: 0.76rem;
  color: var(--text-soft);
  white-space: nowrap;
}

.pulse-metric strong {
  font-size: 0.85rem;
  color: #fbe7bc;
  letter-spacing: 0.01em;
}

.pulse-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(7, 15, 20, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.pulse-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(228, 177, 84, 0.82), rgba(248, 227, 167, 0.94));
  transition: width 220ms ease;
}

.pulse-summary {
  justify-self: end;
}

.pulse-summary .tag {
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(23, 41, 49, 0.8);
  color: var(--text-muted);
  font-size: 0.75rem;
  padding: 0.23rem 0.62rem;
}

.tag.accent {
  background: rgba(198, 145, 60, 0.2);
  border-color: rgba(238, 190, 112, 0.4);
  color: #f7ddb0;
}

.tag.warning {
  background: rgba(246, 207, 116, 0.16);
  border-color: rgba(246, 207, 116, 0.38);
  color: #f7dfad;
}

.tag.danger {
  background: rgba(230, 102, 82, 0.17);
  border-color: rgba(230, 102, 82, 0.42);
  color: #ffd0c7;
}

.status-alerts {
  grid-area: alerts;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  min-height: 1.6rem;
}

.mobile-tabs {
  display: none;
  margin-bottom: 0.65rem;
  gap: 0.4rem;
}

.mobile-tabs button {
  flex: 1;
  text-align: center;
  position: relative;
}

.mobile-tabs button.active,
.mobile-tabs button[aria-selected="true"] {
  background: linear-gradient(180deg, #e2b560 0%, #cc8c36 100%);
  color: #151008;
}

.mobile-tabs button[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 0.28rem;
  height: 2px;
  border-radius: 999px;
  background: rgba(21, 16, 8, 0.62);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.95fr) minmax(560px, 1.8fr) minmax(250px, 0.95fr);
  gap: 0.95rem;
}

.left-col,
.center-col,
.right-col {
  min-width: 0;
}

.panel,
.resources-panel,
.crew-panel,
.phase-panel,
.log-panel,
.map-panel {
  background:
    linear-gradient(164deg, rgba(20, 42, 52, 0.91), rgba(13, 28, 35, 0.93)),
    var(--texture-overlay) center/640px repeat;
  background-blend-mode: normal, soft-light;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--panel-pad);
  box-shadow: var(--shadow), var(--panel-glow);
  backdrop-filter: blur(2px);
}

.resources-panel,
.crew-panel {
  margin-bottom: 0.85rem;
}

.panel h3,
.resources-panel h3,
.crew-panel h3,
.phase-panel h3,
.log-panel h3,
.map-panel h3 {
  margin: 0 0 0.55rem;
  font-size: 0.94rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.parts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  font-size: 0.82rem;
  margin-bottom: 0.65rem;
}

.parts-grid span {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 0.28rem 0.45rem;
  background: rgba(11, 20, 26, 0.45);
}

.vehicle-name {
  margin: 0 0 0.35rem;
  color: var(--accent);
}

.meter {
  margin-bottom: 0.42rem;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.79rem;
  margin-bottom: 0.2rem;
}

.meter-label {
  color: var(--text-muted);
}

.meter-value {
  color: var(--text-main);
}

.meter-track {
  background: #0f1a20;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
  height: 9px;
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 220ms ease;
}

.meter-fill.good {
  background: linear-gradient(90deg, #4ea675, #67c592);
}

.meter-fill.warning {
  background: linear-gradient(90deg, #d5b35b, #f0ca73);
}

.meter-fill.danger {
  background: linear-gradient(90deg, #b85243, #e66d5c);
}

.crew-list {
  display: grid;
  gap: 0.58rem;
}

.crew-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 0.58rem;
  padding: 0.52rem;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(9, 19, 24, 0.55);
}

.crew-avatar-wrap {
  width: 58px;
  height: 58px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.05);
}

.crew-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.crew-main h4 {
  margin: 0;
  font-size: 0.96rem;
}

.crew-role {
  margin: 0.1rem 0 0.35rem;
  color: var(--text-soft);
  font-size: 0.75rem;
}

.crew-vitals {
  display: grid;
  gap: 0.28rem;
}

.trait-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.24rem;
  margin-top: 0.35rem;
}

.canvas-shell {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(199, 170, 116, 0.28);
  background:
    linear-gradient(160deg, rgba(13, 27, 34, 0.92), rgba(10, 20, 26, 0.94)),
    var(--texture-overlay) center/580px repeat;
  background-blend-mode: normal, soft-light;
  box-shadow: var(--shadow);
  margin-bottom: 0.82rem;
}

#game-canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 1100 / 420;
}

.event-panel {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(230, 190, 119, 0.33);
  background: linear-gradient(166deg, rgba(67, 54, 32, 0.9), rgba(48, 38, 20, 0.86));
  padding: 0.8rem;
  margin-bottom: 0.82rem;
}

.event-panel h3 {
  margin: 0 0 0.4rem;
  color: #f7d59f;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.83rem;
}

.event-text p {
  margin: 0 0 0.45rem;
  font-family: 'Spectral', Georgia, serif;
  font-size: 1rem;
  line-height: 1.42;
}

.event-hint {
  margin: -0.1rem 0 0.5rem;
  color: #eecf95;
  font-size: 0.78rem;
}

.event-choices {
  display: grid;
  gap: 0.45rem;
}

.choice-btn {
  text-align: left;
  display: grid;
  gap: 0.1rem;
  background: rgba(22, 37, 45, 0.92);
  border-left: 3px solid rgba(242, 196, 118, 0.4);
}

.choice-btn:hover .choice-hotkey kbd {
  border-color: rgba(255, 255, 255, 0.34);
  background: rgba(13, 22, 27, 0.88);
}

.choice-btn:focus-visible .choice-hotkey kbd {
  border-color: rgba(255, 238, 178, 0.85);
}

.choice-btn:disabled {
  border-left-color: rgba(230, 102, 82, 0.36);
  background: rgba(30, 28, 28, 0.82);
}

.choice-topline {
  display: flex;
  align-items: center;
  gap: 0.44rem;
}

.choice-hotkey kbd {
  min-width: 1.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(9, 16, 20, 0.8);
  color: #f0ddb7;
  font-size: 0.72rem;
  line-height: 1;
  padding: 0.18rem 0.3rem;
}

.choice-btn small {
  color: var(--text-soft);
  font-weight: 500;
}

.choice-reason {
  color: #ffbe9f;
}

.phase-panel p {
  margin: 0 0 0.55rem;
  color: var(--text-muted);
}

.phase-note {
  margin-top: -0.12rem;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.policy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.62rem;
}

.policy-grid label,
.settings-grid label,
.setup-controls label {
  display: grid;
  gap: 0.26rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.5rem;
  align-items: end;
}

.settings-grid button {
  align-self: start;
}

select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.54rem;
  background: #102028;
  color: var(--text-main);
}

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

.phase-actions button {
  min-height: 2.2rem;
}

.phase-actions.services button,
.phase-actions.evening-grid button {
  flex: 1;
  min-width: 120px;
}

.phase-actions button.selected {
  border-color: rgba(240, 195, 119, 0.72);
  background: linear-gradient(180deg, rgba(226, 181, 96, 0.32), rgba(153, 111, 49, 0.45));
  color: #ffe9c2;
}

.log-panel {
  margin-top: 0.82rem;
}

.log-list {
  display: grid;
  gap: 0.42rem;
  max-height: 360px;
  overflow: auto;
  padding-right: 0.1rem;
}

.log-empty {
  margin: 0;
  padding: 0.6rem 0.65rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  color: var(--text-soft);
  font-size: 0.82rem;
  background: rgba(8, 15, 20, 0.4);
}

.log-list::-webkit-scrollbar {
  width: 9px;
}

.log-list::-webkit-scrollbar-thumb {
  background: rgba(118, 148, 168, 0.45);
  border-radius: 999px;
  border: 2px solid rgba(11, 21, 26, 0.75);
}

.log-item {
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(6, 14, 18, 0.58);
  padding: 0.46rem 0.55rem;
}

.log-item header {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-soft);
  margin-bottom: 0.2rem;
}

.log-item h4 {
  margin: 0 0 0.12rem;
  font-size: 0.9rem;
}

.log-item p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.map-track {
  position: relative;
  height: 70px;
  border-radius: 12px;
  border: 1px solid rgba(245, 223, 173, 0.17);
  background:
    linear-gradient(180deg, rgba(12, 27, 33, 0.82), rgba(8, 18, 22, 0.82)),
    var(--texture-overlay) center/460px repeat;
  background-blend-mode: normal, soft-light;
  margin-bottom: 0.5rem;
  overflow: hidden;
}

.map-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      90deg,
      transparent 0%,
      rgba(244, 211, 139, 0.14) 38%,
      rgba(248, 224, 166, 0.2) 50%,
      rgba(244, 211, 139, 0.14) 62%,
      transparent 100%
    );
  pointer-events: none;
}

.map-progress {
  position: absolute;
  inset: 34px auto 20px 0;
  height: 16px;
  background: linear-gradient(90deg, rgba(224, 179, 89, 0.45), rgba(240, 206, 129, 0.6));
  border-right: 1px solid rgba(252, 234, 185, 0.9);
}

.map-stop {
  position: absolute;
  top: 36px;
  transform: translate(-50%, -50%);
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(210, 224, 230, 0.35);
  border: 1px solid rgba(237, 243, 247, 0.36);
}

.map-stop.reached {
  background: #f4e2bc;
  border-color: #fff2da;
}

.map-stop.current {
  width: 12px;
  height: 12px;
  background: #f8cc71;
  border-color: #ffe1a4;
  box-shadow: 0 0 10px rgba(248, 205, 116, 0.65);
}

.map-vehicle {
  position: absolute;
  top: 37px;
  transform: translate(-50%, -50%);
  width: 13px;
  height: 13px;
  border-radius: 4px;
  background: #f4d082;
  border: 1px solid #ffe5b3;
}

.map-caption,
.segment-preview {
  margin: 0 0 0.42rem;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.weather-forecast h4 {
  margin: 0 0 0.32rem;
  color: var(--text-soft);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.why-panel {
  margin-top: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  background: rgba(8, 14, 18, 0.62);
  overflow: hidden;
}

.why-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 0.46rem 0.55rem;
  font-size: 0.8rem;
  color: #f4dcaf;
  border-bottom: 1px solid transparent;
}

.why-panel[open] summary {
  border-bottom-color: rgba(255, 255, 255, 0.11);
}

.why-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem 0.52rem;
}

.why-grid p {
  margin: 0;
  display: grid;
  gap: 0.08rem;
  font-size: 0.76rem;
}

.why-grid strong {
  color: var(--text-soft);
  font-weight: 600;
}

.map-flags {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.map-flags code {
  display: inline-block;
  padding: 0.1rem 0.32rem;
  border-radius: 999px;
  background: rgba(244, 208, 130, 0.16);
  border: 1px solid rgba(244, 208, 130, 0.36);
  color: #f9deaa;
}

.title-screen {
  position: relative;
  min-height: calc(100vh - 2rem);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(218, 186, 125, 0.28);
  background: linear-gradient(145deg, rgba(12, 27, 34, 0.96), rgba(7, 17, 23, 0.96));
  box-shadow: var(--shadow);
}

.title-backdrop {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 17, 23, 0.78) 0%, rgba(7, 17, 23, 0.38) 42%, rgba(7, 17, 23, 0.66) 100%),
    linear-gradient(180deg, rgba(8, 18, 24, 0.16) 0%, rgba(8, 18, 24, 0.65) 100%),
    url('../assets/ui/title-valley-road.png') center/cover no-repeat;
  filter: saturate(1.04) contrast(1.02);
}

.title-content {
  position: relative;
  z-index: 2;
  max-width: 690px;
  margin: 1.8rem 1.6rem;
  padding: 1.6rem 1.5rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  background: linear-gradient(166deg, rgba(8, 19, 24, 0.78), rgba(8, 19, 24, 0.52));
  backdrop-filter: blur(2px);
}

.title-content h1 {
  margin: 0;
  font-size: clamp(2.35rem, 5.2vw, 4rem);
  letter-spacing: 0.055em;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}

.title-content p {
  max-width: 590px;
  margin: 0.72rem 0;
  color: #e2e8dd;
  font-family: 'Spectral', Georgia, serif;
  font-size: 1.12rem;
  line-height: 1.45;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.title-controls {
  margin-top: 1.4rem;
  border: 1px solid rgba(246, 215, 152, 0.28);
  border-radius: 12px;
  padding: 0.7rem 0.8rem;
  background: linear-gradient(160deg, rgba(7, 16, 21, 0.72), rgba(8, 18, 23, 0.52));
}

.title-controls h3 {
  margin: 0 0 0.25rem;
  font-size: 0.92rem;
  text-transform: uppercase;
  color: var(--accent);
}

.title-controls p {
  margin: 0.1rem 0;
  font-size: 0.9rem;
}

.setup-screen,
.summary-screen,
.fatal-error {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.1rem;
  background: linear-gradient(160deg, rgba(22, 39, 49, 0.95), rgba(15, 28, 34, 0.95));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.setup-grid {
  display: grid;
  gap: 0.85rem;
}

.setup-grid h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.setup-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
}

.setup-card {
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 17, 21, 0.58);
  border-radius: 10px;
  padding: 0.6rem;
  transition: border-color 140ms ease, transform 140ms ease, background 140ms ease;
}

.setup-card:hover {
  border-color: rgba(238, 194, 113, 0.42);
  transform: translateY(-1px);
  background: rgba(14, 26, 31, 0.64);
}

.setup-card.active {
  border-color: #f2c679;
  background: rgba(63, 43, 19, 0.48);
}

.setup-card h4 {
  margin: 0 0 0.25rem;
}

.setup-card p {
  margin: 0 0 0.2rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.setup-controls {
  margin-top: 0.85rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.5rem;
  align-items: end;
}

.setup-count {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.2rem 0.55rem;
  font-size: 0.74rem;
  color: var(--text-soft);
}

.setup-count.ready {
  border-color: rgba(115, 201, 150, 0.45);
  background: rgba(89, 184, 134, 0.14);
  color: #b8f0d4;
}

.setup-help {
  margin: 0.7rem 0 0;
  color: var(--text-soft);
  font-size: 0.83rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.summary-grid article {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(8, 15, 19, 0.55);
  padding: 0.55rem;
}

.summary-grid h3 {
  margin: 0;
  font-size: 0.76rem;
  text-transform: uppercase;
  color: var(--text-soft);
}

.summary-grid p {
  margin: 0.25rem 0 0;
  font-size: 1rem;
}

.modal {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  overflow: auto;
  z-index: 80;
  background: linear-gradient(168deg, rgba(16, 30, 38, 0.97), rgba(11, 22, 29, 0.97));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.62);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 9, 0.62);
  backdrop-filter: blur(2px);
  z-index: 70;
}

.modal header,
.modal footer {
  position: sticky;
  z-index: 2;
  background: rgba(16, 30, 38, 0.96);
  padding: 0.75rem;
}

.modal header {
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.modal footer {
  bottom: 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.modal h3 {
  margin: 0;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-close {
  background: linear-gradient(180deg, #3a5563 0%, #2c404a 100%);
  border-color: rgba(173, 202, 218, 0.4);
}

.modal-body {
  padding: 0.76rem;
  display: grid;
  gap: 0.55rem;
}

.save-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.54rem;
}

.save-slot {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  padding: 0.52rem;
  background: rgba(8, 15, 20, 0.58);
}

.save-slot.empty {
  opacity: 0.84;
}

.save-slot h4 {
  margin: 0 0 0.24rem;
}

.save-slot p {
  margin: 0.1rem 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.save-slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.import-box {
  width: 100%;
  min-height: 130px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.8rem;
  line-height: 1.4;
}

.hidden {
  display: none !important;
}

.store-grid,
.repair-grid,
.debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.45rem;
}

.debug-grid label {
  display: grid;
  gap: 0.22rem;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.store-item {
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 10px;
  padding: 0.54rem;
  background: rgba(8, 15, 20, 0.58);
}

.store-item h4 {
  margin: 0 0 0.28rem;
}

.store-item p {
  margin: 0 0 0.38rem;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.store-item button {
  width: 100%;
}

.store-price {
  margin: 0 0 0.18rem;
  color: #f6ddaa;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.store-effect {
  margin: 0 0 0.38rem;
  color: var(--text-muted);
}

.minigame-layout {
  display: grid;
  gap: 0.5rem;
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(60px, 1fr));
  gap: 0.38rem;
}

.mini-cell {
  min-height: 52px;
  font-size: 1rem;
  letter-spacing: 0.08em;
}

.mini-cell.on {
  background: linear-gradient(180deg, #5f8f6e 0%, #487558 100%);
}

.mini-cell.off {
  background: linear-gradient(180deg, #3d4552 0%, #2c343f 100%);
}

.mini-target {
  font-family: 'Spectral', serif;
  color: #f3d7a4;
  letter-spacing: 0.12em;
}

.mini-timer {
  margin: 0;
  color: var(--warning);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  border: 1px solid rgba(246, 211, 142, 0.45);
  background: rgba(19, 32, 40, 0.94);
  color: #f8e4ba;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  animation: toast-in 130ms ease;
}

.debug-controls {
  margin-top: 0.5rem;
}

.debug-flags {
  margin-top: 0.45rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(8, 15, 20, 0.52);
  padding: 0.5rem;
}

.debug-flags h4 {
  margin: 0 0 0.28rem;
  color: var(--text-soft);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.debug-flags p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.debug-flags pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.73rem;
  line-height: 1.35;
  color: #f4e5c3;
}

@media (hover: hover) {
  .panel:hover,
  .resources-panel:hover,
  .crew-panel:hover,
  .phase-panel:hover,
  .log-panel:hover,
  .map-panel:hover {
    border-color: rgba(243, 205, 133, 0.36);
  }
}

.text-small {
  font-size: 14px;
}

.text-large {
  font-size: 18px;
}

.contrast {
  --bg-deep: #000;
  --bg-surface: #0a0a0a;
  --bg-panel: #101010;
  --bg-panel-alt: #171717;
  --text-main: #fff;
  --text-muted: #e8e8e8;
  --text-soft: #d2d2d2;
  --line: #f5f5f5;
}

.reduce-motion *,
.reduce-motion *::before,
.reduce-motion *::after {
  animation-duration: 0s !important;
  transition-duration: 0s !important;
}

.fatal-error h1 {
  margin-top: 0;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
