:root {
  color-scheme: light;
  --bg: #d0f0f5; /* icy cyber blue */
  --bg-elevated: #e6f9fa;
  --accent-main: #00bcd4; /* cyber cyan */
  --accent-secondary: #d500f9; /* neon magenta */
  --accent-soft: rgba(0, 188, 212, 0.16);
  --danger: #ff1744;
  --text-primary: #083d47;
  --text-secondary: #166f80;
  --border-subtle: rgba(0, 188, 212, 0.2);
  --glow-strong: 0 0 22px rgba(0, 229, 255, 0.55);
  --radius-pill: 999px;
  --transition-fast: 160ms ease-out;
  --transition-med: 260ms ease-out;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

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

#app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  padding: 10px 10px env(safe-area-inset-bottom);
  display: flex;
  flex-direction: column;
  color: var(--text-primary);
  overflow: hidden;
}

/* HUD */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 2px;
  z-index: 10;
}

.logo {
  font-size: 18px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-main);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.6);
}

.logo span {
  color: var(--accent-secondary);
}

.hud-right {
  display: flex;
  gap: 8px;
}

/* Pills */

.pill {
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.9),
      rgba(255, 255, 255, 0.6)
    ),
    rgba(235, 250, 252, 0.96);
  padding: 6px 10px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  min-width: 88px;
}

.pill-small {
  padding: 4px 9px;
  min-width: 70px;
}

.btn-ghost {
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  background: rgba(255, 255, 255, 0.8);
}

.btn-ghost:active {
  transform: scale(0.95);
}

.btn-ghost:hover {
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

.ghost-container {
  position: absolute;
  top: 15%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s ease-in-out;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ghost-visible {
  opacity: 0.95;
  pointer-events: auto;
  animation: floatGhost 6s ease-in-out infinite;
}

.ghost-img {
  width: 140px;
  height: auto;
  filter: drop-shadow(0 0 20px var(--accent-main)) hue-rotate(15deg);
  border-radius: 20px;
  animation: glitch 4s infinite;
}

.ghost-quote {
  margin-top: 16px;
  padding: 8px 14px;
  background: rgba(235, 250, 252, 0.85);
  border: 1px solid var(--accent-main);
  border-radius: 12px;
  font-family: monospace;
  font-size: 11px;
  color: var(--text-primary);
  text-align: center;
  max-width: 220px;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 12px rgba(0, 188, 212, 0.2);
}

@keyframes floatGhost {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, -15px); }
}

@keyframes glitch {
  0%, 100% { opacity: 1; filter: drop-shadow(0 0 20px var(--accent-main)) hue-rotate(15deg); }
  95% { opacity: 1; filter: drop-shadow(0 0 20px var(--accent-main)) hue-rotate(15deg); }
  96% { opacity: 0.8; filter: drop-shadow(0 0 30px var(--accent-secondary)) hue-rotate(90deg) contrast(1.5); }
  97% { opacity: 1; filter: drop-shadow(0 0 20px var(--accent-main)) hue-rotate(15deg); }
}

.pill-wide {
  flex: 0 0 auto;
  min-width: 140px;
}

.pill-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.pill-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.12em;
}

.pill-value {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-main);
}

.pill-sub {
  margin-top: 2px;
}

.pill-sub-label {
  font-size: 9px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.16em;
}

.pill-sub-value {
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--accent-secondary);
}

/* Core area */

.core-area {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.grid {
  position: absolute;
  inset: 8px 2px 12px;
  border-radius: 24px;
  background:
    linear-gradient(
      rgba(255, 255, 255, 0.5),
      rgba(255, 255, 255, 0.3)
    ),
    radial-gradient(
      circle at top,
      rgba(255, 255, 255, 0.5),
      transparent 65%
    ),
    radial-gradient(
      circle at bottom,
      rgba(0, 229, 255, 0.3),
      transparent 70%
    ),
    var(--bg-elevated);
  border: 1px solid rgba(0, 188, 212, 0.2);
  overflow: hidden;
}

.grid::before,
.grid::after {
  content: "";
  position: absolute;
  inset: -100%;
  background-image: linear-gradient(
    rgba(0, 188, 212, 0.15) 1px,
    transparent 1px
  );
  background-size: 32px 32px;
  opacity: 0.7;
}

.grid::before {
  animation: gridScroll 18s linear infinite;
}

.grid::after {
  transform: rotate(90deg);
  animation: gridScroll 26s linear infinite;
  opacity: 0.4;
}

@keyframes gridScroll {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(32px, 32px, 0);
  }
}

.core-container {
  position: relative;
  width: min(76vw, 360px);
  aspect-ratio: 1 / 1;
  max-height: 76vh;
}

/* Core */

.core-ring {
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 188, 212, 0.2),
    0 0 40px rgba(0, 229, 255, 0.4);
}

.core-ring-inner {
  inset: 27%;
  border-style: solid;
  border-color: rgba(213, 0, 249, 0.6);
  opacity: 0.8;
  animation: rotateSlow 24s linear infinite;
}

.core-ring-outer {
  inset: 9%;
  animation: rotateSlowReverse 28s linear infinite;
}

@keyframes rotateSlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes rotateSlowReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

.core {
  position: absolute;
  inset: 35%;
  border-radius: 50%;
  background: radial-gradient(
    circle at top,
    rgba(224, 255, 255, 1),
    rgba(0, 229, 255, 0.95) 55%,
    rgba(213, 0, 249, 0.9) 100%
  );
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.core::before {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.26);
  mix-blend-mode: screen;
  opacity: 0.85;
}

.core-glow {
  position: absolute;
  width: 160%;
  height: 160%;
  background: conic-gradient(
    from 0deg,
    rgba(255, 255, 255, 0.6),
    rgba(0, 229, 255, 0.4),
    rgba(255, 255, 255, 0.6)
  );
  opacity: 0.8;
  animation: spinGlow 12s linear infinite;
}

@keyframes spinGlow {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.core-symbol {
  position: relative;
  font-size: 30px;
  color: var(--accent-main);
  text-shadow:
    0 0 10px rgba(255, 255, 255, 0.9),
    0 0 14px rgba(0, 229, 255, 0.9);
}

/* Core pulse halo */

.core-pulse {
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(0, 229, 255, 0.5),
    transparent 70%
  );
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
}

/* Nodes */

.node {
  position: absolute;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 255, 0.6);
  background: radial-gradient(
      circle at top left,
      rgba(255, 255, 255, 0.95),
      rgba(224, 255, 255, 0.9)
    ),
    rgba(235, 250, 252, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--text-primary);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-align: center;
  outline: none;
  cursor: pointer;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.6),
    0 0 18px rgba(0, 229, 255, 0.5);
  transition:
    transform var(--transition-fast),
    box-shadow var(--transition-fast),
    border-color var(--transition-fast),
    background var(--transition-fast);
}

.node-label {
  opacity: 0.9;
}

.node::before {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  opacity: 0.8;
}

.node::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 229, 255, 0.06);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.2);
}

.node-1 {
  top: 5%;
  left: 50%;
  transform: translateX(-50%);
}

.node-2 {
  bottom: 7%;
  left: 11%;
}

.node-3 {
  bottom: 7%;
  right: 11%;
}

.node-4 {
  top: 22%;
  right: -2%;
}

.node:active {
  transform: scale(0.94);
}

.node-active {
  background: radial-gradient(
      circle at center,
      rgba(0, 229, 255, 0.4),
      rgba(224, 255, 255, 1)
    );
  border-color: rgba(213, 0, 249, 0.9);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8),
    0 0 28px rgba(0, 229, 255, 0.8);
}

/* Bottom bar */

.bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 4px;
  z-index: 5;
}

.levels {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.level-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.16em;
}

.level-track {
  position: relative;
  height: 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.7);
  overflow: hidden;
}

.level-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: linear-gradient(
    90deg,
    rgba(0, 229, 255, 0.4),
    rgba(213, 0, 249, 0.9),
    rgba(0, 229, 255, 0.9)
  );
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.8);
  transition: width 260ms ease-out;
}

.level-markers {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 10%;
}

.marker {
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.22);
  opacity: 0.6;
}

.level-name {
  font-size: 11px;
  color: var(--accent-secondary);
  text-transform: lowercase;
  letter-spacing: 0.14em;
}

/* Floating chip */

.floating-chip {
  position: absolute;
  left: 50%;
  bottom: 72px;
  transform: translateX(-50%);
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(230, 249, 250, 0.98);
  border: 1px solid rgba(0, 188, 212, 0.6);
  color: var(--text-secondary);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
  pointer-events: none;
  opacity: 0;
  transition:
    opacity 320ms ease-out,
    transform 320ms ease-out;
}

.floating-chip-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(-6px);
}

/* Particles */

.particle {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.9;
  background: radial-gradient(
    circle,
    rgba(0, 229, 255, 1),
    rgba(213, 0, 249, 0.4),
    transparent 65%
  );
  transform: translate(-50%, -50%);
  animation: rise 580ms ease-out forwards;
}

@keyframes rise {
  0% {
    transform: translate(-50%, -20%) scale(0.8);
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -80%) scale(1.25);
    opacity: 0;
  }
}

/* Core pulse animation class */

.core-pulse-active {
  animation: corePulse 380ms ease-out;
}

@keyframes corePulse {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  40% {
    opacity: 1;
    transform: scale(1.1);
  }
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}

/* Responsive tweaks */

@media (max-height: 640px) {
  .core-container {
    width: min(70vw, 320px);
  }

  .node {
    width: 64px;
    height: 64px;
    font-size: 10px;
  }

  .core-symbol {
    font-size: 26px;
  }
}