/* Reset — zero out margins/padding, use border-box for predictable sizing */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  color-scheme: dark;
}

/* Fullscreen — no scroll, no overflow, no elastic bounce */
html, body {
  position: fixed;
  inset: 0;
  overflow: clip;
  background: #000;
  font-family: Menlo, Consolas, 'Courier New', monospace;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-touch-callout: none;
}

/* Canvas fills the entire viewport behind everything else */
#canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  touch-action: none;
  background: #000;
}

/* Hide audio elements — keep in rendering tree for Web Audio API (Safari needs this) */
audio {
  position: absolute;
  visibility: hidden;
}

/* Playback controls — centered without transform (avoids Safari compositing layer) */
#controls {
  position: fixed;
  inset: 0;
  width: fit-content;
  height: fit-content;
  margin: auto;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 20px 30px;
  background: none;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  transition: opacity 1.0s ease;
  /* Centered by inset:0 + margin:auto */
}

#controls .glyph-btn {
  transition: opacity 0.3s ease, font-size 0.5s ease, min-width 0.5s ease, min-height 0.5s ease;
}

#controls.idle .glyph-btn {
  opacity: 0;
  transition: opacity 1.0s ease, font-size 0.5s ease, min-width 0.5s ease, min-height 0.5s ease;
}

#controls.idle .glyph-btn.current {
  opacity: 1;
  animation: idle-glow 4s ease infinite;
}

@keyframes idle-glow {
  0%, 100% { opacity: 0.85; text-shadow: 0 0 10px rgba(255,255,255,0.6), 0 0 20px rgba(255,255,255,0.3), 0 0 35px rgba(255,255,255,0.1); }
  50% { opacity: 0.55; text-shadow: 0 0 6px rgba(255,255,255,0.3), 0 0 14px rgba(255,255,255,0.15); }
}

/* Glyph grid — JS sets inline grid-template-columns */
#glyph-grid {
  display: grid;
  grid-template-columns: repeat(4, 66px);
  gap: 12px;
  justify-content: center;
}

.glyph-btn {
  pointer-events: auto;
  aspect-ratio: 1;
  font-size: var(--glyph-size, 60px);
  color: rgba(255, 255, 255, 0.2);
  background: none;
  border: none;
  cursor: pointer;
  font-family: system-ui, 'Segoe UI Symbol', 'Apple Symbols', sans-serif;
  font-variant-emoji: text; /* Force text presentation — prevents coloured emoji on mobile */
  text-shadow: 0 0 calc(4px * var(--glow-scale, 1)) rgba(255,255,255,0.1);
  transition: color 0.3s ease, text-shadow 0.3s ease, opacity 0.3s ease,
              font-size 0.5s ease, min-width 0.5s ease, min-height 0.5s ease;
  -webkit-touch-callout: none;
  -webkit-appearance: none;
  appearance: none;
  user-select: none;
}

.glyph-btn:hover {
  color: rgba(255, 255, 255, 0.5);
  text-shadow: 0 0 calc(8px * var(--glow-scale, 1)) rgba(255,255,255,0.3), 0 0 calc(16px * var(--glow-scale, 1)) rgba(255,255,255,0.15);
}

.glyph-btn.current {
  color: rgba(255, 255, 255, 1.0);
  text-shadow: 0 0 calc(12px * var(--glow-scale, 1)) rgba(255,255,255,1.0), 0 0 calc(24px * var(--glow-scale, 1)) rgba(255,255,255,0.7), 0 0 calc(40px * var(--glow-scale, 1)) rgba(255,255,255,0.3);
}

.glyph-btn:focus-visible {
  outline: none;
}

@keyframes glyph-pulse {
  0%, 100% { color: rgba(255,255,255,0.6); text-shadow: 0 0 calc(8px * var(--glow-scale, 1)) rgba(255,255,255,0.5), 0 0 calc(16px * var(--glow-scale, 1)) rgba(255,255,255,0.25); }
  50% { color: rgba(255,255,255,0.25); text-shadow: 0 0 calc(4px * var(--glow-scale, 1)) rgba(255,255,255,0.15); }
}

.glyph-btn.pulse {
  animation: glyph-pulse 0.8s ease infinite;
}

.glyph-btn.arrive {
  color: rgba(255,255,255,1.0);
  text-shadow: 0 0 calc(16px * var(--glow-scale, 1)) rgba(255,255,255,1.0), 0 0 calc(32px * var(--glow-scale, 1)) rgba(255,255,255,0.8), 0 0 calc(50px * var(--glow-scale, 1)) rgba(255,255,255,0.4);
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

/* Scrub bar — floating glyph cursor below the glyph grid */
#scrub-bar {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 40px);
  left: 50%;
  transform: translateX(-50%);
  height: 60px;
  z-index: 5;
  pointer-events: auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  cursor: pointer;
  transition: opacity 1.0s ease, width 0.4s ease;
}

@media (orientation: landscape) {
  #scrub-bar {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }
}

#scrub-cursor {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(-50%, -50%);
  font-size: 28px;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 0 0 6px rgba(255,255,255,0.15), 0 0 14px rgba(255,255,255,0.06);
  pointer-events: none;
  font-family: system-ui, 'Segoe UI Symbol', 'Apple Symbols', sans-serif;
  transition: color 0.2s ease, text-shadow 0.2s ease;
}

#scrub-bar.scrubbing #scrub-cursor,
#scrub-cursor:hover {
  color: rgba(255, 255, 255, 0.7);
  text-shadow: 0 0 8px rgba(255,255,255,0.4), 0 0 18px rgba(255,255,255,0.15);
}

/* Time remaining — top-right corner */
#time-remaining {
  position: fixed;
  top: 40px;
  right: 30px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
}

/* Track list — top-right, below timer */
#track-list {
  position: fixed;
  top: 70px;
  left: 30px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.35);
  pointer-events: none;
  white-space: nowrap;
  z-index: 1;
  line-height: 1.6;
}

#track-list .track-entry {
  transition: color 0.3s ease, text-shadow 0.3s ease;
}

#track-list .track-entry.current {
  color: rgba(255, 255, 255, 1.0);
  text-shadow: 0 0 10px rgba(255,255,255,0.6), 0 0 20px rgba(255,255,255,0.3);
}

/* Playlist navigation arrows — left/right edges, aligned with scrub bar */
.playlist-nav {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 40px);
  height: 60px;
  line-height: 60px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  pointer-events: auto;
  z-index: 5;
  -webkit-user-select: none;
  user-select: none;
  transition: color 0.3s ease, text-shadow 0.3s ease;
  padding: 0 20px;
}

@media (orientation: landscape) {
  .playlist-nav {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  }
}

#playlist-prev {
  left: 0;
}

#playlist-next {
  right: 0;
}

.playlist-nav:hover {
  color: rgba(255, 255, 255, 0.6);
  text-shadow: 0 0 8px rgba(255,255,255,0.3), 0 0 18px rgba(255,255,255,0.12);
}

.playlist-nav:active {
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 12px rgba(255,255,255,0.6), 0 0 24px rgba(255,255,255,0.3);
}

/* Utility class to hide elements. !important overrides ID-level selectors. */
.hidden {
  display: none !important;
}
