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

body {
  overflow: hidden;
  background: #06060f;
  font-family: 'Segoe UI', Arial, sans-serif;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header nav ───────────────────────────────────────────────────────────── */
header {
  flex-shrink: 0;
  z-index: 50;
  background: rgba(4, 4, 20, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(80, 100, 255, 0.25);
  padding: 0.55rem 1rem;
  text-align: center;
}

header a {
  color: rgba(160, 180, 255, 0.85);
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
}

header a:hover { color: #fff; }

main {
  flex: 1;
  min-height: 0;
  position: relative;
}

#game-area {
  position: absolute;
  inset: 0;
}

#canvas {
  display: block;
  /* Fill the game-area div; Three.js setSize(…, false) won't override this */
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  touch-action: none;
}

/* ── HUD ──────────────────────────────────────────────────────────────────── */
#hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px) + 8px);
  left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: clamp(6px, 2vw, 14px);
  pointer-events: none;
  z-index: 10;
}

.hud-chip {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(80, 130, 255, 0.35);
  border-radius: 20px;
  padding: clamp(4px, 1.2vw, 6px) clamp(12px, 3.5vw, 20px);
  font-size: clamp(9px, 2.2vw, 11px);
  color: rgba(140, 175, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 1px;
  min-width: clamp(68px, 18vw, 88px);
  text-align: center;
}

.hud-chip span {
  display: inline;
  font-size: clamp(13px, 3.8vw, 16px);
  font-weight: 700;
  color: #fff;
  margin-left: 5px;
  transition: color 0.4s;
}

#hud-timer-chip.warn span { color: #ffaa00; }
#hud-timer-chip.danger span { color: #ff3333; }

/* ── Shuffle countdown bar ────────────────────────────────────────────────── */
#shuffle-bar-wrap {
  position: absolute;
  top: 90px;
  left: 10%;
  right: 10%;
  height: 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
  pointer-events: none;
  z-index: 10;
}

#shuffle-bar {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #00ccff, #aa44ff);
  box-shadow: 0 0 8px #00ccff88;
  transform-origin: left center;
  transition: background 0.4s;
}

#shuffle-bar.warn  { background: linear-gradient(90deg, #ffaa00, #ff4400);
                     box-shadow: 0 0 8px #ff660088; }

/* ── Hint bar ─────────────────────────────────────────────────────────────── */
#hint-bar {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(100, 150, 255, 0.55);
  font-size: clamp(0.65rem, 2.5vw, 0.78rem);
  letter-spacing: 2px;
  text-transform: uppercase;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Overlay ──────────────────────────────────────────────────────────────── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 5vw, 28px);
  background: rgba(4, 4, 16, 0.82);
  backdrop-filter: blur(6px);
  z-index: 30;
}

#overlay.hidden { display: none; }

#ol-title {
  font-size: clamp(1.8rem, 9vw, 4rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: clamp(3px, 1.5vw, 6px);
  text-transform: uppercase;
  text-shadow: 0 0 20px #00ccff, 0 0 50px #0055aa;
}

#ol-btn {
  background: linear-gradient(135deg, #0088cc 0%, #004488 100%);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: clamp(12px, 3vw, 14px) clamp(32px, 10vw, 48px);
  font-size: clamp(0.85rem, 3vw, 1rem);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 0 24px rgba(0, 180, 255, 0.5), 0 4px 12px rgba(0,0,0,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
  /* large enough to tap comfortably */
  min-height: 48px;
  min-width: clamp(140px, 40vw, 200px);
}

#ol-btn:active { transform: scale(0.96); }

.hidden { display: none !important; }
