:root {
  color-scheme: dark;
  --navy: #081a24;
  --navy-frame: #0b222edb;
  --ink: #040e14;
  --cream: #fff4da;
  --muted: #a6c4c6;
  --gold: #ffc65a;
  --gold-glow: #ffc65a44;
  --cyan: #91e9df;
  --cyan-bright: #36ded0;
  --cyan-glow: #91e9df33;
  --coral: #ff7a6b;
  --mint: #6be3b5;
  --border-cyan: #4a828a;
  --border-glow: #5db2bd;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--cream);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Trebuchet MS", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
}

button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  background: none;
}
button:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .65; filter: grayscale(40%); }
[hidden] { display: none !important; }

.ad {
  width: min(100%, 1160px);
  min-height: 100svh;
  padding: clamp(12px, 2vw, 24px);
  display: grid;
  grid-template-columns: .76fr 1.24fr;
  grid-template-rows: auto 1fr auto;
  gap: 14px 28px;
  background: radial-gradient(ellipse at 8% 25%, #18424d 0, transparent 60%), radial-gradient(circle at 85% 85%, #0d2e38 0, transparent 50%), var(--navy);
  position: relative;
  overflow: hidden;
}

.masthead {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
}
.brand {
  width: 175px;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px #00000088);
}
.demo-label {
  font-size: 10px;
  letter-spacing: 1.8px;
  color: var(--cyan);
  border: 1px solid var(--border-cyan);
  background: #0d2e39d9;
  padding: 5px 11px;
  border-radius: 6px;
  font-weight: 800;
  box-shadow: 0 2px 8px #00000044;
}

.intro {
  align-self: center;
  padding-bottom: 10px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 2.8px;
  color: var(--gold);
  font-weight: 800;
  margin: 0 0 10px;
  text-transform: uppercase;
}
h1 {
  font-size: clamp(34px, 5.5vw, 68px);
  line-height: .98;
  letter-spacing: -1.5px;
  margin: 0 0 14px;
  font-weight: 900;
}
h1 span {
  color: var(--gold);
  text-shadow: 0 0 25px var(--gold-glow);
}
.tagline {
  font-size: 14px;
  line-height: 1.5;
  color: #c9dbd8;
  max-width: 350px;
  margin: 0 0 16px;
}

.mode-overview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.mode-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid #37636c;
  background: #0f2733;
  color: var(--muted);
  transition: all .15s ease;
}
.mode-pill.is-active {
  background: var(--gold);
  color: #0c1f26;
  border-color: #fff2cb;
  box-shadow: 0 2px 14px var(--gold-glow);
}
.mode-pill.is-done {
  border-color: var(--mint);
  color: var(--mint);
}

.expedition {
  align-self: center;
  min-width: 0;
  border: 2px solid var(--border-glow);
  border-radius: 18px;
  background: #06151e;
  overflow: hidden;
  box-shadow: 0 20px 60px #010a1199, 0 0 30px #4d8d9622;
  display: flex;
  flex-direction: column;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: #05131a;
  border-bottom: 2px solid #204550;
  padding: 4px;
  gap: 4px;
}
.mode-tab {
  border: 1px solid transparent;
  border-radius: 8px;
  background: #0c242f;
  color: var(--muted);
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .4px;
  text-align: center;
  transition: all .15s ease;
}
.mode-tab:hover {
  color: var(--cream);
  background: #143542;
}
.mode-tab.is-active {
  background: linear-gradient(180deg, #1c4b57, #102d36);
  color: var(--gold);
  border-color: var(--cyan);
  box-shadow: inset 0 1px 0 #91e9df55, 0 0 12px var(--cyan-glow);
}
.mode-tab.is-done::after {
  content: " ✓";
  color: var(--mint);
}

.scene {
  position: relative;
  height: clamp(215px, 37vh, 320px);
  overflow: hidden;
  background: #081a24;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* Authentic Top HUD matching Compose StandardHudHeader */
.hud-top {
  position: absolute;
  top: 7px;
  left: 7px;
  right: 7px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 3;
}
.hud-role-card, .hud-vitals-card, .hud-center-telemetry {
  background: var(--navy-frame);
  border: 1.5px solid var(--border-cyan);
  border-radius: 12px;
  padding: 3px 8px;
  display: flex;
  align-items: center;
  gap: 7px;
  backdrop-filter: blur(5px);
  box-shadow: 0 4px 12px #00000066;
}
.hud-avatar-box {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--cyan-bright);
  box-shadow: 0 0 8px var(--cyan-glow);
  overflow: hidden;
  background: #102e3b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hud-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.hud-role-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hud-role-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hud-leader-pill {
  background: var(--gold);
  color: #0b2028;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 4px;
  letter-spacing: .4px;
}
.hud-mode-title {
  color: var(--cyan);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .5px;
}
.hud-post-line {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--gold);
  font-weight: 700;
}
.hud-mini-icon {
  width: 12px;
  height: 12px;
  object-fit: contain;
}
.hud-center-telemetry {
  padding: 5px 10px;
  border-color: #55919a;
}
.hud-meter {
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .8px;
}
.hud-vitals-card {
  gap: 8px;
}
.hud-hearts {
  display: flex;
  align-items: center;
  gap: 3px;
}
.hud-heart-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: drop-shadow(0 0 4px #ff5040aa);
}
.hud-divider {
  width: 1px;
  height: 18px;
  background: #39636e;
}
.hud-timer-box {
  display: flex;
  align-items: center;
  gap: 5px;
}
.hud-clock {
  font-family: monospace;
  font-size: 13px;
  font-weight: 800;
  color: #ffffff;
}
.hud-actions-top {
  display: flex;
  gap: 5px;
}
.hud-circle-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border-cyan);
  background: var(--navy-frame);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px #00000044;
}
.hud-top-icon {
  width: 15px;
  height: 15px;
  object-fit: contain;
}

/* Voice & Radio Feed */
.hud-feed {
  position: absolute;
  bottom: 8px;
  left: 10px;
  right: 10px;
  background: #051620f0;
  border: 1.5px solid #48818c;
  border-radius: 10px;
  padding: 5px 12px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  box-shadow: 0 4px 16px #00000077;
  z-index: 3;
}
.feed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  flex-shrink: 0;
  box-shadow: 0 0 10px var(--gold);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .45; transform: scale(.85); }
}
#feed-who {
  color: var(--cyan);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  flex-shrink: 0;
}
#feed-text {
  color: var(--cream);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

/* Controls Deck */
.controls {
  padding: 10px 14px;
  background: #081d28;
  border-top: 2px solid #244955;
}
.controls-topline {
  display: grid;
  grid-template-columns: 85px 1fr 220px;
  align-items: center;
  gap: 12px;
}

/* D-Pad Virtual Joystick representation */
.dpad-joystick {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  border: 2px solid #3b6b75;
  background: radial-gradient(circle, #183e4a 20%, #0a1f28 85%);
  box-shadow: inset 0 2px 6px #00000088, 0 4px 12px #00000044;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  align-items: center;
  justify-items: center;
  color: var(--muted);
  font-size: 10px;
  user-select: none;
}
.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-center { grid-column: 2; grid-row: 2; color: var(--cyan); font-size: 12px; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

/* Sync Rhythm Gauge */
.sync-deck {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.sync-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .8px;
}
.sync-title {
  color: var(--cyan);
}
.sync-score {
  color: var(--gold);
  background: #112d38;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid #3d6f78;
}
.timing-track {
  position: relative;
  height: 14px;
  border: 1.5px solid #4a7780;
  border-radius: 8px;
  overflow: hidden;
  background: #0f2732;
  box-shadow: inset 0 2px 5px #00000077;
}
.target-zone {
  position: absolute;
  left: 36%;
  width: 28%;
  height: 100%;
  background: linear-gradient(90deg, #d49526, var(--gold), #d49526);
  box-shadow: 0 0 12px var(--gold);
}
.marker {
  position: absolute;
  height: 100%;
  width: 8px;
  border: 1.5px solid #061822;
  background: #ffffff;
  left: 0;
  border-radius: 3px;
  transform: translateX(-50%);
  box-shadow: 0 0 8px #ffffff;
}
#instruction {
  min-height: 16px;
  line-height: 1.3;
  font-size: 11px;
  text-align: center;
  color: #d8ebe8;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Action Buttons Deck */
.action-buttons-deck {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hud-subactions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}
.sub-btn {
  border: 1.5px solid #3c6e77;
  border-radius: 8px;
  background: #102f3c;
  color: var(--cream);
  padding: 5px 4px;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: all .12s ease;
  min-height: 38px;
}
.sub-btn:hover {
  background: #194657;
  border-color: var(--cyan);
}
.sub-btn.is-highlight {
  background: linear-gradient(180deg, #1d483b, #123126);
  border-color: var(--gold);
  color: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}
.sub-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
}
.sub-text {
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.jump {
  width: 100%;
  border: 1.5px solid #fff0c7;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 900;
  color: #0c2027;
  background: linear-gradient(180deg, #ffd777, var(--gold));
  box-shadow: 0 4px 0 #ab7c2e, 0 6px 18px var(--gold-glow);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition: transform .12s, box-shadow .12s;
  letter-spacing: .4px;
}
.jump:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #ab7c2e;
}
.jump-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}
.jump-arrow {
  font-size: 14px;
}
.control-note {
  text-align: center;
  font-size: 9px;
  color: var(--muted);
  margin: 6px 0 0;
}

/* Footer & CTA */
.footer {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 10px;
  border-top: 1px solid #2b4952;
}
.footer-title {
  font-size: 13px;
  font-weight: 800;
  margin: 0 0 3px;
  color: #f1f8f7;
}
.fineprint {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}
.install {
  flex-shrink: 0;
  background: linear-gradient(180deg, #a7f5eb, var(--cyan));
  color: #092128;
  border: 1px solid #c7fbf5;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 4px 0 #46968d, 0 6px 20px #91e9df44;
  letter-spacing: .5px;
  transition: transform .12s;
}
.install:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #46968d;
}
.install span { margin-left: 8px; }
.exit-status {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 12px;
  color: var(--gold);
  line-height: 1.4;
}

/* End Card Victory Screen */
.result {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, #0e303f, #05131b 90%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 16px;
  z-index: 10;
  animation: fade-result .25s ease-out;
}
@keyframes fade-result {
  from { opacity: 0; transform: scale(.96); }
  to { opacity: 1; transform: scale(1); }
}
.result-brand {
  width: 160px;
  height: auto;
  margin-bottom: 4px;
  object-fit: contain;
}
.result-rollinauts {
  width: 82px;
  height: 82px;
  object-fit: contain;
  filter: drop-shadow(0 6px 14px #00000088);
}
.result h2 {
  font-size: 26px;
  font-weight: 900;
  margin: 6px 0 4px;
  color: var(--gold);
  letter-spacing: -.6px;
  text-shadow: 0 0 20px var(--gold-glow);
}
.result p {
  font-size: 12px;
  line-height: 1.45;
  margin: 0 0 10px;
  max-width: 330px;
  color: #d6ebe7;
}
.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.badge-done {
  font-size: 10px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 12px;
  background: #103440;
  color: var(--mint);
  border: 1px solid var(--mint);
}
.replay {
  border: 1.5px solid var(--cyan);
  border-radius: 9px;
  background: linear-gradient(180deg, #1b4959, #10303b);
  color: var(--cream);
  padding: 9px 20px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 3px 10px #00000055;
  transition: all .15s ease;
}
.replay:hover {
  background: #23586b;
  box-shadow: 0 0 14px var(--cyan-glow);
}

/* Responsive adjustments */
@media (max-width: 760px) {
  .ad {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 520px;
    min-height: 100svh;
    padding: 12px;
  }
  .masthead { min-height: 32px; }
  .brand { width: 130px; max-height: 48px; }
  .demo-label { font-size: 8px; padding: 4px 7px; }
  .intro { padding: 0; }
  .eyebrow { font-size: 9px; margin: 0 0 4px; }
  h1 { font-size: clamp(26px, 8.5vw, 38px); margin: 0 0 6px; }
  h1 br { display: none; }
  h1 span:before { content: " "; }
  .tagline { font-size: 12px; margin: 0 0 8px; max-width: none; }
  .mode-overview { display: none; }
  .expedition { width: 100%; margin: 0; }
  .scene { height: clamp(180px, 31svh, 250px); }
  .hud-center-telemetry { display: none; }
  .hud-actions-top { display: none; }
  .controls-topline { grid-template-columns: 1fr 160px; }
  .dpad-joystick { display: none; }
  .footer { align-items: stretch; flex-direction: column; gap: 8px; padding-top: 8px; }
  .footer-title { font-size: 11px; margin-bottom: 2px; }
  .fineprint { font-size: 8.5px; }
  .install { padding: 10px; font-size: 12px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .ad {
    display: grid;
    max-width: none;
    padding: 8px 16px;
    gap: 6px 16px;
    grid-template-columns: .8fr 1.2fr;
  }
  .masthead { grid-column: 1; grid-row: 1; min-height: 26px; }
  .brand { width: 100px; max-height: 36px; }
  .demo-label { font-size: 7px; padding: 3px 5px; }
  .intro { grid-column: 1; grid-row: 2; padding: 0; align-self: center; }
  .eyebrow { margin-bottom: 3px; font-size: 8px; }
  h1 { font-size: clamp(22px, 4vw, 32px); margin-bottom: 4px; }
  .tagline { font-size: 10px; margin: 0 0 6px; }
  .mode-pill { font-size: 8px; padding: 3px 6px; }
  .expedition { grid-column: 2; grid-row: 1 / 4; margin: 0; }
  .mode-tab { padding: 4px; font-size: 9px; }
  .scene { height: 145px; }
  .hud-top { top: 4px; left: 4px; right: 4px; }
  .hud-avatar-box { width: 24px; height: 24px; }
  .hud-leader-pill { font-size: 7px; padding: 1px 3px; }
  .hud-mode-title { font-size: 9px; }
  .hud-center-telemetry { display: none; }
  .hud-heart-icon { width: 12px; height: 12px; }
  .hud-clock { font-size: 10px; }
  .hud-actions-top { display: none; }
  .hud-feed { bottom: 4px; padding: 3px 6px; font-size: 9px; }
  .controls { padding: 5px 8px; }
  .controls-topline { grid-template-columns: 1fr 140px; gap: 8px; }
  .dpad-joystick { display: none; }
  .sub-btn { min-height: 30px; padding: 2px; }
  .sub-icon { width: 12px; height: 12px; }
  .sub-text { font-size: 8px; }
  .timing-track { height: 10px; }
  .jump { padding: 6px; font-size: 11px; }
  .jump-icon { width: 16px; height: 16px; }
  .control-note { display: none; }
  .footer { grid-column: 1; grid-row: 3; flex-direction: column; align-items: stretch; padding-top: 4px; gap: 4px; }
  .footer-title { font-size: 9px; }
  .fineprint { font-size: 7px; }
  .install { padding: 6px; font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
