:root {
  --bg-top: #09111f;
  --bg-bottom: #050814;
  --panel: rgba(10, 18, 38, 0.9);
  --panel-border: rgba(140, 214, 255, 0.18);
  --text: #eef7ff;
  --muted: #93a7c9;
  --cyan: #67e8f9;
  --blue: #5b8cff;
  --pink: #ff4fcf;
  --gold: #ffd166;
  --success: #7dffb3;
  --danger: #ff7b8f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(72, 111, 255, 0.2), transparent 34%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
}

button {
  font: inherit;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: center;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  filter: blur(8px);
  opacity: 0.3;
}

.ambient-a {
  width: 240px;
  height: 240px;
  left: -40px;
  top: 6%;
  background: radial-gradient(circle, rgba(103, 232, 249, 0.5), transparent 70%);
}

.ambient-b {
  width: 320px;
  height: 320px;
  right: -80px;
  bottom: 2%;
  background: radial-gradient(circle, rgba(255, 79, 207, 0.35), transparent 72%);
  animation-duration: 12s;
}

.game-frame {
  position: relative;
  z-index: 1;
  width: min(430px, 100%);
  min-height: calc(100vh - 24px);
  padding: 16px;
  border: 1px solid rgba(140, 214, 255, 0.14);
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(18, 30, 62, 0.96), rgba(8, 12, 28, 0.98)),
    rgba(8, 12, 28, 0.92);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.28);
}

.hero-bar,
.hud,
.stage {
  display: grid;
  gap: 16px;
}

.hero-bar {
  grid-template-columns: 1fr;
  align-items: start;
  margin-bottom: 12px;
}

.eyebrow,
.promo-kicker,
.overlay-label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}

h1,
h2,
.hud strong {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  line-height: 0.92;
}

h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.subtitle,
#status-text,
#overlay-message {
  margin: 10px 0 0;
  max-width: 42ch;
  color: var(--muted);
  line-height: 1.45;
}

.hud {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

.hud-card,
.promo-card,
.board-panel,
.side-panel {
  border: 1px solid rgba(147, 167, 201, 0.18);
  background: var(--panel);
  border-radius: 18px;
}

.hud-card {
  padding: 12px 10px;
  text-align: center;
}

.hud-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 8px;
}

.stage {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.board-panel {
  position: relative;
  padding: 14px;
  overflow: hidden;
}

.instruction-row {
  margin-bottom: 10px;
}

.board-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 16px currentColor;
}

.legend-dot.source {
  color: var(--cyan);
  background: var(--cyan);
}

.legend-dot.vault {
  color: var(--pink);
  background: var(--pink);
}

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  aspect-ratio: 1;
  width: min(100%, 330px);
  margin: 0 auto;
  padding: 10px;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(12, 19, 42, 0.95), rgba(7, 12, 28, 0.92)),
    rgba(5, 9, 20, 0.95);
  box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.06);
}

.cell {
  position: relative;
  border: 1px solid rgba(143, 198, 255, 0.16);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 50%, rgba(31, 52, 92, 0.55), transparent 48%),
    linear-gradient(180deg, rgba(19, 33, 67, 0.96), rgba(8, 14, 30, 0.96)),
    rgba(7, 13, 28, 0.98);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.02),
    0 4px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition:
    transform 0.12s ease,
    border-color 0.12s ease;
  touch-action: manipulation;
}

.cell:active {
  transform: scale(0.97);
}

.cell.highlight {
  border-color: rgba(255, 209, 102, 0.9);
  box-shadow:
    0 0 0 2px rgba(255, 209, 102, 0.18),
    inset 0 0 24px rgba(255, 209, 102, 0.08);
}

.cell.completed {
  border-color: rgba(125, 255, 179, 0.7);
}

.cell-path {
  position: absolute;
  inset: 10%;
}

.cell-label {
  position: absolute;
  left: 50%;
  top: 6px;
  transform: translateX(-50%);
  z-index: 2;
  padding: 3px 6px;
  border-radius: 999px;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #07111e;
}

.cell-label.source {
  background: var(--cyan);
}

.cell-label.vault {
  background: var(--pink);
  color: #fff3fb;
}

.direction-hint {
  position: absolute;
  z-index: 2;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(238, 247, 255, 0.52);
  font-size: 0.56rem;
  line-height: 1;
}

.direction-hint.up {
  top: 4px;
  left: calc(50% - 8px);
}

.direction-hint.right {
  right: 4px;
  top: calc(50% - 8px);
}

.direction-hint.down {
  bottom: 4px;
  left: calc(50% - 8px);
}

.direction-hint.left {
  left: 4px;
  top: calc(50% - 8px);
}

.segment {
  position: absolute;
  opacity: 1;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.segment.horizontal {
  left: 8%;
  right: 8%;
  top: calc(50% - 7px);
  height: 14px;
}

.segment.vertical {
  top: 8%;
  bottom: 8%;
  left: calc(50% - 7px);
  width: 14px;
}

.segment.active {
  background:
    linear-gradient(180deg, rgba(231, 247, 255, 0.98), rgba(150, 216, 255, 0.92) 45%, rgba(255, 122, 208, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.35),
    0 0 12px rgba(103, 232, 249, 0.28);
}

.segment.inactive {
  background:
    linear-gradient(180deg, rgba(74, 92, 128, 0.72), rgba(47, 62, 90, 0.7));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.segment::after {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.02));
  opacity: 0.6;
}

.core {
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(248, 252, 255, 1), rgba(91, 140, 255, 0.45));
  box-shadow:
    0 0 10px rgba(91, 140, 255, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.core.source {
  background: radial-gradient(circle, rgba(239, 255, 255, 0.98), rgba(103, 232, 249, 0.68));
  box-shadow: 0 0 12px rgba(103, 232, 249, 0.4);
}

.core.vault {
  background: radial-gradient(circle, rgba(255, 240, 249, 1), rgba(255, 79, 207, 0.72));
  box-shadow: 0 0 12px rgba(255, 79, 207, 0.4);
}

.side-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px;
  gap: 14px;
}

.promo-card {
  padding: 16px;
}

.feature-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.feature-pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.84rem;
}

.cta-button,
.secondary-button {
  border: 0;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.cta-button {
  min-height: 50px;
  padding: 13px 20px;
  border-radius: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #07111e;
  background: linear-gradient(135deg, var(--gold), #ff9f5a 50%, #ff62c0);
  box-shadow: 0 10px 22px rgba(255, 120, 142, 0.18);
}

.cta-button:hover,
.secondary-button:hover,
.cta-button:focus-visible,
.secondary-button:focus-visible {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.cta-button-main {
  width: 100%;
}

.secondary-button {
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.tutorial-callout {
  position: relative;
  z-index: 1;
  max-width: none;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 209, 102, 0.14);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: #ffe7b5;
  font-size: 0.82rem;
  line-height: 1.35;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
}

.tutorial-callout.hidden {
  display: none;
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 8, 20, 0.68);
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(360px, 100%);
  padding: 24px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(18, 30, 62, 0.98), rgba(6, 10, 22, 0.98));
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.3);
  text-align: center;
}

@media (max-width: 480px) {
  .cta-button-top {
    width: 100%;
  }

  .ambient {
    display: none;
  }

  .hud {
    gap: 8px;
  }

  .hud-card {
    padding: 10px 8px;
  }

  .hud-label {
    font-size: 0.68rem;
  }

  .board-header {
    margin-bottom: 8px;
  }

  .legend {
    font-size: 0.76rem;
    padding: 5px 8px;
  }
}
