/* ==========================================================
   Poppy 5 3D — Fullscreen First-Person Toy Factory HUD
   ========================================================== */

:root {
  --grab-blue: #29B6F6;
  --grab-blue-dark: #0277BD;
  --grab-red: #FF5252;
  --grab-red-dark: #C62828;
  --gold: #FFD54F;
  --green: #4ADE80;
  --green-dark: #15803D;
  --glass: rgba(15, 23, 48, 0.78);
  --glass-border: rgba(125, 162, 255, 0.35);
  --font-ar: 'Cairo', system-ui, sans-serif;
  --font-en: 'Fredoka', sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ar);
  background: #0D1326;
  color: #F8FAFC;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button, a {
  font-family: inherit;
  color: inherit;
  text-decoration: none;
  border: none;
  background: none;
  cursor: pointer;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.viewport-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.scene-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.scene-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Center Aim Reticle */
.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 5;
  display: grid;
  place-items: center;
}

.reticle-ring {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.65);
  box-shadow: 0 0 10px rgba(41, 182, 246, 0.5);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.reticle-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #FFFFFF;
}

.reticle.is-locked .reticle-ring {
  transform: scale(1.35);
  border-color: var(--gold);
}

/* Top HUD */
.hud-top {
  position: absolute;
  top: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  z-index: 10;
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: auto;
}

.hud-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 2px solid var(--glass-border);
  backdrop-filter: blur(8px);
  font-weight: 800;
  font-size: 0.94rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.back-pill:hover {
  border-color: var(--grab-blue);
}

.title-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 2px solid var(--glass-border);
  backdrop-filter: blur(8px);
  font-weight: 800;
  font-size: 0.95rem;
}

.chapter-tag {
  background: linear-gradient(135deg, var(--grab-blue), var(--grab-red));
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--font-en);
  font-size: 0.82rem;
  font-weight: 700;
  color: #FFFFFF;
}

.objective-pill {
  border-color: rgba(255, 213, 79, 0.65);
  color: #FEF08A;
}

.star-pill {
  border-color: var(--gold);
  color: #FFE082;
  font-size: 1rem;
}

.sound-pill {
  padding: 8px 12px;
}

/* Action Toast */
.action-toast {
  position: absolute;
  top: 118px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 20px;
  border-radius: 999px;
  background: rgba(15, 23, 48, 0.88);
  border: 2px solid var(--green);
  color: #BBF7D0;
  font-weight: 900;
  font-size: 1.05rem;
  z-index: 12;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  text-align: center;
  white-space: nowrap;
}

.action-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(4px);
}

/* Bottom HUD */
.hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
  pointer-events: none;
}

.dpad, .grabpack-dock, .room-progress {
  pointer-events: auto;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.dpad-row {
  display: flex;
  gap: 6px;
}

.dpad-btn {
  width: 50px;
  height: 50px;
  border-radius: 16px;
  background: var(--glass);
  border: 2px solid var(--glass-border);
  backdrop-filter: blur(6px);
  font-size: 1.25rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
}

.dpad-btn:active {
  transform: translateY(3px);
  border-color: var(--gold);
}

/* GrabPack Hand Dock */
.grabpack-dock {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hand-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 18px;
  font-weight: 900;
  font-size: 0.96rem;
  color: #FFFFFF;
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.blue-hand {
  background: linear-gradient(180deg, #38BDF8 0%, var(--grab-blue-dark) 100%);
  box-shadow: 0 5px 0 #01436D;
  border: 2px solid #7DD3FC;
}

.red-hand {
  background: linear-gradient(180deg, #FF6B6B 0%, var(--grab-red-dark) 100%);
  box-shadow: 0 5px 0 #7F1D1D;
  border: 2px solid #FCA5A5;
}

.hand-btn.is-selected {
  transform: translateY(-3px) scale(1.04);
  outline: 3px solid var(--gold);
}

.hand-btn:active {
  transform: translateY(3px);
}

.hand-emoji {
  font-size: 1.35rem;
}

/* Room Progress */
.room-progress {
  background: var(--glass);
  border: 2px solid var(--glass-border);
  border-radius: 18px;
  padding: 8px 14px;
  backdrop-filter: blur(8px);
  text-align: center;
}

.room-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #CBD5E1;
  margin-bottom: 4px;
}

.room-dots {
  display: flex;
  gap: 6px;
}

.r-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  display: grid;
  place-items: center;
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 0.9rem;
}

.r-dot.is-current {
  background: var(--grab-blue);
  border-color: #FFFFFF;
}

.r-dot.is-done {
  background: var(--green);
  border-color: #BBF7D0;
  color: #052E16;
}

/* Overlays */
.overlay-screen {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(20, 30, 64, 0.86) 0%, rgba(9, 13, 28, 0.94) 100%);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 30;
}

.overlay-screen[hidden] {
  display: none;
}

.overlay-panel {
  max-width: 580px;
  width: 100%;
  background: rgba(25, 36, 72, 0.92);
  border: 3px solid #4B65B0;
  border-radius: 30px;
  padding: 28px 26px;
  text-align: center;
  box-shadow: 0 12px 0 #0C1226, 0 30px 60px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.poppy-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(41, 182, 246, 0.2);
  border: 2px solid var(--grab-blue);
  font-family: var(--font-en);
  font-weight: 700;
  font-size: 1rem;
  color: #BAE6FD;
}

.poppy-logo .ch5 {
  background: var(--grab-red);
  color: #FFFFFF;
  padding: 2px 10px;
  border-radius: 999px;
}

.poppy-logo.success {
  font-family: var(--font-ar);
  background: rgba(74, 222, 128, 0.2);
  border-color: var(--green);
  color: #BBF7D0;
}

.poppy-logo.gold {
  font-family: var(--font-ar);
  background: rgba(255, 213, 79, 0.22);
  border-color: var(--gold);
  color: #FEF08A;
}

.overlay-panel h1, .overlay-panel h2 {
  margin: 0;
  font-size: clamp(1.5rem, 3.8vw, 2.2rem);
  font-weight: 900;
}

.overlay-lead {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: #CBD5E1;
  line-height: 1.6;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.tip-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 10px 8px;
  font-size: 0.86rem;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.tip-card span {
  font-size: 1.45rem;
}

.cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 32px;
  border-radius: 20px;
  background: linear-gradient(180deg, #FF6B6B 0%, var(--grab-red-dark) 100%);
  color: #FFFFFF;
  font-size: 1.25rem;
  font-weight: 900;
  box-shadow: 0 6px 0 #7F1D1D;
  transition: transform 0.12s ease;
}

.cta-btn:hover {
  transform: scale(1.03);
}

.cta-btn:active {
  transform: translateY(4px);
}

.cta-btn.cta-green {
  background: linear-gradient(180deg, #4ADE80 0%, var(--green-dark) 100%);
  box-shadow: 0 6px 0 #14532D;
}

.cta-btn.cta-blue {
  background: linear-gradient(180deg, #38BDF8 0%, var(--grab-blue-dark) 100%);
  box-shadow: 0 6px 0 #01436D;
}

.victory-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (max-width: 720px) {
  .tips-grid {
    grid-template-columns: 1fr;
  }
  .hand-btn span:last-child {
    display: none;
  }
  .room-progress {
    display: none;
  }
}
