:root {
  color-scheme: light;
  --ink: #18363a;
  --ink-soft: #597075;
  --paper: #f8f3e8;
  --panel: rgba(255, 255, 255, 0.91);
  --panel-solid: #fffdf8;
  --line: rgba(24, 54, 58, 0.14);
  --accent: #177d72;
  --accent-strong: #0d625e;
  --accent-soft: #d8f0e9;
  --danger: #c5473e;
  --warning: #da7e31;
  --shadow: 0 18px 50px rgba(24, 54, 58, 0.17);
  --shadow-soft: 0 8px 24px rgba(24, 54, 58, 0.12);
  --topbar-height: 80px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #d7ccb4;
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 0;
}

button:not(:disabled),
a {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(23, 125, 114, 0.38);
  outline-offset: 2px;
}

.is-hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  transform: translateY(-150%);
}

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

.game-app {
  width: 100%;
  height: 100%;
}

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(230px, 0.85fr) minmax(520px, 2.4fr) auto;
  align-items: center;
  min-height: var(--topbar-height);
  padding: 10px 18px;
  border-bottom: 1px solid rgba(24, 54, 58, 0.13);
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 4px 20px rgba(36, 51, 47, 0.1);
  backdrop-filter: blur(18px);
}

.brand-block,
.time-controls,
.metrics-strip,
.composer-row,
.mission-topline,
.panel-heading,
.composer-head,
.modal-head,
.status-cluster {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 11px;
}

.raw-link {
  display: grid;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--accent-strong);
  box-shadow: 0 4px 12px rgba(22, 61, 67, 0.08);
}

.raw-link:hover {
  background: var(--accent-soft);
}

.raw-link svg {
  width: 20px;
  fill: currentColor;
}

.brand-copy {
  display: grid;
  min-width: 0;
  gap: 1px;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 19px;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.panel-heading span,
.composer-head span,
.modal-head span,
.mission-topline span,
#modalKicker {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.channel-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid rgba(23, 125, 114, 0.22);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

[data-channel="beta"] .channel-badge {
  border-color: rgba(113, 69, 181, 0.25);
  background: #eee4ff;
  color: #6840a5;
}

.metrics-strip {
  justify-content: center;
  min-width: 0;
  gap: clamp(8px, 1.3vw, 24px);
  padding: 0 16px;
}

.metric {
  position: relative;
  display: grid;
  min-width: 67px;
  gap: 2px;
  text-align: left;
}

.metric + .metric::before {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: clamp(-12px, -0.7vw, -5px);
  width: 1px;
  background: var(--line);
  content: "";
}

.metric span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 650;
  white-space: nowrap;
}

.metric strong {
  overflow: hidden;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.035em;
  text-overflow: ellipsis;
}

.metric-money strong {
  color: #11725e;
}

.metric-money strong::after {
  margin-left: 4px;
  color: #b58c2f;
  content: "●";
  font-size: 8px;
  vertical-align: 2px;
}

.metric-reputation strong::after {
  margin-left: 2px;
  color: var(--ink-soft);
  content: "/100";
  font-size: 10px;
  font-weight: 600;
}

.time-controls {
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.speed-group,
.camera-controls {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 3px 12px rgba(24, 54, 58, 0.07);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 11px;
}

.icon-button svg {
  width: 17px;
  fill: currentColor;
}

.icon-button.is-active {
  background: #fde5df;
  color: var(--danger);
}

.speed-group {
  display: flex;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
}

.speed-group button {
  min-width: 36px;
  height: 32px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 800;
}

.speed-group button:hover,
.speed-group button.is-active {
  background: var(--ink);
  color: #fff;
}

.game-stage {
  position: relative;
  height: calc(100% - var(--topbar-height));
  overflow: hidden;
  background: #a9dceb;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
}

#gameCanvas.is-dragging {
  cursor: grabbing;
}

#gameCanvas.is-building {
  cursor: crosshair;
}

.mission-widget,
.selection-panel,
.line-composer,
.event-banner,
.action-dock,
.camera-controls,
.status-cluster {
  position: absolute;
  z-index: 10;
}

.mission-widget,
.selection-panel,
.line-composer {
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.mission-widget {
  top: 18px;
  left: 18px;
  width: min(280px, calc(100vw - 36px));
  padding: 14px 16px;
  border-radius: 16px;
}

.mission-topline {
  justify-content: space-between;
  margin-bottom: 6px;
}

.mission-topline time {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mission-widget > strong {
  display: block;
  font-size: 15px;
}

.mission-widget p {
  margin: 4px 0 9px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
}

.mission-widget small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 10px;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(24, 54, 58, 0.1);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1a8b79, #44b48a);
  transition: width 350ms ease;
}

.event-banner {
  top: 18px;
  left: 50%;
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr) auto;
  align-items: center;
  width: min(520px, calc(100% - 640px));
  min-width: 360px;
  padding: 10px 13px;
  border: 1px solid rgba(196, 96, 52, 0.2);
  border-radius: 14px;
  background: rgba(255, 247, 232, 0.95);
  box-shadow: var(--shadow-soft);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.event-icon {
  display: grid;
  width: 30px;
  height: 30px;
  margin-right: 10px;
  place-items: center;
  border-radius: 50%;
  background: #e58a48;
  color: white;
  font-weight: 900;
}

.event-banner div {
  display: grid;
  gap: 2px;
}

.event-banner strong {
  font-size: 12px;
}

.event-banner div span,
.event-banner time {
  color: var(--ink-soft);
  font-size: 10px;
}

.event-banner time {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.selection-panel {
  top: 18px;
  right: 18px;
  width: 330px;
  max-height: calc(100% - 122px);
  overflow: auto;
  border-radius: 18px;
}

.line-composer {
  top: 18px;
  left: 18px;
  width: 342px;
  max-height: calc(100% - 122px);
  padding: 17px;
  overflow: auto;
  border-radius: 18px;
}

.line-composer:not(.is-hidden) ~ .mission-widget {
  display: none;
}

.panel-heading,
.composer-head,
.modal-head {
  justify-content: space-between;
  gap: 12px;
}

.panel-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 17px 17px 13px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 248, 0.96);
}

.panel-heading div,
.composer-head div,
.modal-head div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.panel-heading h2,
.composer-head h2,
.modal-head h2 {
  margin: 0;
  overflow: hidden;
  font-size: 19px;
  letter-spacing: -0.025em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.close-button {
  display: grid;
  flex: 0 0 auto;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 50%;
  background: rgba(24, 54, 58, 0.08);
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
}

.close-button:hover {
  background: rgba(24, 54, 58, 0.14);
  color: var(--ink);
}

.selection-body {
  padding: 15px 17px;
}

.selection-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 17px 17px;
}

.selection-actions:empty {
  display: none;
}

.composer-help {
  margin: 10px 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.field-label,
.color-fieldset legend {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.text-input,
.select-input,
.modal-body input[type="text"],
.modal-body input[type="number"],
.modal-body textarea,
.modal-body select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: rgba(255, 255, 255, 0.82);
}

.text-input {
  margin: 5px 0 10px;
}

.composer-row {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.composer-row .select-input {
  width: 55%;
}

.color-fieldset {
  margin: 0 0 11px;
  padding: 0;
  border: 0;
}

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 6px;
}

.color-choice {
  width: 25px;
  height: 25px;
  border: 3px solid white;
  border-radius: 50%;
  background: var(--choice-color);
  box-shadow: 0 0 0 1px rgba(24, 54, 58, 0.16);
}

.color-choice.is-active {
  box-shadow: 0 0 0 3px var(--ink);
}

.composer-stops {
  display: grid;
  max-height: 130px;
  margin: 0 0 11px;
  padding: 0;
  overflow: auto;
  list-style: none;
  counter-reset: stops;
}

.composer-stops li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 31px;
  border-bottom: 1px solid rgba(24, 54, 58, 0.08);
  font-size: 12px;
  counter-increment: stops;
}

.composer-stops li:not(.empty-stop)::before {
  display: grid;
  width: 19px;
  height: 19px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  content: counter(stops);
  font-size: 9px;
  font-weight: 800;
}

.composer-stops .empty-stop {
  justify-content: center;
  color: var(--ink-soft);
  font-style: italic;
}

.cost-card {
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(238, 244, 239, 0.72);
}

.cost-card > div,
.detail-row,
.upgrade-meta,
.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cost-card span {
  color: var(--ink-soft);
  font-size: 11px;
}

.cost-card strong {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.cost-card .cost-total {
  margin-top: 4px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.cost-card .cost-total strong {
  color: var(--accent-strong);
  font-size: 16px;
}

.composer-actions,
.boot-actions,
.modal-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.primary-button,
.secondary-button,
.danger-button,
.small-button,
.selection-actions button,
.modal-actions button {
  min-height: 40px;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 800;
}

.primary-button {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 5px 14px rgba(13, 98, 94, 0.2);
}

.primary-button:hover:not(:disabled) {
  background: #094e4c;
}

.secondary-button,
.small-button,
.selection-actions button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary-button:hover:not(:disabled),
.small-button:hover:not(:disabled),
.selection-actions button:hover:not(:disabled) {
  background: var(--accent-soft);
}

.danger-button,
.selection-actions .danger-button {
  background: #fde8e4;
  color: #a6322d;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.composer-actions > * {
  flex: 1;
}

.action-dock {
  bottom: calc(18px + var(--safe-bottom));
  left: 50%;
  display: flex;
  align-items: stretch;
  gap: 3px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.91);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.dock-button {
  position: relative;
  display: grid;
  min-width: 74px;
  min-height: 58px;
  padding: 7px 9px 6px;
  place-items: center;
  gap: 3px;
  border-radius: 13px;
  background: transparent;
  color: var(--ink-soft);
}

.dock-button:hover,
.dock-button.is-active {
  background: rgba(23, 125, 114, 0.1);
  color: var(--accent-strong);
}

.dock-button svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.dock-button span {
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
}

.dock-primary {
  min-width: 98px;
  background: var(--accent-strong);
  color: #fff;
}

.dock-primary:hover,
.dock-primary.is-active {
  background: #094e4c;
  color: #fff;
}

.mobile-more {
  display: none;
}

.camera-controls {
  right: 18px;
  bottom: calc(23px + var(--safe-bottom));
  display: grid;
  grid-template-columns: repeat(3, 38px);
  overflow: hidden;
  border-radius: 12px;
}

.camera-controls button {
  display: grid;
  height: 38px;
  place-items: center;
  border-left: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-size: 21px;
  font-weight: 500;
}

.camera-controls button:first-child {
  border-left: 0;
}

.camera-controls button:hover {
  background: var(--accent-soft);
}

.camera-controls svg {
  width: 18px;
  fill: currentColor;
}

.status-cluster {
  right: 18px;
  bottom: calc(69px + var(--safe-bottom));
  align-items: flex-end;
  flex-direction: column;
  gap: 3px;
  color: rgba(24, 54, 58, 0.7);
  font-size: 9px;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
}

.notification-stack {
  position: absolute;
  z-index: 50;
  top: 84px;
  left: 50%;
  display: grid;
  width: min(380px, calc(100% - 30px));
  gap: 7px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 13px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: var(--shadow-soft);
  animation: toast-in 260ms ease both;
  backdrop-filter: blur(14px);
}

.toast.is-leaving {
  animation: toast-out 220ms ease both;
}

.toast-icon {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.toast.warning .toast-icon {
  background: #fbe6d2;
  color: #a6521f;
}

.toast.danger .toast-icon {
  background: #fde0dc;
  color: #a62f2a;
}

.toast-copy {
  display: grid;
  gap: 1px;
}

.toast-copy strong {
  font-size: 12px;
}

.toast-copy span {
  color: var(--ink-soft);
  font-size: 10px;
}

.modal-layer {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(16, 35, 38, 0.55);
  backdrop-filter: blur(5px);
}

.modal-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(900px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 22px;
  background: var(--panel-solid);
  box-shadow: 0 30px 90px rgba(7, 30, 32, 0.3);
  animation: modal-in 200ms ease both;
}

.modal-head {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.modal-body {
  min-height: 180px;
  padding: 20px;
  overflow: auto;
}

.modal-body > :first-child {
  margin-top: 0;
}

.modal-body > :last-child {
  margin-bottom: 0;
}

.modal-body p {
  color: var(--ink-soft);
  line-height: 1.5;
}

.detail-grid,
.stat-grid,
.upgrade-grid,
.zone-grid,
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.detail-card,
.stat-card,
.upgrade-card,
.zone-card,
.settings-card,
.help-card {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.68);
}

.detail-card,
.stat-card {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.detail-card span,
.stat-card span,
.detail-row span,
.summary-line span,
.upgrade-meta span {
  color: var(--ink-soft);
  font-size: 10px;
}

.detail-card strong,
.stat-card strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
}

.detail-list {
  display: grid;
  gap: 0;
}

.detail-row {
  min-height: 35px;
  border-bottom: 1px solid rgba(24, 54, 58, 0.08);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row strong {
  font-size: 11px;
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-pill.warning {
  background: #fbe8d5;
  color: #a85621;
}

.status-pill.danger {
  background: #f8ddda;
  color: #a9322d;
}

.line-key {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 5px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--line-color);
  box-shadow: 0 0 0 1px rgba(24, 54, 58, 0.2);
  vertical-align: -2px;
}

.congestion-meter {
  margin: 10px 0;
}

.congestion-meter .progress-track {
  height: 7px;
}

.congestion-meter.warning .progress-track span {
  background: #db8136;
}

.congestion-meter.danger .progress-track span {
  background: #c5473e;
}

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

.upgrade-card,
.zone-card {
  display: flex;
  min-height: 175px;
  flex-direction: column;
}

.upgrade-card h3,
.zone-card h3,
.settings-card h3,
.help-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
}

.upgrade-card p,
.zone-card p,
.settings-card p,
.help-card p {
  margin: 3px 0 10px;
  font-size: 11px;
}

.upgrade-card ul,
.zone-card ul {
  margin: 0 0 13px;
  padding-left: 17px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

.upgrade-card button,
.zone-card button {
  width: 100%;
  margin-top: auto;
}

.zone-card.is-locked {
  background: repeating-linear-gradient(-45deg, rgba(24, 54, 58, 0.035) 0 8px, rgba(255, 255, 255, 0.55) 8px 16px);
}

.zone-card.is-unlocked {
  border-color: rgba(23, 125, 114, 0.28);
  background: rgba(224, 244, 236, 0.6);
}

.ranking-toolbar,
.modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.ranking-toolbar select {
  width: auto;
  min-width: 180px;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.ranking-table {
  width: 100%;
  min-width: 790px;
  border-collapse: collapse;
  font-size: 11px;
}

.ranking-table th,
.ranking-table td {
  padding: 10px 11px;
  border-bottom: 1px solid rgba(24, 54, 58, 0.08);
  text-align: left;
  white-space: nowrap;
}

.ranking-table th {
  position: sticky;
  z-index: 1;
  top: 0;
  background: #eef2eb;
  color: var(--ink-soft);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ranking-table tbody tr {
  cursor: pointer;
}

.ranking-table tbody tr:hover {
  background: var(--accent-soft);
}

.ranking-table tbody tr:last-child td {
  border-bottom: 0;
}

.rank-number {
  color: var(--ink-soft);
  font-weight: 900;
}

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

.chart-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
}

.chart-card h3 {
  margin: 0 0 9px;
  font-size: 11px;
}

.chart-card canvas {
  display: block;
  width: 100%;
  height: 130px;
}

.settings-card label,
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  font-size: 11px;
}

.settings-card input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

.settings-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.data-textarea {
  min-height: 170px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 10px;
}

.help-steps {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  padding: 0;
  list-style: none;
  counter-reset: help;
}

.help-steps li {
  position: relative;
  min-height: 86px;
  padding: 13px 13px 13px 48px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.65);
  counter-increment: help;
}

.help-steps li::before {
  position: absolute;
  top: 13px;
  left: 13px;
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  content: counter(help);
  font-size: 10px;
  font-weight: 900;
}

.help-steps strong {
  display: block;
  margin-bottom: 3px;
  font-size: 12px;
}

.help-steps span {
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.4;
}

.boot-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  display: grid;
  padding: 20px;
  place-items: center;
  background:
    radial-gradient(circle at 20% 10%, rgba(81, 184, 159, 0.28), transparent 30%),
    radial-gradient(circle at 82% 85%, rgba(81, 138, 167, 0.28), transparent 32%),
    #173a3e;
}

.boot-overlay::before,
.boot-overlay::after {
  position: absolute;
  border: 12px solid rgba(255, 255, 255, 0.035);
  border-radius: 50%;
  content: "";
}

.boot-overlay::before {
  width: 50vw;
  height: 50vw;
  top: -35vw;
  right: -10vw;
}

.boot-overlay::after {
  width: 32vw;
  height: 32vw;
  bottom: -20vw;
  left: -8vw;
}

.boot-card {
  position: relative;
  z-index: 1;
  width: min(450px, 100%);
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 25px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 30px 100px rgba(4, 18, 20, 0.38);
  text-align: center;
}

.boot-logo {
  display: grid;
  width: 74px;
  height: 74px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 22px;
  background: linear-gradient(145deg, #1e907c, #164f64);
  box-shadow: 0 12px 30px rgba(22, 79, 100, 0.25);
}

.boot-logo svg {
  width: 52px;
  fill: none;
  stroke: #f8f3e8;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 6px;
}

.boot-channel {
  color: var(--accent-strong);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.boot-card h1 {
  margin: 5px 0 6px;
  font-size: 34px;
  letter-spacing: -0.045em;
}

.boot-card > p {
  max-width: 350px;
  margin: 0 auto 20px;
  color: var(--ink-soft);
  line-height: 1.5;
}

.seed-box {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f0f3eb;
  text-align: left;
}

.seed-box label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.seed-box div {
  display: flex;
  gap: 6px;
}

.seed-box input {
  min-width: 0;
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
}

.seed-box button {
  padding: 0 11px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
}

.seed-box small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  font-size: 9px;
}

.boot-actions {
  justify-content: center;
}

.boot-actions button {
  flex: 1;
}

.boot-hint {
  display: block;
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 9px;
}

body.high-contrast {
  --ink: #081012;
  --ink-soft: #26373a;
  --panel: rgba(255, 255, 255, 0.98);
  --line: rgba(0, 0, 0, 0.35);
  --accent: #005f5a;
  --accent-strong: #004b48;
}

body.high-contrast .topbar,
body.high-contrast .action-dock,
body.high-contrast .selection-panel,
body.high-contrast .line-composer {
  border-color: #111;
}

body.reduced-motion *,
body.reduced-motion *::before,
body.reduced-motion *::after {
  scroll-behavior: auto !important;
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.97); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px) scale(0.97); }
}

@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}

@media (max-width: 1180px) {
  :root {
    --topbar-height: 76px;
  }

  .topbar {
    grid-template-columns: 210px minmax(430px, 1fr) auto;
    padding-inline: 12px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .channel-badge,
  .metric-secondary {
    display: none;
  }

  .metrics-strip {
    gap: 15px;
    padding-inline: 8px;
  }

  .metric + .metric::before {
    left: -8px;
  }

  .dock-button {
    min-width: 63px;
  }

  .dock-primary {
    min-width: 88px;
  }

  .camera-controls {
    bottom: calc(94px + var(--safe-bottom));
  }

  .status-cluster {
    bottom: calc(140px + var(--safe-bottom));
  }

  .event-banner {
    width: min(440px, calc(100% - 590px));
  }
}

@media (max-width: 860px) {
  :root {
    --topbar-height: 112px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: 52px 48px;
    padding: 5px 10px 7px;
  }

  .brand-block {
    align-self: center;
  }

  .raw-link {
    width: 36px;
    height: 36px;
    border-radius: 11px;
  }

  .eyebrow {
    display: none;
  }

  .channel-badge {
    display: inline-flex;
  }

  .time-controls {
    grid-column: 2;
    grid-row: 1;
  }

  .metrics-strip {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
    gap: 20px;
    padding: 4px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .metrics-strip::-webkit-scrollbar {
    display: none;
  }

  .metric,
  .metric-secondary {
    display: grid;
    min-width: 72px;
  }

  .event-banner {
    top: 9px;
    width: calc(100% - 24px);
    min-width: 0;
  }

  .mission-widget {
    top: 9px;
    left: 9px;
    width: 245px;
  }

  .selection-panel,
  .line-composer {
    top: auto;
    right: 8px;
    bottom: calc(83px + var(--safe-bottom));
    left: 8px;
    width: auto;
    max-height: min(58vh, 480px);
    border-radius: 18px;
  }

  .line-composer {
    max-height: min(67vh, 560px);
  }

  .action-dock {
    right: 8px;
    bottom: calc(7px + var(--safe-bottom));
    left: 8px;
    justify-content: space-around;
    gap: 1px;
    transform: none;
  }

  .dock-button {
    min-width: 0;
    min-height: 58px;
    flex: 1;
    padding-inline: 4px;
  }

  .dock-primary {
    min-width: 0;
  }

  .dock-more {
    display: none;
  }

  .action-dock.is-expanded .dock-more {
    position: absolute;
    right: 0;
    bottom: calc(100% + 7px);
    display: grid;
    width: 92px;
    border: 1px solid var(--line);
    background: var(--panel-solid);
    box-shadow: var(--shadow-soft);
  }

  .action-dock.is-expanded .dock-more:nth-of-type(7) {
    right: 97px;
  }

  .action-dock.is-expanded .dock-more:nth-of-type(6) {
    right: 194px;
  }

  .mobile-more {
    display: grid;
  }

  .camera-controls {
    right: 9px;
    bottom: calc(83px + var(--safe-bottom));
  }

  .status-cluster {
    right: 9px;
    bottom: calc(128px + var(--safe-bottom));
  }

  .detail-grid,
  .stat-grid,
  .settings-grid,
  .upgrade-grid,
  .zone-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  :root {
    --topbar-height: 108px;
  }

  .topbar {
    grid-template-rows: 48px 48px;
  }

  .brand-copy strong {
    font-size: 15px;
  }

  .channel-badge {
    padding: 3px 5px;
    font-size: 8px;
  }

  .icon-button {
    width: 34px;
    height: 34px;
  }

  .speed-group button {
    min-width: 31px;
    height: 28px;
  }

  .metric {
    min-width: 66px;
  }

  .metric span {
    font-size: 9px;
  }

  .metric strong {
    font-size: 14px;
  }

  .mission-widget {
    width: 220px;
    padding: 11px 12px;
  }

  .mission-widget p,
  .mission-widget small {
    display: none;
  }

  .event-banner {
    grid-template-columns: auto 1fr;
  }

  .event-banner time {
    display: none;
  }

  .dock-button span {
    font-size: 8px;
  }

  .dock-button svg {
    width: 19px;
  }

  .selection-panel,
  .line-composer {
    bottom: calc(78px + var(--safe-bottom));
    max-height: 62vh;
  }

  .camera-controls {
    bottom: calc(78px + var(--safe-bottom));
  }

  .status-cluster {
    display: none;
  }

  .modal-layer {
    align-items: end;
    padding: 0;
  }

  .modal-panel {
    width: 100%;
    max-height: 86vh;
    border-radius: 21px 21px 0 0;
  }

  .modal-head,
  .modal-body {
    padding: 15px;
  }

  .upgrade-grid,
  .zone-grid,
  .settings-grid,
  .chart-grid,
  .help-steps {
    grid-template-columns: 1fr;
  }

  .ranking-toolbar,
  .modal-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .ranking-toolbar select {
    width: 100%;
  }

  .boot-card {
    padding: 23px 18px;
  }

  .boot-card h1 {
    font-size: 29px;
  }

  .boot-logo {
    width: 64px;
    height: 64px;
  }

  .seed-box div,
  .boot-actions {
    flex-direction: column;
  }
}

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