/* The painted scene can keep its dusk palette in projection; every essential
   label sits on a solid surface whose palette is independent of the site theme. */
.echo-shell {
  --echo-paper: #f9f8ed;
  --echo-ink: #182c38;
  --echo-muted: #344651;
  --echo-edge: #9aaeb0;
  --echo-selected: #c4f3e4;
  --echo-selected-ink: #12312b;
  --echo-pass: #145142;
  --echo-fail: #792c1b;
  container-type: inline-size;
}
.echo-shell[data-display=screen] {
  --echo-paper: #152630;
  --echo-ink: #f5faf5;
  --echo-muted: #d2e5e4;
  --echo-edge: #7c9399;
  --echo-selected: #214b43;
  --echo-selected-ink: #e2fff3;
  --echo-pass: #a5f4d4;
  --echo-fail: #ffc9a9;
}
.echo-shell dl, .echo-shell dd { margin: 0; }
.echo-shell .puzzle-toolbar { flex-shrink: 0; }
.echo-world {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 17px 20px 15px;
  background: #19333e url('/games/echo/summit.webp') center 60% / cover;
  color: var(--echo-ink);
}
.echo-world::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(0deg, #061828bb, transparent 62%);
  pointer-events: none;
}
.echo-brief, .echo-status, .echo-report, .echo-receiver h3, .echo-readout {
  border: 1px solid var(--echo-edge);
  background: var(--echo-paper);
  box-shadow: 0 5px 17px #06172552;
}
.echo-brief {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, .95fr);
  align-items: center;
  gap: 16px;
  border-radius: 14px;
  padding: 12px 17px;
}
.echo-brief p { margin: 0 0 5px; color: var(--echo-muted); font-size: 13px; font-weight: 600; }
.echo-brief h2 {
  color: var(--echo-ink);
  margin: 0;
  font: 700 clamp(23px, 2.85cqw, 36px)/1.16 var(--font-sans);
  overflow-wrap: break-word;
}
.echo-targets { display: grid; grid-template-columns: 1.22fr 1.04fr .8fr; gap: 6px; }
.echo-targets > div { padding-left: 14px; border-left: 1px solid var(--echo-edge); }
.echo-targets dt { font-size: clamp(13px, 1.25cqw, 17px); color: var(--echo-muted); font-weight: 600; line-height: 1.18; }
.echo-targets dd { margin-top: 3px; font-size: clamp(21px, 2.45cqw, 34px); font-weight: 700; line-height: 1.16; font-variant-numeric: tabular-nums; }
.echo-field { position: relative; isolation: isolate; display: grid; align-items: end; overflow: hidden; border-radius: 12px; }
.echo-receivers { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.echo-receiver { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; }
.echo-receiver h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--echo-ink);
  font: 700 clamp(14px, 1.68cqw, 23px)/1.25 var(--font-sans);
  border-radius: 10px;
  padding: 7px 10px;
}
.echo-receiver h3 span {
  display: grid;
  place-items: center;
  height: 27px;
  width: 27px;
  flex: 0 0 27px;
  border-radius: 6px;
  color: #fff4d8;
  background: #573927;
  font-size: 15px;
}
.echo-instrument {
  display: grid;
  place-items: end center;
  position: relative;
  height: clamp(112px, 14.5cqw, 210px);
  min-height: 0;
}
.echo-instrument::before {
  content: '';
  position: absolute;
  width: 54%;
  height: 13%;
  inset: auto 23% 3%;
  background: radial-gradient(ellipse, #101319e0, #10131900 71%);
  pointer-events: none;
}
.echo-receiver[data-locked-on=true] .echo-instrument > svg {
  filter: drop-shadow(0 0 12px #60eac2d9) drop-shadow(1px 3px 5px #06162775);
}
.echo-lock path { fill: none; stroke-linecap: round; }
.echo-lock-halo { stroke: #0b2b2c; stroke-width: 8; }
.echo-lock-arc { stroke: #8bf5d3; stroke-width: 4.5; }
.echo-lock-dot { fill: #c6ffe9; stroke: #0b2b2c; stroke-width: 3; }
.echo-lock > g { animation: echo-lock-pulse 1.5s ease-in-out infinite; }
@keyframes echo-lock-pulse { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }
.echo-reduced .echo-lock > g { animation: none; }
@media (prefers-reduced-motion: reduce) { .echo-lock > g { animation: none; } }
.echo-instrument > svg { display: block; z-index: 1; width: 100%; height: 100%; filter: drop-shadow(1px 3px 5px #06162775); }
.echo-readout { border-radius: 10px; overflow: hidden; }
.echo-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.echo-modes button, .echo-mode-label {
  min-height: 42px;
  font: 650 clamp(14px, 1.55cqw, 20px)/1.2 var(--font-sans);
  color: var(--echo-ink);
  background: var(--echo-paper);
}
.echo-modes button { border: 0; padding: 4px 1px; cursor: pointer; appearance: none; }
.echo-modes button + button { border-left: 1px solid var(--echo-edge); }
.echo-modes button[aria-pressed=true], .echo-mode-label {
  background: var(--echo-selected);
  color: var(--echo-selected-ink);
  box-shadow: inset 0 -3px var(--echo-pass);
}
.echo-modes button:hover { box-shadow: inset 0 -3px var(--echo-pass); }
.echo-modes button:focus-visible { outline: 3px solid var(--echo-pass); outline-offset: -3px; }
.echo-mode-label { display: grid; place-items: center; margin: 0; }
.echo-counts { display: grid; grid-template-columns: 1.45fr .85fr .67fr; border-top: 1px solid var(--echo-edge); }
.echo-counts > div { text-align: center; padding: 6px 2px; min-width: 0; }
.echo-counts > div + div { border-left: 1px solid var(--echo-edge); }
.echo-counts dt { font: 600 clamp(12px, 1.15cqw, 17px)/1.19 var(--font-sans); color: var(--echo-muted); }
.echo-counts dd { margin-top: 3px; font-size: clamp(20px, 2.2cqw, 32px); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.08; }
.echo-status { margin: 0; padding: 9px 14px; border-radius: 10px; font-weight: 650; font-size: clamp(14px, 1.5cqw, 20px); }
.echo-sweep {
  position: absolute;
  pointer-events: none;
  inset: 0 auto 0 0;
  width: 22%;
  background: linear-gradient(90deg, #45ffd600, #45ffd622 82%, #b9ffec99);
  border-right: 2px solid #caffec;
  animation: echo-sweep 1.34s cubic-bezier(.28,.4,.48,.93) both;
  z-index: 0;
}
@keyframes echo-sweep { from { transform: translateX(-101%); } to { transform: translateX(459%); } }
.echo-report { border-radius: 12px; padding: 11px 14px; line-height: 1.25; }
.echo-report h3 { margin: 0 0 9px; color: var(--echo-ink); font: 700 clamp(23px, 2.4cqw, 34px)/1.18 var(--font-sans); }
.echo-report[data-result=success] h3 { color: var(--echo-pass); }
.echo-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.echo-metrics > div { padding-left: 10px; border-left: 3px solid var(--echo-pass); }
.echo-metrics > div[data-met=false] { border-color: var(--echo-fail); }
.echo-metrics dt { font-weight: 650; font-size: clamp(13px, 1.45cqw, 20px); }
.echo-metrics dd strong { font-size: clamp(22px, 2.4cqw, 38px); line-height: 1.25; font-variant-numeric: tabular-nums; }
.echo-metrics .echo-fraction { font-weight: 600; white-space: nowrap; }
.echo-metrics .echo-goal { display: flex; flex-wrap: wrap; gap: 3px 8px; align-items: center; font-size: clamp(12px, 1.15cqw, 16px); color: var(--echo-muted); font-weight: 600; }
.echo-goal span { display: inline-flex; align-items: center; gap: 3px; color: var(--echo-pass); font-weight: 700; }
.echo-goal span svg { width: 14px; height: 14px; }
[data-met=false] .echo-goal span { color: var(--echo-fail); }
.echo-signal { display: flex; height: 5px; overflow: hidden; margin-top: 10px; border-radius: 4px; }
.echo-signal > span:first-child { background: #31897a; }
.echo-signal > span:last-child { background: repeating-linear-gradient(120deg, #a7602f 0 3px, #de9b64 3px 6px); }
.echo-reflection { margin: 9px 0 0; font-size: clamp(14px, 1.45cqw, 20px); font-weight: 600; line-height: 1.42; }
.echo-reflection strong { color: var(--echo-pass); margin-right: 5px; }
.echo-shell .echo-dock { flex-direction: row; flex-wrap: wrap; justify-content: space-between; padding: 12px 16px; gap: 8px 16px; }
.echo-actions, .echo-power { display: flex; align-items: center; gap: 8px; }
.echo-actions .sprout-primary { min-height: 44px; min-width: 200px; font-size: 17px; padding: 8px 13px; white-space: normal; text-align: center; }
.echo-actions .btn.ghost { min-height: 44px; padding: 8px 13px; text-align: center; white-space: normal; }
.echo-power { color: var(--ink); font-size: 14px; font-weight: 600; }
.echo-power strong { margin-left: 5px; font-size: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.echo-power[data-over=true] { color: var(--echo-fail); border-radius: 6px; background: var(--echo-paper); padding: 2px 5px; }
.echo-hint { width: 100%; margin: 0; padding: 8px 11px; border-radius: 8px; background: var(--echo-paper); color: var(--echo-ink); font-size: 14px; font-weight: 600; }
.echo-setup, .echo-settings, .echo-storage { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 14px; }
.echo-setup { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.echo-setup label { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.echo-setup select { margin: 0; min-height: 40px; max-width: 100%; font-size: 14px; }
.echo-settings summary { font-weight: 650; cursor: pointer; }
.echo-settings p { margin: 10px 0; }
.echo-settings ol { margin: 0; padding-left: 24px; line-height: 1.8; }
.echo-storage p { margin: 0 0 5px; }
.echo-loading { padding: 45px; text-align: center; }
.echo-dialog {
  width: min(580px, calc(100% - 28px));
  max-height: 85dvh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.echo-dialog::backdrop { background: #081b25b3; }
.echo-dialog h2 { margin: 0 0 12px; font-size: 26px; }
.echo-dialog h3 { margin: 14px 0 4px; font: 700 16px var(--font-sans); }
.echo-dialog p { margin: 0; font-size: 15px; line-height: 1.65; }
.echo-dialog > div { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Keep the dock and exit available on short screens. Any overflow belongs to
   the scene, so the four antennas never need a carousel or hidden slide. */
.echo-shell.echo-present {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100%;
  height: 100dvh;
  border: 0;
  border-radius: 0;
}
.echo-present .echo-workspace { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.echo-present .echo-world { min-height: 100%; padding-block: 12px 10px; gap: 10px; }
.echo-present .echo-field { flex: 1; }
.echo-present .echo-instrument { height: clamp(128px, 28dvh, 380px); }
.echo-present:is([data-phase=success], [data-phase=miss]) .echo-instrument { height: clamp(90px, 15dvh, 250px); }
.echo-present .echo-dock { flex-shrink: 0; }
.echo-present .echo-report { padding: 10px 14px; }
.echo-reduced .echo-sweep { animation: none; display: none; }

@media (max-width: 780px) {
  .echo-brief { grid-template-columns: 1fr; gap: 9px; }
  .echo-targets > div { padding-left: 8px; }
  .echo-targets > div:first-child { padding-left: 0; border-left: 0; }
  .echo-receivers { gap: 8px; }
}
@media (max-width: 600px) {
  .echo-world, .echo-present .echo-world { padding: 10px 8px; gap: 9px; }
  .echo-brief { padding: 9px; }
  .echo-brief p { margin-bottom: 2px; }
  .echo-receivers { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px 7px; }
  .echo-receiver h3 { padding: 5px; gap: 5px; }
  .echo-receiver h3 span { height: 22px; width: 22px; flex-basis: 22px; font-size: 13px; }
  .echo-instrument, .echo-present .echo-instrument { height: clamp(78px, 23vw, 152px); }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-instrument { height: clamp(50px, 13vw, 100px); }
  .echo-counts > div { padding: 3px 1px; }
  .echo-modes button, .echo-mode-label { min-height: 40px; }
  .echo-present .echo-mode-label { min-height: 30px; }
  .echo-report { padding: 9px 8px; }
  .echo-metrics { gap: 6px; }
  .echo-metrics > div { padding-left: 5px; }
  .echo-fraction { display: block; font-size: 12px; }
  .echo-shell .echo-dock { gap: 6px; padding: 8px; }
  .echo-actions { width: 100%; }
  .echo-actions .sprout-primary { min-width: 0; flex: 1; font-size: 15px; }
  .echo-actions .btn.ghost { font-size: 13px; }
  .echo-shell .puzzle-toolbar { gap: 6px; padding: 8px; }
  .echo-shell .sprout-spacer { display: none; }
}
@media (max-width: 410px) {
  .echo-shell .puzzle-toolbar > [data-action=fullscreen] > span { display: none; }
  .echo-shell .puzzle-toolbar > [data-action=fullscreen] { width: 40px; justify-content: center; padding: 0; }
  .echo-counts dt { font-size: 12px; }
}
@media (max-height: 590px) and (min-width: 601px) {
  .echo-present .puzzle-toolbar { padding: 5px 12px; }
  .echo-present .echo-world { padding: 6px 10px; gap: 6px; }
  .echo-present .echo-brief { grid-template-columns: minmax(0,1fr) minmax(310px,1fr); gap: 8px; padding: 5px 10px; }
  .echo-present .echo-brief h2 { font-size: 21px; }
  .echo-present .echo-brief p { margin-bottom: 1px; }
  .echo-present .echo-instrument { height: clamp(50px, 16dvh, 95px); }
  /* A side-by-side report leaves all four receivers and the verdict readable
     within a landscape phone's short viewport. */
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-world {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(240px, 1fr);
    grid-template-rows: auto 1fr;
    align-items: start;
  }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-brief {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }
  /* The adjacent report already prints all three targets at this size. */
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-brief .echo-targets { display: none; }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-receivers { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-instrument { height: clamp(24px, 6.5dvh, 57px); }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-readout { display: grid; grid-template-columns: auto minmax(0, 1fr); }
  .echo-present:is([data-phase=success], [data-phase=miss]) .echo-counts { border-top: 0; }
  .echo-present .echo-mode-label { padding: 0 5px; }
  .echo-present .echo-metrics { grid-template-columns: 1fr; gap: 5px; }
  .echo-present .echo-metrics > div { display: grid; grid-template-columns: 1fr auto; gap: 0 4px; }
  .echo-present .echo-metrics dt { align-self: center; }
  .echo-present .echo-metrics .echo-goal { grid-column: 1 / -1; }
  .echo-present .echo-receiver h3 { padding: 3px 5px; }
  .echo-present .echo-receiver h3 span { height: 22px; width: 22px; flex-basis: 22px; }
  .echo-present .echo-counts > div, .echo-present .echo-report { padding-top: 3px; padding-bottom: 3px; }
  .echo-present .echo-mode-label { min-height: 24px; }
  .echo-present .echo-report h3 { font-size: 20px; margin-bottom: 1px; }
  .echo-present .echo-signal { margin-top: 3px; }
  .echo-present .echo-reflection { margin-top: 3px; line-height: 1.26; }
  .echo-shell.echo-present .echo-dock { padding: 5px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .echo-sweep { animation: none; display: none; }
}
