/* ============================================================
   KRATI'S WORLD — Mini-Game Neumorphic Overlay
   Reuses CSS Variables from style.css
   ============================================================ */

#game-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: var(--bg-light);
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  overflow: hidden;
  font-family: var(--font-body);
}

#game-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Header / HUD */
.game-hud {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

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

.hud-pill {
  background: var(--bg-light);
  box-shadow: var(--neu-light-sm);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-dark);
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  transition: transform 0.2s ease;
}

.hud-pill.pop {
  transform: scale(1.15);
}

.hud-btn {
  background: var(--bg-light);
  box-shadow: var(--neu-light-sm);
  border: none;
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-dark);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.hud-btn:hover {
  transform: translateY(-2px);
  color: var(--blush);
}

.hud-btn:active {
  box-shadow: var(--neu-light-inset);
  transform: translateY(0);
}

/* Canvas Container */
#game-canvas-container {
  flex: 1;
  width: 100%;
  height: 100%;
  position: relative;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Virtual Joystick */
#joystick-area {
  position: absolute;
  bottom: 24px;
  left: 24px;
  width: 130px;
  height: 130px;
  z-index: 10;
  touch-action: none;
  user-select: none;
}

.joystick-base {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--bg-light);
  box-shadow: var(--neu-light-inset);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid rgba(255, 255, 255, 0.5);
}

.joystick-knob {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-light);
  box-shadow: var(--neu-light);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: transform 0.05s linear;
}

/* Controls Hint on Desktop */
.controls-hint {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: var(--bg-light);
  box-shadow: var(--neu-light-sm);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  color: var(--text-dark);
  opacity: 0.85;
  z-index: 10;
  pointer-events: none;
  font-family: var(--font-body);
  font-weight: 600;
}

@media (max-width: 767px) {
  .controls-hint {
    display: none;
  }
}

/* Modals (Love Notes & Ending) */
.game-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 46, 0.6);
  backdrop-filter: blur(8px);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.game-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.game-modal-card {
  background: var(--bg-light);
  box-shadow: var(--neu-light);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  border: 3px solid #fff;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.game-modal-overlay.active .game-modal-card {
  transform: translateY(0) scale(1);
}

.game-modal-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: inline-block;
  animation: floatIcon 2s ease-in-out infinite;
}

@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.game-modal-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  color: var(--text-dark);
  margin: 0 0 14px 0;
}

.game-modal-text {
  font-family: var(--font-body);
  font-size: 1.05rem;
  color: var(--text-dark);
  line-height: 1.6;
  margin: 0 0 24px 0;
  background: var(--bg-soft);
  box-shadow: var(--neu-light-inset);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  font-style: italic;
}

.game-modal-btn {
  background: var(--bg-light);
  box-shadow: var(--neu-light);
  border: none;
  border-radius: var(--radius-pill);
  padding: 12px 28px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  color: var(--blush);
  cursor: pointer;
  transition: all 0.2s ease;
}

.game-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 10px 10px 20px var(--shadow-light-2), -10px -10px 20px var(--shadow-light-1);
}

.game-modal-btn:active {
  box-shadow: var(--neu-light-inset);
  transform: translateY(0);
}

/* Ending Specific Styles */
.ending-card {
  background: var(--bg-dark);
  color: var(--text-light);
  border: 3px solid var(--plum);
  box-shadow: var(--neu-dark);
}

.ending-card .game-modal-title {
  color: var(--gold);
}

.ending-card .game-modal-text {
  background: #231f33;
  box-shadow: var(--neu-dark-inset);
  color: var(--text-light);
}

.ending-card .game-modal-btn {
  background: var(--bg-dark);
  color: var(--gold);
  box-shadow: var(--neu-dark-sm);
}

/* Explore Button in Chapter 8 */
.explore-trigger-wrapper {
  margin-top: 40px;
  text-align: center;
  padding: 20px 0;
}

.explore-trigger-btn {
  background: linear-gradient(135deg, var(--bg-light) 0%, #fef8fa 100%);
  box-shadow: var(--neu-light), 0 0 25px rgba(255, 71, 126, 0.35);
  border: 2.5px solid #ffb3c6;
  border-radius: var(--radius-pill);
  padding: 18px 42px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  transition: all 0.35s cubic-bezier(0.18, 0.89, 0.32, 1.28);
  animation: exploreGlowPulse 2.5s infinite ease-in-out;
}

@keyframes exploreGlowPulse {
  0%, 100% {
    box-shadow: var(--neu-light), 0 0 20px rgba(255, 71, 126, 0.3);
    border-color: rgba(255, 179, 198, 0.8);
  }
  50% {
    box-shadow: var(--neu-light), 0 0 35px rgba(255, 71, 126, 0.7);
    border-color: #ff477e;
  }
}

.explore-trigger-btn:hover {
  transform: translateY(-5px) scale(1.05);
  color: #ff477e;
  box-shadow: 12px 12px 24px var(--shadow-light-2), -12px -12px 24px var(--shadow-light-1), 0 0 45px rgba(255, 71, 126, 0.8);
}

.explore-trigger-btn:active {
  box-shadow: var(--neu-light-inset);
  transform: translateY(0) scale(0.98);
}

/* Smartphone Layout matching user sketch (Stacked top buttons, framed square game display, bottom-left controls) */
@media (max-width: 768px) {
  #game-overlay {
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: center !important;
    padding: 0 !important;
  }

  .game-hud {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }

  .game-hud-left,
  .game-hud-right {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .game-hud-left {
    align-items: flex-start;
  }

  .game-hud-right {
    align-items: flex-end;
  }

  .hud-pill, .hud-btn {
    padding: 6px 12px;
    font-size: 0.78rem;
    border-radius: 20px;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.08);
  }

  #hud-zone-title span {
    max-width: 145px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #game-canvas-container {
    flex: none !important;
    width: calc(100% - 20px) !important;
    max-width: 420px;
    aspect-ratio: 1 / 1;
    margin-top: 105px !important;
    margin-bottom: auto !important;
    border-radius: 18px;
    box-shadow: var(--neu-light-inset), 0 12px 40px rgba(30, 27, 46, 0.25);
    border: 4px solid #2a2040;
    overflow: hidden;
    background: #e0daf0;
  }

  #joystick-area {
    position: absolute;
    bottom: 16px;
    left: 20px;
    width: 120px;
    height: 120px;
  }

  .controls-hint {
    display: none !important;
  }
}
