/* Echo Heist · Midnight Museum Pixel Edition — Shadow DOM Scoped Formal Styles */
body { margin: 0; background: #fff9ed; }

.g-echo {
  container: echo / inline-size;
  --ink: #272219;
  --paper: #fff9ed;
  --card: #fffdf7;
  --muted: #6f6659;
  --line: #d9d1c0;
  --accent: #1b2234;
  position: relative;
  box-sizing: border-box;
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Hiragino Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.g-echo:focus { outline: none; }
.g-echo *, .g-echo *::before, .g-echo *::after { box-sizing: border-box; }
.g-echo button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
.g-echo button:disabled { cursor: default; opacity: .42; }
.g-echo button:focus-visible, .g-echo summary:focus-visible { outline: 3px solid #337a9f; outline-offset: 2px; }
.g-echo .hidden { display: none !important; }

/* Museum Wings & Stage Strip */
.g-echo .eh-wing-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.g-echo .eh-wing-btn {
  flex: 1;
  min-width: 150px;
  text-align: left;
  padding: 9px 12px;
  border-radius: 13px;
  border: 1.5px solid var(--line);
  background: var(--card);
  transition: border-color .15s, background .15s, transform .12s;
}

.g-echo .eh-wing-btn:hover {
  border-color: #9ca59a;
  transform: translateY(-1px);
}

.g-echo .eh-wing-btn.active {
  background: #1b2234;
  border-color: #1b2234;
  color: #fff8e8;
}

.g-echo .eh-wing-btn strong {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: .01em;
}

.g-echo .eh-wing-btn small {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--muted);
}

.g-echo .eh-wing-btn.active small {
  color: #b5c2db;
}

.g-echo .eh-stage-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.g-echo .eh-stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--card);
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 700;
  transition: background .14s, border-color .14s, transform .12s;
}

.g-echo .eh-stage-pill:hover { border-color: var(--ink); }

.g-echo .eh-stage-pill.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--card);
}

.g-echo .eh-stage-pill.cleared {
  border-color: #5ea380;
  background: #eaf5ee;
}

.g-echo .eh-stage-pill.cleared.active {
  background: #234d39;
  border-color: #234d39;
  color: var(--card);
}

.g-echo .eh-pill-stars {
  font-size: 10px;
  letter-spacing: -1px;
  color: #c99116;
}

.g-echo .eh-stage-pill.active .eh-pill-stars { color: #f5c542; }

/* Responsive 2-column layout via container query */
.g-echo .eh-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

@container echo (min-width: 860px) {
  .g-echo .eh-layout {
    grid-template-columns: minmax(0, 1.32fr) minmax(300px, .68fr);
    gap: 20px;
  }
}

/* Museum Pixel Viewport */
.g-echo .eh-stage {
  position: relative;
  border-radius: 20px;
  background: #181d2c;
  border: 2px solid #2b344d;
  color: #f4efe2;
  padding: 15px;
  box-shadow: 0 10px 28px rgba(18, 22, 36, 0.14);
  overflow: hidden;
}

.g-echo .eh-stage-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.g-echo .eh-stage-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 800;
  color: #f5c542;
}

.g-echo .eh-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #eb4b4b;
  box-shadow: 0 0 8px #eb4b4b;
  animation: ehBlink 1.2s infinite;
  flex-shrink: 0;
}

@keyframes ehBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.28; }
}

.g-echo .eh-stage-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 11px;
  font-weight: 700;
  color: #aebad4;
}

.g-echo .eh-chip {
  padding: 3px 8px;
  border-radius: 99px;
  background: #232c42;
  border: 1px solid #354263;
  color: #dce6fa;
}

.g-echo .eh-chip.key-ok {
  background: #1b3d2e;
  border-color: #39d98a;
  color: #a6ffd0;
}

.g-echo .eh-chip.key-need {
  background: #3d2e17;
  border-color: #f5c542;
  color: #fff0a6;
}

.g-echo .eh-canvas-wrap {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 14px;
  overflow: hidden;
  background: #111521;
  border: 1.5px solid #2b3550;
  padding: 6px;
}

.g-echo .eh-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: manipulation;
  max-width: 100%;
  height: auto;
}

/* Victory / Replay Theater Overlay */
.g-echo .eh-win-overlay {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 13px 15px;
  border-radius: 14px;
  background: rgba(16, 21, 34, 0.94);
  border: 1.5px solid #f5c542;
  color: #fff8e8;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
}

.g-echo .eh-win-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.g-echo .eh-win-title {
  font-size: 15px;
  font-weight: 850;
  color: #fff0a6;
  margin: 0;
}

.g-echo .eh-win-stars {
  font-size: 16px;
  letter-spacing: 2px;
  color: #f5c542;
}

.g-echo .eh-win-sub {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5ec;
}

.g-echo .eh-win-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.g-echo .eh-win-btn {
  min-height: 36px;
  padding: 6px 13px;
  border-radius: 10px;
  border: 1.5px solid #3c4b6e;
  background: #232c42;
  color: #fff8e8;
  font-size: 12px;
  font-weight: 750;
}

.g-echo .eh-win-btn.primary {
  background: #f5c542;
  border-color: #f5c542;
  color: #121624;
}

.g-echo .eh-win-btn:hover { filter: brightness(1.08); }

/* VHS Tape Timeline Scrubber */
.g-echo .eh-timeline {
  margin-top: 12px;
  padding: 11px 12px;
  border-radius: 14px;
  background: #121624;
  border: 1.5px solid #2a334d;
  color: #f4f1e6;
}

.g-echo .eh-tl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 750;
  color: #9fb0d0;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.g-echo .eh-tl-strip {
  display: grid;
  gap: 4px;
}

.g-echo .eh-tl-slot {
  appearance: none;
  border: 1px solid #2b3654;
  border-radius: 9px;
  padding: 5px 2px;
  text-align: center;
  font-size: 10px;
  background: #1a2134;
  color: #c2cee8;
  transition: background .12s, border-color .12s, transform .1s;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.g-echo .eh-tl-slot:hover {
  border-color: #4ee6ff;
  background: #222d47;
}

.g-echo .eh-tl-slot.now {
  background: #f5c542;
  border-color: #fff0a6;
  color: #121624;
  font-weight: 900;
  transform: translateY(-1px);
}

.g-echo .eh-tl-slot.scrub {
  border-color: #4ee6ff;
  box-shadow: 0 0 0 2px rgba(78, 230, 255, 0.35);
}

.g-echo .eh-tl-slot.past {
  background: #232d45;
  color: #8f9fba;
}

.g-echo .eh-tl-beat {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  font-weight: 800;
}

.g-echo .eh-tl-icons {
  font-size: 10px;
  line-height: 1.1;
  min-height: 14px;
  display: flex;
  gap: 2px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.g-echo .eh-tl-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.g-echo .eh-tl-dot.red { background: #eb4b4b; }
.g-echo .eh-tl-dot.blue { background: #3b9eff; }
.g-echo .eh-tl-dot.gold { background: #f5c542; }
.g-echo .eh-tl-dot.bell { background: #fff0a6; box-shadow: 0 0 4px #fff0a6; }
.g-echo .eh-tl-dot.swap { background: #c084fc; }
.g-echo .eh-tl-dot.swap2 { background: #39d98a; }

.g-echo .eh-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: #aebad4;
  margin-top: 10px;
}

.g-echo .eh-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.g-echo .eh-legend em { font-style: normal; }

.g-echo .eh-leg-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

/* Right Control Panel */
.g-echo .eh-panel {
  min-width: 0;
  padding: 15px;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: var(--card);
}

.g-echo .eh-stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.g-echo .eh-stat {
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: #f5f2e8;
  border: 1px solid var(--line);
}

.g-echo .eh-stat small {
  display: block;
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.g-echo .eh-stat b {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.g-echo .eh-feedback {
  min-height: 54px;
  margin: 0 0 11px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f5f2e8;
  border: 1.5px solid #dfd7c4;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink);
}

.g-echo .eh-feedback.good {
  background: #e6f4ea;
  border-color: #8cc49e;
  color: #1b4b2e;
}

.g-echo .eh-feedback.bad {
  background: #fdeae5;
  border-color: #e49786;
  color: #8f2d1c;
}

.g-echo .eh-rewind-btn {
  width: 100%;
  min-height: 46px;
  border-radius: 13px;
  border: 2px solid #1b2234;
  background: linear-gradient(180deg, #25304a 0%, #161d2e 100%);
  color: #4ee6ff;
  font-size: 13.5px;
  font-weight: 850;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 9px;
  box-shadow: 0 4px 12px rgba(22, 29, 46, 0.16);
  transition: transform .12s, filter .12s;
}

.g-echo .eh-rewind-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.12);
}

.g-echo .eh-rewind-btn.pulse {
  border-color: #db6446;
  color: #fff0a6;
  background: linear-gradient(180deg, #c94a38 0%, #962f21 100%);
}

.g-echo .eh-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  max-width: 244px;
  margin: 10px auto 12px;
}

.g-echo .eh-pad button {
  min-height: 48px;
  border-radius: 12px;
  border: 1.5px solid #c5cbc1;
  background: #f5f4ec;
  font-size: 17px;
  font-weight: 850;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: transform .1s, background .12s, border-color .12s;
}

.g-echo .eh-pad button:hover:not(:disabled) {
  border-color: var(--ink);
  background: #eceae0;
}

.g-echo .eh-pad button:active:not(:disabled) { transform: scale(0.95); }

.g-echo .eh-pad button small {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--muted);
}

.g-echo .eh-pad .up { grid-column: 2; grid-row: 1; }
.g-echo .eh-pad .left { grid-column: 1; grid-row: 2; }
.g-echo .eh-pad .wait {
  grid-column: 2;
  grid-row: 2;
  background: #fff3c4;
  border-color: #d4a632;
  color: #5e4408;
  font-size: 12.5px;
}
.g-echo .eh-pad .right { grid-column: 3; grid-row: 2; }
.g-echo .eh-pad .down { grid-column: 2; grid-row: 3; }

.g-echo .eh-tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}

.g-echo .eh-tool-btn {
  min-height: 38px;
  padding: 6px 9px;
  border-radius: 11px;
  border: 1.5px solid #cbd1c7;
  background: transparent;
  font-size: 11.5px;
  font-weight: 750;
  color: var(--ink);
  transition: background .12s, border-color .12s;
}

.g-echo .eh-tool-btn:hover:not(:disabled) {
  background: #f0eee5;
  border-color: var(--ink);
}

.g-echo .eh-echo-roster {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
}

.g-echo .eh-echo-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #f3f2e8;
  border-left: 4px solid #4ee6ff;
  font-size: 11.5px;
}

.g-echo .eh-echo-card.e2 { border-left-color: #a855f7; }
.g-echo .eh-echo-card.e3 { border-left-color: #e59c12; }
.g-echo .eh-echo-card.empty {
  border-left-color: #cfd4c9;
  color: var(--muted);
  background: #faf9f2;
}

.g-echo .eh-hint-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fff6d9;
  border: 1.5px solid #ddb752;
  font-size: 12px;
  line-height: 1.6;
  color: #4f3a08;
}

.g-echo .eh-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.g-echo .eh-toggle {
  min-height: 33px;
  padding: 5px 10px;
  border-radius: 9px;
  border: 1.5px solid var(--line);
  background: #f8f5ec;
  font-size: 11.5px;
  font-weight: 700;
}

.g-echo .eh-toggle[aria-pressed="true"] {
  background: #fff3c4;
  border-color: #c9a13a;
}

.g-echo .eh-help {
  margin-top: 11px;
  font-size: 12px;
  line-height: 1.65;
  color: #5c5244;
}

.g-echo .eh-help summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.g-echo .eh-help ol {
  margin: 8px 0 0;
  padding-left: 18px;
}

.g-echo .eh-help li + li { margin-top: 4px; }

.g-echo .eh-keys-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

/* Celebration confetti scoped to stage */
.g-echo .eh-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 6;
}

.g-echo .eh-confetti i {
  position: absolute;
  top: 12%;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  animation: ehFall 1.05s ease-in forwards;
}

@keyframes ehFall {
  to { transform: translate(var(--dx), 360px) rotate(320deg); opacity: 0; }
}

/* Reduced motion */
.g-echo.still .eh-rec-dot,
.g-echo.still .eh-confetti i {
  animation: none !important;
}

.g-echo.still * {
  transition-duration: .01ms !important;
}

@container echo (max-width: 640px) {
  .g-echo { padding: 10px; }
  .g-echo .eh-wing-btn {
    min-width: 0;
    padding: 7px 9px;
  }
  .g-echo .eh-wing-btn strong {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 11px;
    line-height: 1.3;
  }
  .g-echo .eh-wing-btn small { display: none; }
  .g-echo .eh-stage { padding: 11px; }
  .g-echo .eh-pad { max-width: 226px; }
  .g-echo .eh-pad button { min-height: 44px; }
  .g-echo .eh-tl-slot { min-height: 38px; }
  .g-echo .eh-keys-note { display: none; }
}
