:root {
  --ink: #fff6df;
  --muted: rgba(255, 246, 223, 0.76);
  --sand: #ffd98e;
  --ember: #ff8f4d;
  --teal: #67e3df;
  --sea: #0f2438;
  --night: #07111d;
  --glass: rgba(8, 21, 35, 0.72);
  --glass-strong: rgba(8, 21, 35, 0.92);
  --border: rgba(255, 230, 173, 0.18);
  --border-bright: rgba(255, 230, 173, 0.3);
  --shadow: 0 28px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Gill Sans", Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 76% -12%, rgba(255, 156, 76, 0.28), transparent 34rem),
    radial-gradient(circle at 12% 18%, rgba(103, 227, 223, 0.2), transparent 28rem),
    linear-gradient(160deg, #08111b 0%, #0d1b2a 54%, #152c3f 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(16px);
  pointer-events: none;
  opacity: 0.72;
}

body::before {
  width: 22rem;
  height: 22rem;
  top: -8rem;
  right: -4rem;
  background: rgba(255, 147, 77, 0.17);
}

body::after {
  width: 18rem;
  height: 18rem;
  bottom: -6rem;
  left: -3rem;
  background: rgba(88, 219, 213, 0.12);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.page-shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
  position: relative;
  z-index: 1;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.hero-copy,
.legend-card,
.hud-panel,
.control-panel,
.records-panel,
.overlay-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.012));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.hero-copy,
.legend-card,
.control-panel,
.records-panel {
  border-radius: 24px;
  padding: 1.1rem 1.2rem;
}

.hero-copy {
  min-width: 0;
}

.eyebrow,
.overlay-kicker,
.legend-title,
.status-title,
.stat-label {
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.eyebrow,
.overlay-kicker {
  color: var(--sand);
}

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  letter-spacing: 0.02em;
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 6vw, 4.5rem);
  line-height: 0.95;
  margin-top: 0.25rem;
}

h3 {
  font-size: 1rem;
}

.hero-text,
.legend-card p,
.mission-copy p,
#overlayText,
.last-result {
  margin: 0.45rem 0 0;
  color: var(--muted);
  line-height: 1.45;
}

kbd {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 230, 173, 0.22);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.08);
  font-family: "Trebuchet MS", "Gill Sans", Verdana, sans-serif;
  font-size: 0.82em;
}

.legend-title,
.status-title {
  color: var(--teal);
  margin: 0;
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 360px);
  gap: 1rem;
  align-items: start;
}

.play-column {
  display: grid;
  gap: 0.85rem;
  min-width: 0;
}

.hud-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.7rem;
  border-radius: 24px;
  padding: 0.7rem;
}

.stat-chip {
  min-width: 0;
  padding: 0.8rem 0.9rem;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(7, 17, 29, 0.62), rgba(7, 17, 29, 0.42)),
    radial-gradient(circle at 20% 0%, rgba(103, 227, 223, 0.13), transparent 65%);
  border: 1px solid rgba(255, 230, 173, 0.14);
}

.stat-chip strong {
  display: block;
  margin-top: 0.25rem;
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.game-frame {
  position: relative;
  overflow: hidden;
  border-radius: 32px;
  border: 1px solid rgba(255, 235, 190, 0.18);
  box-shadow: var(--shadow);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    linear-gradient(180deg, rgba(9, 20, 31, 0.95), rgba(6, 13, 23, 0.95));
}

#game {
  display: block;
  width: 100%;
  height: clamp(430px, 64vh, 680px);
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 50% 42%, rgba(103, 227, 223, 0.12), transparent 22rem),
    linear-gradient(180deg, rgba(3, 7, 12, 0.24), rgba(3, 7, 12, 0.6));
  transition: opacity 180ms ease, visibility 180ms ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay-card {
  width: min(460px, 100%);
  border-radius: 28px;
  padding: 1.4rem;
  text-align: center;
  background: linear-gradient(180deg, rgba(7, 19, 32, 0.93), rgba(5, 14, 25, 0.97));
  border: 1px solid rgba(255, 228, 173, 0.18);
}

.overlay-card h2 {
  font-size: clamp(2.15rem, 7vw, 3.6rem);
}

.last-result {
  color: var(--sand);
  font-weight: 700;
}

.control-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.mission-copy {
  min-width: 0;
}

.challenge-text {
  color: var(--sand);
  font-weight: 700;
}

.start-button,
.pulse-button,
.ghost-button,
.text-button {
  border: 0;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.04em;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.start-button:hover,
.pulse-button:hover,
.ghost-button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.start-button {
  margin-top: 1rem;
  padding: 0.9rem 1.3rem;
  border-radius: 999px;
  color: #08111b;
  background: linear-gradient(135deg, #ffd289, #ff9859);
  box-shadow: 0 14px 26px rgba(255, 145, 77, 0.28);
}

.pulse-button {
  min-width: 132px;
  min-height: 54px;
  padding: 0.9rem 1rem;
  border-radius: 18px;
  color: #08111b;
  background: linear-gradient(135deg, #8ef4ec, #66cfe2);
  box-shadow: 0 14px 26px rgba(91, 209, 210, 0.22);
}

.pulse-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.records-panel {
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 1rem;
}

.panel-heading {
  display: flex;
  gap: 1rem;
  align-items: start;
  justify-content: space-between;
}

.mini-stats {
  display: grid;
  gap: 0.4rem;
  text-align: right;
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-stats strong {
  color: var(--sand);
}

.pilot-field {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.pilot-field input {
  width: 100%;
  border: 1px solid rgba(255, 230, 173, 0.2);
  border-radius: 16px;
  padding: 0.78rem 0.85rem;
  color: var(--ink);
  background: rgba(5, 14, 25, 0.62);
  outline: none;
}

.pilot-field input:focus {
  border-color: rgba(103, 227, 223, 0.7);
  box-shadow: 0 0 0 3px rgba(103, 227, 223, 0.12);
}

.challenge-banner {
  border: 1px solid rgba(103, 227, 223, 0.26);
  border-radius: 18px;
  padding: 0.85rem;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(103, 227, 223, 0.14), transparent 72%),
    rgba(5, 14, 25, 0.5);
  line-height: 1.45;
}

.record-section {
  display: grid;
  gap: 0.7rem;
}

.record-section h3 {
  color: var(--teal);
}

.record-list {
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.record-item,
.empty-record {
  border: 1px solid rgba(255, 230, 173, 0.13);
  border-radius: 16px;
  padding: 0.75rem;
  background: rgba(5, 14, 25, 0.48);
}

.record-item {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.record-main {
  min-width: 0;
}

.record-title {
  display: block;
  font-weight: 700;
}

.record-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.record-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: #08111b;
  background: linear-gradient(135deg, #ffd289, #ff9859);
  font-size: 0.78rem;
  font-weight: 800;
}

.record-badge.survived {
  background: linear-gradient(135deg, #8ef4ec, #66cfe2);
}

.empty-record {
  color: var(--muted);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.ghost-button,
.text-button {
  border-radius: 999px;
  padding: 0.72rem 0.9rem;
}

.ghost-button {
  color: var(--ink);
  border: 1px solid var(--border-bright);
  background: rgba(255, 255, 255, 0.06);
}

.ghost-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.text-button {
  color: var(--sand);
  background: transparent;
}

@media (max-width: 980px) {
  .hero,
  .app-layout {
    grid-template-columns: 1fr;
  }

  .records-panel {
    position: static;
  }
}

@media (max-width: 640px) {
  .page-shell {
    width: min(100% - 0.8rem, 100%);
    padding: 0.5rem 0 1rem;
  }

  .hero {
    gap: 0.7rem;
    margin-bottom: 0.7rem;
  }

  .hero-copy,
  .legend-card,
  .control-panel,
  .records-panel,
  .hud-panel {
    border-radius: 20px;
  }

  .hero-copy,
  .legend-card,
  .control-panel,
  .records-panel {
    padding: 0.9rem;
  }

  .legend-card {
    display: none;
  }

  .hero-text {
    font-size: 0.93rem;
  }

  .app-layout,
  .play-column {
    gap: 0.65rem;
  }

  .hud-panel {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
    padding: 0.45rem;
  }

  .stat-chip {
    border-radius: 14px;
    padding: 0.55rem 0.45rem;
    text-align: center;
  }

  .stat-label {
    font-size: 0.58rem;
    letter-spacing: 0.08em;
  }

  .stat-chip strong {
    font-size: clamp(0.92rem, 4.5vw, 1.15rem);
  }

  .game-frame {
    border-radius: 24px;
  }

  #game {
    height: min(62svh, 560px);
    min-height: 420px;
  }

  .overlay-card {
    border-radius: 22px;
    padding: 1.05rem;
  }

  .control-panel {
    grid-template-columns: 1fr;
    gap: 0.8rem;
  }

  .pulse-button {
    width: 100%;
    min-height: 56px;
  }

  .panel-heading {
    align-items: end;
  }
}

@media (max-width: 380px) {
  .page-shell {
    width: min(100% - 0.5rem, 100%);
  }

  .stat-chip {
    padding-inline: 0.3rem;
  }

  .stat-label {
    font-size: 0.52rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .start-button,
  .pulse-button,
  .ghost-button,
  .text-button {
    transition: none;
  }
}
