/* Minimal UI — game is almost all canvas */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: #0a0e17;
  color: #e8eef8;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  cursor: none;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.65rem;
  padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0 max(1rem, env(safe-area-inset-left));
  pointer-events: none;
  z-index: 2;
  font-variant-numeric: tabular-nums;
}

.hud-scores {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
}

.hud-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.hud-block {
  display: flex;
  flex-direction: column;
  min-width: 4.2rem;
}

#run-timer {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.hud-block .label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.55;
}

.hud-block span:last-child {
  font-size: 1.35rem;
  font-weight: 600;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.65);
}

/* Power-up HUD */
.power-hud {
  display: flex;
  gap: 0.45rem;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
  min-width: 0;
}

.power-slot,
.held-queue {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.55rem 0.35rem 0.4rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 23, 0.55);
  backdrop-filter: blur(6px);
  min-height: 2.5rem;
  max-width: 14rem;
}

.held-queue {
  pointer-events: auto;
  cursor: pointer;
}

.held-queue.empty {
  opacity: 0.55;
  cursor: default;
}

.held-queue.ready {
  opacity: 1;
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.25);
  animation: pulse-ready 1.4s ease-in-out infinite;
}

.held-slots {
  display: flex;
  gap: 0.25rem;
}

.inv-slot {
  width: 1.55rem;
  height: 1.55rem;
  display: grid;
  place-items: center;
  border-radius: 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  font-size: 0.85rem;
  line-height: 1;
}

.inv-slot.empty {
  opacity: 0.4;
  font-size: 0.7rem;
}

.inv-slot.filled {
  opacity: 1;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.08);
}

.inv-slot.next {
  border-color: rgba(167, 139, 250, 0.75);
  box-shadow: 0 0 10px rgba(167, 139, 250, 0.35);
}

.power-slot.empty {
  opacity: 0.55;
}

.power-slot.ready {
  opacity: 1;
  border-color: rgba(167, 139, 250, 0.55);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.25);
  animation: pulse-ready 1.4s ease-in-out infinite;
}

.power-slot.active-slot {
  border-color: rgba(125, 211, 252, 0.5);
  background: rgba(20, 40, 70, 0.65);
}

.power-slot[hidden] {
  display: none;
}

.slot-key {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.slot-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.slot-name {
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-timer {
  margin-left: 0.15rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #7dd3fc;
  min-width: 2.4rem;
  text-align: right;
}

@keyframes pulse-ready {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(167, 139, 250, 0.2);
  }
  50% {
    box-shadow: 0 0 18px rgba(167, 139, 250, 0.45);
  }
}

#btn-pause,
#btn-home {
  pointer-events: auto;
  flex-shrink: 0;
}

#btn-home {
  display: grid;
  place-items: center;
  text-decoration: none;
  margin-left: auto;
}

#btn-pause {
  margin-left: 0.35rem;
}

.nav-home {
  margin-top: 0.85rem;
  font-size: 0.8rem;
}

.nav-home a {
  color: #7dd3fc;
  text-decoration: none;
  opacity: 0.85;
}

.nav-home a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Pickup toast — clear feedback when grabbing a power-up */
.pickup-toast {
  position: absolute;
  left: 50%;
  bottom: max(18%, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.15rem 0.75rem 0.85rem;
  border-radius: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(8, 12, 22, 0.88);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45), 0 0 28px var(--pickup-glow, rgba(167, 139, 250, 0.45));
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.22s ease;
  min-width: min(18rem, 88vw);
}

.pickup-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.pickup-toast[hidden] {
  display: none;
}

.pickup-toast.show[hidden] {
  display: flex;
}

.pickup-icon {
  font-size: 1.85rem;
  line-height: 1;
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.pickup-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-align: left;
}

.pickup-text strong {
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.pickup-text span {
  font-size: 0.78rem;
  opacity: 0.8;
}

.pickup-text kbd {
  display: inline-block;
  padding: 0.05rem 0.35rem;
  border-radius: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
}

.power-slot.just-picked,
.held-queue.just-picked {
  animation: pick-pop 0.55s ease;
  border-color: var(--pickup-glow, #a78bfa);
  box-shadow: 0 0 22px var(--pickup-glow, rgba(167, 139, 250, 0.55));
}

@keyframes pick-pop {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

.icon-btn {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 0.5rem;
  background: rgba(10, 14, 23, 0.55);
  color: #e8eef8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: rgba(120, 200, 255, 0.55);
  outline: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(6, 9, 16, 0.72);
  z-index: 3;
  transition: opacity 0.15s ease;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: min(23rem, 100%);
  padding: 1.75rem 1.5rem 1.35rem;
  border-radius: 1rem;
  border: 1px solid rgba(120, 180, 255, 0.22);
  background: linear-gradient(160deg, rgba(18, 28, 48, 0.95), rgba(10, 14, 23, 0.98));
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.panel h1 {
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, #7dd3fc, #a78bfa, #f472b6);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin-top: 0.45rem;
  font-size: 0.9rem;
  opacity: 0.7;
}

.final-score {
  margin-top: 0.85rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.final-score[hidden] {
  display: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 1.35rem;
}

.btn {
  min-width: 7.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: #e8eef8;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.btn:hover,
.btn:focus-visible {
  border-color: rgba(125, 211, 252, 0.55);
  outline: none;
}

.btn.primary {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  border-color: transparent;
  color: #0a0e17;
}

.btn.primary:hover,
.btn.primary:focus-visible {
  filter: brightness(1.08);
}

.btn[hidden] {
  display: none;
}

.hint {
  margin-top: 1.1rem;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  opacity: 0.5;
  line-height: 1.45;
}

.version {
  margin-top: 1rem;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  opacity: 0.4;
  color: #7dd3fc;
}

.power-legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.55rem 0.9rem;
  margin-top: 0.85rem;
  font-size: 0.7rem;
  opacity: 0.65;
}

.power-legend li {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot.speed {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.dot.invuln {
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
}

.dot.wings {
  background: #fbbf24;
  box-shadow: 0 0 6px #fbbf24;
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .power-slot.ready {
    transition: none;
    animation: none;
  }
}

@media (max-width: 520px) {
  #hud {
    flex-wrap: wrap;
  }

  .power-hud {
    order: 3;
    width: 100%;
    justify-content: flex-start;
  }
}
