:root {
  color-scheme: dark;
  font: 16px/1.45 system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color: #eef8f5;
  background: #101923;
  --paper: #eef8f5;
  --muted: #adc3c8;
  --line: #39535c;
  --gold: #ffce7d;
  --teal: #85e8d2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  background:
    radial-gradient(ellipse at 9% 18%, #1e3d44 0, transparent 52%),
    radial-gradient(ellipse at 95% 78%, #18283a 0, transparent 60%);
}
.station {
  display: grid;
  grid-template-columns: minmax(260px, 330px) minmax(360px, 500px);
  align-items: center;
  justify-content: center;
  gap: clamp(28px, 6vw, 76px);
  min-height: 100svh;
  padding: 30px clamp(18px, 5vw, 56px);
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  color: var(--teal);
  font: 650 .72rem/1.4 ui-monospace, Consolas, monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.pilot { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); box-shadow: 0 0 14px #85e8d299; }
.tag { padding: 3px 6px; border: 1px solid #4d7479; border-radius: 4px; color: #c8e2e2; }
.brief-head, .help-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.help, .help-head button {
  min-height: 44px;
  padding: 6px 11px;
  border: 1px solid #55717b;
  border-radius: 8px;
  background: #263944;
  color: var(--paper);
  font-size: .82rem;
  font-weight: 700;
}
h1 {
  margin: 14px 0 10px;
  font-size: clamp(2.65rem, 5.65vw, 5.1rem);
  line-height: .98;
  letter-spacing: -.067em;
}
.mission { margin: 19px 0 21px; color: #cfdee0; max-width: 33ch; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 15px; font-size: .83rem; color: var(--muted); }
.legend-item { display: inline-flex; gap: 7px; align-items: center; }
.marker {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font: 700 .74rem/1 ui-monospace, Consolas, monospace;
}
.first { color: var(--gold); }
.second { color: var(--teal); }
.console {
  min-width: 0;
  background: #17252e;
  border: 1px solid #3b555e;
  border-radius: 20px;
  padding: clamp(12px, 2.7vw, 24px);
  box-shadow: 0 20px 70px #060b1366;
}
.console-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 13px; }
h2 { margin: 3px 0 0; font-size: clamp(1.02rem, 2.3vw, 1.34rem); line-height: 1.2; }
.counter { color: var(--muted); flex-shrink: 0; font: 600 .75rem/1.2 ui-monospace, Consolas, monospace; }
.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(4px, 1.1vw, 8px);
  padding: clamp(5px, 1.2vw, 10px);
  border: 1px solid #304853;
  border-radius: 12px;
  background: #111d25;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1.17;
  border: 1px solid #334a56;
  border-radius: 9px;
  background: #182933;
  color: #a5bec5;
}
.tile.wall {
  border-color: #243641;
  background: #141f28 radial-gradient(circle, #38515b 1px, transparent 1.5px) center / 12px 12px;
}
.tile svg, .send svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.tile .marker { width: 28px; height: 28px; }
.tile.source { color: var(--teal); background: #193a3e; }
.tile.receiver-first { color: var(--gold); border-color: #866439; }
.tile.receiver-second { color: var(--teal); border-color: #3d7d73; }
button { font: inherit; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 2px solid white; outline-offset: 2px; z-index: 1; }
button.tile {
  color: var(--paper);
  background: #28414d;
  border-color: #5b7b83;
  min-height: 44px;
}
button.tile:hover:not([data-first]):not([data-second]) { background: #345361; }
button.tile svg { transition: transform .14s ease; }
button.tile[data-direction="south"] svg { transform: rotate(90deg); }
.switch-number {
  position: absolute;
  top: 2px;
  left: 4px;
  color: #d2e2e4;
  font: 600 .61rem/1.4 ui-monospace, Consolas, monospace;
}
.tile[data-first] { background-color: #473923; }
.tile[data-second] { background-color: #1b443f; }
.tile[data-first][data-second] { background-image: linear-gradient(135deg, #473923 50%, #1b443f 50%); }
.tile[data-first]::before, .tile[data-second]::after {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font: 700 .64rem/1.15 ui-monospace, Consolas, monospace;
}
.tile[data-first]::before { content: "I"; color: var(--gold); }
.tile[data-second]::after { content: "II"; color: var(--teal); }
.tile[data-first][data-second]::before { right: 18px; }
.actions { display: grid; grid-template-columns: minmax(44px, 1fr) auto auto; gap: 8px; margin-top: 13px; }
.actions button {
  min-width: 44px;
  min-height: 44px;
  border-radius: 8px;
  padding: 7px clamp(7px, 2vw, 15px);
  font-size: .86rem;
  font-weight: 700;
}
.send {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #9df5e1;
  background: var(--teal);
  color: #112c2b;
}
.send:hover { background: #aff4e4; }
.send svg { width: 19px; height: 19px; flex-shrink: 0; }
.reset { background: #263944; color: var(--paper); border: 1px solid #55717b; }
.reset:hover { background: #304952; }
.feedback { margin-top: 12px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 9px; min-height: 83px; }
.feedback p { margin: 0; }
#status { font-weight: 700; font-size: .91rem; }
#detail, #score { margin-top: 4px; color: var(--muted); font-size: .79rem; }
.feedback[data-result="won"] { border-color: #62b7a5; background: #193632; }
.feedback[data-result="lost"] { border-color: #9b7954; }
dialog {
  width: min(430px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  overflow: auto;
  padding: 16px;
  border: 1px solid #55717b;
  border-radius: 12px;
  background: #17252e;
  color: var(--paper);
}
dialog::backdrop { background: #070f18cc; }
dialog ol { padding-left: 22px; }
dialog li + li { margin-top: 6px; }
dialog p { margin-bottom: 0; }
@media (min-width: 980px) and (max-height: 660px) {
  .station { padding-block: 8px; }
}
@media (max-width: 750px) {
  .station { grid-template-columns: minmax(0, 490px); align-content: start; gap: 15px; padding: 18px 12px; }
  .brief { padding: 0 3px; }
  h1 { margin: 8px 0; font-size: clamp(2.08rem, 8.7vw, 3.4rem); }
  h1 br { display: none; }
  .mission { max-width: 44ch; margin: 9px 0; font-size: .87rem; }
  .legend { font-size: .73rem; }
  .legend .marker { width: 19px; height: 19px; }
}
@media (max-width: 750px) and (max-height: 700px) {
  .station { gap: 8px; padding: 8px; }
  .mission { display: none; }
  .console { padding: 10px; }
  .console-head { margin-bottom: 8px; }
  .actions, .feedback { margin-top: 8px; }
  .feedback { min-height: 0; }
}
@media (max-width: 479px) and (max-height: 550px) {
  .station { gap: 6px; }
  .brief { display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 8px; }
  .brief .eyebrow, .legend { display: none; }
  h1 { margin: 0; font-size: clamp(1.25rem, 6vw, 1.8rem); }
  .feedback { padding: 6px 8px; }
}
@media (max-width: 350px) {
  .console { padding: 9px; }
  .tile svg { width: 23px; height: 23px; }
}
@media (min-width: 480px) and (max-height: 540px) and (orientation: landscape) {
  .station { grid-template-columns: minmax(0, 760px); align-content: center; gap: 8px; padding: 6px 10px; }
  .brief { display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 10px; padding: 0; }
  .brief .eyebrow, .mission, .legend, h1 br { display: none; }
  h1 { margin: 0; font-size: clamp(1.25rem, 3.4vw, 2rem); letter-spacing: -.04em; }
  .console {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(244px, 1fr);
    grid-template-areas: "heading board" "actions board" "feedback board";
    grid-template-rows: auto auto 1fr;
    gap: 7px 11px;
    padding: 8px;
  }
  .console-head { grid-area: heading; margin: 0; }
  .board { grid-area: board; gap: 3px; padding: 4px; }
  .tile { aspect-ratio: auto; min-height: clamp(44px, calc((100svh - 122px) / 4), 64px); }
  .tile svg { width: 23px; height: 23px; }
  .actions { grid-area: actions; gap: 5px; margin: 0; }
  .actions button { padding-inline: 6px; }
  .send svg { display: none; }
  .feedback { grid-area: feedback; align-self: start; min-height: 0; margin: 0; padding: 7px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  button.tile svg { transition: none; }
}
