:root {
  color-scheme: dark;
  --bg: #0f1210;
  --bg-2: #171a16;
  --surface: #171c1b;
  --surface-2: #202621;
  --surface-3: #2a3028;
  --text: #f3f0e7;
  --muted: #aeb7ad;
  --line: rgba(243, 240, 231, 0.16);
  --line-strong: rgba(243, 240, 231, 0.3);
  --teal: #49d6c1;
  --green: #78d66d;
  --amber: #f4b23e;
  --coral: #ff6f61;
  --blue: #6fa8ff;
  --violet: #b18cff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --inset: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  overflow-x: hidden;
}

.cockpit-background {
  background:
    linear-gradient(115deg, rgba(73, 214, 193, 0.08), transparent 30%),
    linear-gradient(245deg, rgba(244, 178, 62, 0.08), transparent 38%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0, rgba(255, 255, 255, 0.035) 1px, transparent 1px, transparent 72px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.028) 0, rgba(255, 255, 255, 0.028) 1px, transparent 1px, transparent 56px),
    linear-gradient(180deg, #111612 0%, #0f1210 55%, #17160f 100%);
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: -2;
}

.cockpit-background::after {
  background: repeating-linear-gradient(135deg, transparent 0, transparent 14px, rgba(244, 178, 62, 0.05) 14px, rgba(244, 178, 62, 0.05) 16px);
  content: "";
  inset: auto 0 0;
  height: 190px;
  opacity: 0.8;
  position: absolute;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.03));
  box-shadow: var(--inset), 0 8px 18px rgba(0, 0, 0, 0.18);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  min-height: 38px;
  padding: 8px 12px;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}

button:hover {
  border-color: rgba(73, 214, 193, 0.58);
  transform: translateY(-1px);
}

button:focus-visible {
  outline: 3px solid rgba(73, 214, 193, 0.35);
  outline-offset: 2px;
}

button.active,
button.primary {
  background: linear-gradient(180deg, #49d6c1, #2aa996);
  border-color: rgba(73, 214, 193, 0.85);
  color: #071211;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 22px;
  justify-content: space-between;
  padding: 24px 28px 18px;
}

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

.brand-mark {
  align-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.02)),
    #151b19;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  flex: 0 0 68px;
  grid-template-columns: 1fr 1fr;
  height: 68px;
  overflow: hidden;
  padding: 8px;
  position: relative;
  width: 68px;
}

.brand-mark,
.brand-mark:hover {
  color: inherit;
  text-decoration: none;
}

.brand-mark span {
  align-items: center;
  background: var(--amber);
  border-radius: 5px;
  color: #1a1204;
  display: flex;
  font-size: 24px;
  font-weight: 900;
  grid-row: span 2;
  justify-content: center;
}

.brand-mark i {
  background: rgba(73, 214, 193, 0.82);
  border-radius: 999px;
  display: block;
  height: 8px;
  margin: auto;
  width: 8px;
}

.brand-mark i:nth-of-type(2) {
  background: rgba(120, 214, 109, 0.9);
}

.brand-mark i:nth-of-type(3) {
  background: rgba(255, 111, 97, 0.9);
}

.eyebrow,
.module-kicker,
.subtitle,
.rail-title {
  color: var(--muted);
  margin: 0;
}

.eyebrow,
.module-kicker {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.subtitle {
  font-size: 14px;
  line-height: 1.6;
  margin-top: 7px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 34px;
  font-weight: 850;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  font-weight: 850;
}

.status-strip {
  align-items: stretch;
  background: rgba(18, 23, 21, 0.86);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow), var(--inset);
  display: grid;
  gap: 8px;
  grid-template-columns: auto auto repeat(3, minmax(74px, 1fr));
  max-width: 620px;
  padding: 8px;
}

.status-chip,
.metric-chip {
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  white-space: nowrap;
}

.metric-chip {
  align-items: flex-start;
  flex-direction: column;
  gap: 2px;
}

.metric-chip strong {
  color: var(--text);
  font-size: 20px;
  line-height: 1;
}

.metric-chip small {
  color: var(--muted);
  font-size: 12px;
}

.dot {
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.05);
  display: inline-block;
  height: 10px;
  width: 10px;
}

.dot.waiting {
  background: #788077;
}

.dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(120, 214, 109, 0.12), 0 0 18px rgba(120, 214, 109, 0.55);
}

.dot.bad {
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(255, 111, 97, 0.12), 0 0 18px rgba(255, 111, 97, 0.55);
}

.layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(560px, 1fr) minmax(330px, 390px);
  grid-template-areas:
    "game hardware"
    "game wifi"
    "evidence rubric"
    "event event";
  padding: 0 28px 28px;
}

.game-stage,
.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.035)),
    rgba(18, 23, 21, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow), var(--inset);
  position: relative;
}

.game-stage::before,
.panel::before {
  border: 1px solid rgba(73, 214, 193, 0.28);
  border-bottom: 0;
  border-left: 0;
  content: "";
  height: 18px;
  pointer-events: none;
  position: absolute;
  right: 10px;
  top: 10px;
  width: 42px;
}

.game-stage {
  grid-area: game;
  min-height: 650px;
  overflow: hidden;
}

.stage-hud {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(73, 214, 193, 0.18), transparent 46%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px;
}

.mission-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.mission-readout span {
  background: rgba(244, 178, 62, 0.13);
  border: 1px solid rgba(244, 178, 62, 0.34);
  border-radius: 999px;
  color: #ffe1a3;
  font-size: 12px;
  font-weight: 800;
  padding: 7px 10px;
}

.stage-toolbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 12px;
  grid-template-columns: auto auto 1fr;
  padding: 12px 16px;
}

.control-cluster {
  align-items: center;
  display: flex;
  gap: 8px;
}

.control-cluster > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.segmented,
.speed-control,
.stage-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bridge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.bridge-actions button {
  min-width: 86px;
}

.segmented,
.speed-control {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px;
}

.segmented button,
.speed-control button {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  min-height: 32px;
  padding: 5px 10px;
}

.segmented button.active {
  background: linear-gradient(180deg, #49d6c1, #2aa996);
  border-color: rgba(73, 214, 193, 0.85);
  color: #071211;
}

.speed-control button.active {
  background: linear-gradient(180deg, #f4b23e, #d68e1c);
  border-color: rgba(244, 178, 62, 0.9);
  color: #1a1204;
}

.stage-actions {
  justify-content: flex-end;
}

.stage-actions button {
  min-width: 72px;
}

.game-shell {
  background:
    linear-gradient(180deg, rgba(73, 214, 193, 0.11), transparent 18%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 16%, transparent 84%, rgba(255, 255, 255, 0.05)),
    #e8ecea;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  margin: 16px;
  overflow: hidden;
  padding: 12px;
  position: relative;
}

.game-shell::before {
  background: repeating-linear-gradient(90deg, rgba(15, 18, 16, 0.06) 0, rgba(15, 18, 16, 0.06) 1px, transparent 1px, transparent 28px);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.frame-label {
  color: rgba(15, 18, 16, 0.72);
  display: flex;
  font-size: 11px;
  font-weight: 900;
  justify-content: space-between;
  margin-bottom: 8px;
  position: relative;
  z-index: 2;
}

#dpGameFrame {
  background: #f7f7f7;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.22);
  display: block;
  height: 530px;
  position: relative;
  width: 100%;
  z-index: 2;
}

.panel {
  padding: 16px;
}

.panel-header {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.hardware-panel {
  grid-area: hardware;
}

.evidence-panel {
  grid-area: evidence;
}

.wifi-panel {
  grid-area: wifi;
}

.rubric-panel {
  grid-area: rubric;
}

.event-panel {
  grid-area: event;
}

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

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

.connection-state {
  background: rgba(73, 214, 193, 0.07);
  border: 1px solid rgba(73, 214, 193, 0.15);
  border-radius: 6px;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
}

.connection-state > span {
  color: var(--text);
  font-size: 14px;
  font-weight: 850;
}

.connection-state small,
.status-note,
.wifi-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.bridge-panel {
  align-items: center;
  background:
    linear-gradient(120deg, rgba(73, 214, 193, 0.1), rgba(244, 178, 62, 0.08)),
    rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(73, 214, 193, 0.18);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.bridge-panel .rail-title {
  margin-top: 0;
}

.bridge-panel strong,
.bridge-panel small {
  display: block;
}

.bridge-panel strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}

.bridge-panel small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  margin-top: 4px;
}

.bridge-learn-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.rotary-panel {
  align-items: center;
  background:
    linear-gradient(120deg, rgba(177, 140, 255, 0.14), rgba(73, 214, 193, 0.06)),
    var(--surface-2);
  border: 1px solid rgba(177, 140, 255, 0.22);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 12px;
}

.rotary-panel strong,
.rotary-panel small {
  display: block;
}

.rotary-panel strong {
  color: #e6d8ff;
  font-size: 14px;
}

.rotary-panel small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  margin-top: 5px;
}

.rotary-dial {
  align-items: center;
  border: 2px solid rgba(177, 140, 255, 0.7);
  border-radius: 50%;
  color: #e6d8ff;
  display: flex;
  flex: 0 0 44px;
  font-size: 26px;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.wifi-form {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.wifi-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.wifi-form input {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.wifi-form input:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(73, 214, 193, 0.16);
}

.wifi-form label:nth-of-type(1),
.wifi-form label:nth-of-type(2),
.wifi-form label:nth-of-type(3) {
  align-self: end;
}

.wifi-form label:nth-of-type(2),
.wifi-form input[name="ssid"],
.wifi-form label:nth-of-type(3),
.wifi-form input[name="password"] {
  grid-column: span 2;
}

.wifi-form .inline-field {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
}

.wifi-form .inline-field input {
  min-width: 0;
}

.wifi-form > button,
.wifi-help {
  grid-column: span 2;
}

.wifi-help {
  margin: 10px 0 0;
}

.wifi-help.no-margin {
  margin: 0 0 12px;
}

.key-button {
  align-items: stretch;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03)),
    var(--surface-2);
  border: 1px solid var(--line);
  border-bottom-color: rgba(0, 0, 0, 0.55);
  border-radius: 8px;
  box-shadow: var(--inset), 0 10px 0 rgba(0, 0, 0, 0.22), 0 18px 24px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 5px;
  min-height: 82px;
  padding: 12px;
  text-align: left;
}

.key-button:hover {
  border-color: rgba(244, 178, 62, 0.65);
  transform: translateY(-2px);
}

.key-button:active {
  box-shadow: var(--inset), 0 4px 0 rgba(0, 0, 0, 0.22), 0 10px 16px rgba(0, 0, 0, 0.22);
  transform: translateY(4px);
}

.key-button strong {
  color: var(--amber);
  font-size: 20px;
  line-height: 1;
}

.key-button span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.key-button span:last-child {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.rail-title {
  font-size: 12px;
  font-weight: 800;
  margin-top: 18px;
}

.feedback-rail {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 8px;
}

.feedback-rail span {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  min-height: 42px;
  padding: 7px 5px;
  text-align: center;
}

.feedback-rail span.active {
  color: #09110c;
}

[data-led="connected"].active {
  background: var(--blue);
  box-shadow: 0 0 20px rgba(111, 168, 255, 0.45);
}

[data-led="playing"].active {
  background: var(--green);
  box-shadow: 0 0 20px rgba(120, 214, 109, 0.45);
}

[data-led="speedup"].active {
  background: var(--amber);
  box-shadow: 0 0 20px rgba(244, 178, 62, 0.45);
}

[data-led="crashed"].active {
  background: var(--coral);
  box-shadow: 0 0 20px rgba(255, 111, 97, 0.45);
}

[data-led="auto"].active {
  background: var(--violet);
  box-shadow: 0 0 20px rgba(177, 140, 255, 0.45);
}

.evidence-list {
  display: grid;
  gap: 8px;
  max-height: 290px;
  overflow: auto;
  padding-right: 2px;
}

.evidence-item {
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 4px solid var(--line-strong);
  border-radius: 6px;
  padding: 10px 12px;
}

.evidence-item.observed {
  border-left-color: var(--green);
}

.evidence-item.derived {
  border-left-color: var(--blue);
}

.evidence-item.inferred {
  border-left-color: var(--amber);
}

.evidence-item.unknown {
  border-left-color: var(--coral);
}

.evidence-item strong {
  color: var(--text);
  display: block;
  font-size: 14px;
  line-height: 1.45;
}

.evidence-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.rubric-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 12px;
}

.rubric-grid div {
  background:
    linear-gradient(180deg, rgba(244, 178, 62, 0.13), rgba(255, 255, 255, 0.04)),
    var(--surface-2);
  border: 1px solid rgba(244, 178, 62, 0.18);
  border-radius: 8px;
  min-height: 108px;
  padding: 14px;
}

.rubric-grid strong {
  color: #ffe1a3;
  display: block;
}

.rubric-grid span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  line-height: 1.55;
  margin-top: 8px;
}

.event-log {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 12px 0 0;
  max-height: 240px;
  overflow: auto;
  padding: 0;
}

.event-log li {
  background: rgba(73, 214, 193, 0.07);
  border: 1px solid rgba(73, 214, 193, 0.14);
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  padding: 9px 10px;
}

@media (max-width: 1120px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    max-width: none;
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "game"
      "hardware"
      "wifi"
      "evidence"
      "rubric"
      "event";
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 18px 14px 14px;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brand-mark {
    flex-basis: 56px;
    height: 56px;
    width: 56px;
  }

  .brand-mark span {
    font-size: 20px;
  }

  h1 {
    font-size: 26px;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    gap: 12px;
    padding: 0 14px 20px;
  }

  .stage-hud,
  .stage-toolbar,
  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .stage-hud,
  .stage-toolbar {
    display: flex;
  }

  .mission-readout,
  .stage-actions,
  .panel-actions {
    justify-content: flex-start;
  }

  .control-cluster {
    align-items: stretch;
    flex-direction: column;
  }

  .wifi-form {
    display: grid;
    grid-template-columns: 1fr;
  }

  .wifi-form label,
  .wifi-form input[name="ssid"],
  .wifi-form input[name="password"],
  .wifi-form > button,
  .wifi-help {
    grid-column: auto;
  }

  .stage-actions button {
    flex: 1 1 100px;
  }

  .game-shell {
    margin: 12px;
    padding: 8px;
  }

  #dpGameFrame {
    height: 420px;
  }

  .feedback-rail,
  .rubric-grid,
  .connection-summary,
  .bridge-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .status-strip,
  .key-grid,
  .bridge-actions,
  .bridge-learn-actions {
    grid-template-columns: 1fr;
  }

  .segmented button,
  .speed-control button,
  .stage-actions button,
  .panel-actions button {
    flex: 1 1 auto;
  }

  #dpGameFrame {
    height: 360px;
  }
}
