/* =====================================================
   FLING THINGS & PEOPLE — Style Sheet
   ===================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --accent:       #FFD93D;
  --accent2:      #FF6B6B;
  --accent3:      #6BCB77;
  --accent4:      #4D96FF;
  --dark:         #0d0f14;
  --panel-bg:     rgba(10, 12, 20, 0.75);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text:         #f0f0f0;
  --font-display: 'Fredoka One', cursive;
  --font-body:    'Nunito', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0f14;
  font-family: var(--font-body);
  color: var(--text);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* =====================================================
   LOADING SCREEN
   ===================================================== */
#loading-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: radial-gradient(ellipse at 50% 40%, #1a2040 0%, #0a0c16 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease;
}

.loading-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.loading-logo {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 8vw, 5rem);
  line-height: 1.1;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(255, 217, 61, 0.5), 0 4px 0 #b8960a;
  letter-spacing: 2px;
}

.loading-logo span {
  color: var(--accent2);
  text-shadow: 0 0 40px rgba(255, 107, 107, 0.5), 0 4px 0 #b83030;
}

.loading-bar-wrap {
  width: 280px;
  height: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--panel-border);
}

.loading-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent4), var(--accent));
  border-radius: 4px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(77, 150, 255, 0.8);
}

.loading-tip {
  font-size: 0.9rem;
  color: rgba(240, 240, 240, 0.5);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* =====================================================
   START / CLICK TO PLAY OVERLAY
   ===================================================== */
#start-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: radial-gradient(ellipse at 50% 35%, #1a2040 0%, rgba(10,12,22,0.95) 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.start-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 2rem;
}

.start-logo {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  line-height: 1.1;
  color: var(--accent);
  text-shadow: 0 0 60px rgba(255, 217, 61, 0.4), 0 4px 0 #b8960a;
}

.start-logo span { color: var(--accent2); text-shadow: 0 0 60px rgba(255,107,107,0.4), 0 4px 0 #b83030; }

.start-subtitle {
  font-size: 0.85rem;
  color: rgba(240,240,240,0.4);
  text-transform: uppercase;
  letter-spacing: 3px;
  font-weight: 700;
}

#start-btn {
  font-family: var(--font-display);
  font-size: 1.4rem;
  padding: 0.8rem 2.5rem;
  background: var(--accent);
  color: #111;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  letter-spacing: 2px;
  box-shadow: 0 6px 0 #b8960a, 0 0 30px rgba(255,217,61,0.3);
  transition: transform 0.1s, box-shadow 0.1s;
}

#start-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #b8960a, 0 0 40px rgba(255,217,61,0.4); }
#start-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #b8960a; }

.controls-hint {
  display: flex;
  gap: 2rem;
  margin-top: 0.5rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 1rem 1.5rem;
}

.hint-col {
  font-size: 0.8rem;
  line-height: 2;
  color: rgba(240,240,240,0.6);
}

.hint-col b {
  color: var(--accent);
  display: inline-block;
  width: 70px;
  font-weight: 800;
}

/* =====================================================
   HUD
   ===================================================== */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

/* Crosshair */
#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
}

.ch-h {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(255,255,255,0.85);
  transform: translateY(-50%);
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.ch-v {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(255,255,255,0.85);
  transform: translateX(-50%);
  border-radius: 1px;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

.ch-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

#crosshair.hovering .ch-h,
#crosshair.hovering .ch-v { background: var(--accent); }
#crosshair.hovering .ch-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent); }

#crosshair.grabbing .ch-h,
#crosshair.grabbing .ch-v { background: var(--accent4); }
#crosshair.grabbing .ch-dot { background: var(--accent4); box-shadow: 0 0 8px var(--accent4); }

/* HUD panels */
.hud-panel {
  position: absolute;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.5rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  backdrop-filter: blur(8px);
  color: rgba(240,240,240,0.8);
}

#grab-indicator {
  bottom: 28%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.2s;
  color: var(--accent);
  white-space: nowrap;
  border-color: rgba(255, 217, 61, 0.3);
}

#grab-indicator.visible { opacity: 1; }

#hold-info {
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 120px;
}

.hold-icon {
  font-size: 1.5rem;
  color: var(--accent4);
}

#hold-name {
  color: white;
  font-size: 0.8rem;
  letter-spacing: 1px;
}

#charge-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  overflow: hidden;
}

#charge-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent4), var(--accent2));
  transition: width 0.05s linear;
  border-radius: 3px;
}

#charge-label {
  font-size: 0.65rem;
  color: rgba(240,240,240,0.4);
  letter-spacing: 1px;
}

#status-panel {
  top: 1rem;
  left: 1.5rem;
  color: var(--accent3);
  border-color: rgba(107, 203, 119, 0.25);
}

#game-title-hud {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: rgba(255, 217, 61, 0.5);
  letter-spacing: 4px;
  pointer-events: none;
}

#pause-btn {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: white;
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  cursor: pointer;
  pointer-events: all;
  display: none;
}

/* =====================================================
   MOBILE CONTROLS
   ===================================================== */
#mobile-controls {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 200;
}

#joystick-zone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 50%;
  height: 55%;
  pointer-events: all;
}

#look-zone {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 50%;
  height: 55%;
  pointer-events: all;
  /* debug: border: 1px dashed rgba(255,255,255,0.1); */
}

#joystick-base {
  position: absolute;
  width: 110px;
  height: 110px;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#joystick-knob {
  width: 46px;
  height: 46px;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.9), rgba(77,150,255,0.8));
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

#action-buttons {
  position: absolute;
  right: 1rem;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  pointer-events: all;
}

.action-btn {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: var(--font-body);
  transition: transform 0.1s;
  box-shadow: 0 5px 0 rgba(0,0,0,0.4);
  -webkit-tap-highlight-color: transparent;
}

.action-btn:active { transform: scale(0.92); box-shadow: 0 2px 0 rgba(0,0,0,0.4); }

.action-btn span { font-size: 1.5rem; line-height: 1; }
.action-btn label { font-size: 0.55rem; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; cursor: pointer; }

.grab-btn {
  background: radial-gradient(circle at 35% 35%, #6dd5ff, var(--accent4));
  color: white;
  width: 78px;
  height: 78px;
  box-shadow: 0 6px 0 #2a5eb8;
}

.jump-btn {
  background: radial-gradient(circle at 35% 35%, #ffd97a, var(--accent));
  color: #111;
  box-shadow: 0 5px 0 #b8960a;
}

.sprint-btn {
  background: radial-gradient(circle at 35% 35%, #9dff9d, var(--accent3));
  color: #111;
  box-shadow: 0 5px 0 #3d8c44;
}

/* =====================================================
   PAUSE MENU
   ===================================================== */
#pause-menu {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(10, 12, 20, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pause-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2.5rem 3rem;
}

.pause-inner h2 {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: var(--accent);
  letter-spacing: 4px;
}

.pause-inner button {
  font-family: var(--font-display);
  font-size: 1.1rem;
  padding: 0.7rem 2rem;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  letter-spacing: 2px;
  width: 200px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.4);
  transition: transform 0.1s;
}

.pause-inner button:active { transform: translateY(2px); box-shadow: none; }

#resume-btn { background: var(--accent4); color: white; }
#respawn-btn-menu { background: var(--accent2); color: white; }

/* =====================================================
   UTILITIES
   ===================================================== */
.mobile-only { display: none !important; }

@media (max-width: 768px), (pointer: coarse) {
  .mobile-only { display: flex !important; }
  .controls-hint { display: none; }
  #pause-btn { display: flex !important; align-items: center; justify-content: center; }
}

/* Death flash */
@keyframes deathFlash {
  0% { opacity: 0; }
  30% { opacity: 0.6; }
  100% { opacity: 0; }
}

.death-flash {
  position: fixed;
  inset: 0;
  background: #ff3333;
  pointer-events: none;
  z-index: 800;
  animation: deathFlash 0.6s ease-out forwards;
}

/* Respawn text */
@keyframes respawnAnim {
  0% { opacity: 0; transform: translate(-50%, -60%); }
  20% { opacity: 1; transform: translate(-50%, -50%); }
  80% { opacity: 1; transform: translate(-50%, -50%); }
  100% { opacity: 0; transform: translate(-50%, -40%); }
}

.respawn-text {
  position: fixed;
  top: 38%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent2);
  text-shadow: 0 0 30px rgba(255,107,107,0.7);
  pointer-events: none;
  z-index: 700;
  animation: respawnAnim 1.5s ease forwards;
}

/* Object pickup ring effect */
@keyframes pickupPulse {
  0% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.5); }
}
