/* ============================================================
   FutureGen Academy — the prompt game's own rules (game.html).

   tailwind.css, loaded before this file, holds the Tailwind classes the game
   was written with, built into a plain file by _tools/gamebuild.html (so the
   page loads nothing from other sites). These rules come after it and win.
   ============================================================ */

/* ---------- from the original game's <style> ---------- */
html {
  font-family: "Rubik", "Heebo", system-ui, -apple-system, "Segoe UI", sans-serif;
  touch-action: manipulation;          /* no double-tap zoom while tapping fast */
}
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  background-color: #090a0f;
  color: #ffffff;
  -webkit-touch-callout: none;
}

#game-canvas {
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* Glow Effects */
.gold-glow { box-shadow: 0 0 25px rgba(234, 179, 8, 0.4); }
.purple-glow { box-shadow: 0 0 25px rgba(168, 85, 247, 0.4); }
.blue-glow { box-shadow: 0 0 25px rgba(59, 130, 246, 0.5); }

/* Millionaire Option Button Animations */
.quiz-option-btn {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid rgba(234, 179, 8, 0.3);
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
}
.quiz-option-btn:hover {
  border-color: #eab308;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(51, 65, 85, 0.98));
  transform: translateY(-2px);
  box-shadow: 0 0 15px rgba(234, 179, 8, 0.5);
}
.quiz-option-btn.selected {
  border-color: #f59e0b;
  background: linear-gradient(135deg, #78350f, #b45309);
  color: #fef08a;
}
.quiz-option-btn.correct {
  border-color: #22c55e !important;
  background: linear-gradient(135deg, #14532d, #15803d) !important;
  color: #bbf7d0 !important;
  box-shadow: 0 0 25px rgba(34, 197, 94, 0.8);
  animation: pulse-correct 0.6s infinite alternate;
}
.quiz-option-btn.wrong {
  border-color: #ef4444 !important;
  background: linear-gradient(135deg, #7f1d1d, #b91c1c) !important;
  color: #fecaca !important;
  box-shadow: 0 0 25px rgba(239, 68, 68, 0.8);
}
@keyframes pulse-correct {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

/* Radial Progress Timer */
.timer-ring { transition: stroke-dashoffset 1s linear; }

/* ---------- the site's additions ---------- */
:focus-visible { outline: 3px solid #facc15; outline-offset: 3px; }
.game-modal:focus { outline: none; }   /* the window itself takes the focus when it opens */
.nowrap { white-space: nowrap; }

/* hearts are emoji now: a lost one is a faded heart */
.heart-off { opacity: .28; filter: grayscale(1); }

/* the "lost a heart" note: centred without a transform, which the bounce animation replaces */
#damage-toast {
  left: 0; right: 0; margin-inline: auto;
  width: max-content; max-width: calc(100vw - 24px);
  --tw-translate-x: 0;
}

/* HUD: stats on the right, the task and the way back to the site on the left */
#hud {
  gap: 12px;
  padding-top: calc(1rem + env(safe-area-inset-top));
  padding-left: calc(1rem + env(safe-area-inset-left));
  padding-right: calc(1rem + env(safe-area-inset-right));
}
#hud-side { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
#home-link {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 6px 12px 6px 8px; border-radius: 14px;
  background: rgba(15, 23, 42, .9); border: 1px solid rgba(245, 158, 11, .4);
  color: #fde68a; font-weight: 700; font-size: .85rem; line-height: 1.2; white-space: nowrap;
  text-decoration: none;
}
#home-link img { width: 26px; height: auto; display: block; }
#hud-stats > div { white-space: nowrap; }
#home-link:hover { background: rgba(30, 41, 59, .95); }

/* the windows scroll when they are taller than the screen (a phone on its side) */
.game-modal {
  overflow-y: auto;
  align-items: flex-start;
  overscroll-behavior: contain;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.game-modal > .modal-card { margin: auto; }
.quiz-badges { flex-wrap: wrap; }
/* after a wrong answer the explanation box is red, like its title */
#quiz-feedback.is-wrong { background-color: rgba(69, 10, 10, .75); border-color: rgba(239, 68, 68, .5); }

.back-link {
  display: inline-block; margin-top: 16px;
  color: #cbd5e1; font-size: .9rem; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px;
}
.back-link:hover { color: #fde68a; }

.no-webgl {
  margin: 0; padding: 14px 16px; border-radius: 14px;
  background: rgba(127, 29, 29, .5); border: 1px solid rgba(239, 68, 68, .6);
  color: #fecaca; font-weight: 700; line-height: 1.6;
}

/* how to play: keys, or touch on a touch screen (body.touch-mode, set by game.js) */
.only-touch { display: none; }
body.touch-mode .only-touch { display: block; }
body.touch-mode .only-keys,
body.touch-mode #keys-help { display: none; }
body.touch-mode #quest-box { pointer-events: none; }   /* the joystick gets that corner too */

/* ---------- touch controls (body.touch-play while the hero can move) ---------- */
#touch-ui {
  position: fixed; inset: 0; z-index: 5;
  display: none; pointer-events: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
body.touch-play #touch-ui { display: block; }

/* the joystick is the whole left half; the ring rests here and jumps to the thumb */
#stick-zone {
  position: absolute; top: 0; bottom: 0; left: 0; width: 50%;
  pointer-events: auto; touch-action: none;
}
#stick-base {
  position: absolute;
  /* clear of the accessibility button in the bottom-left corner */
  left: calc(56px + env(safe-area-inset-left));
  bottom: calc(70px + env(safe-area-inset-bottom));
  width: 124px; height: 124px; border-radius: 50%;
  background: rgba(15, 23, 42, .45);
  border: 2px solid rgba(245, 158, 11, .45);
  box-shadow: inset 0 0 22px rgba(0, 0, 0, .35);
  opacity: .6; transition: opacity .15s;
  pointer-events: none;
}
#stick-base.active { opacity: 1; }
#stick-knob {
  position: absolute; left: 50%; top: 50%;
  width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 70%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}
#stick-knob.running {
  background: radial-gradient(circle at 35% 30%, #fff7cc, #facc15 70%);
  box-shadow: 0 0 24px rgba(250, 204, 21, .85);
}

.touch-btn {
  position: absolute; pointer-events: auto; touch-action: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 50%;
  border: 2px solid rgba(245, 158, 11, .6);
  background: rgba(15, 23, 42, .62);
  color: #fde68a; font-weight: 800;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
  -webkit-tap-highlight-color: transparent;
}
.touch-btn .ico { font-size: 1.7rem; line-height: 1; }
.touch-btn .lbl { font-size: .72rem; line-height: 1; }
.touch-btn.pressed { transform: scale(.92); background: rgba(245, 158, 11, .38); }
/* jump in the corner, the sword up and to its left: clear of each other and of the
   joystick's ring even on a 360px-wide phone */
#btn-jump {
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(26px + env(safe-area-inset-bottom));
  width: 92px; height: 92px;
}
#btn-sword {
  right: calc(104px + env(safe-area-inset-right));
  bottom: calc(112px + env(safe-area-inset-bottom));
  width: 76px; height: 76px;
}

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  /* stats and the way back on the first row, the task under them */
  #hud {
    flex-wrap: wrap; gap: 8px;
    padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 0
             calc(10px + env(safe-area-inset-left));
  }
  #hud-side { display: contents; }
  #hud-stats { order: 1; gap: 10px; padding: 7px 12px; border-radius: 14px; }
  #hud-stats .text-lg { font-size: 1rem; }
  #hearts-container .heart { font-size: 1.2rem; }
  .lives-count { display: none; }
  #home-link { order: 2; }
  #quest-box { order: 3; flex: 1 1 100%; max-width: none; padding: 7px 12px; border-radius: 14px; }
  #quest-text { font-size: .78rem; }
}
@media (max-height: 500px) {
  /* a phone on its side: a slimmer HUD leaves room for the game */
  #hud { padding-top: calc(8px + env(safe-area-inset-top)); }
  #hud-stats, #quest-box { padding: 6px 12px; border-radius: 14px; }
  #quest-text { font-size: .78rem; }
  #quest-box { max-width: 22rem; }
  #hud-stats { gap: 10px; }
  #hud-stats .text-lg { font-size: 1rem; }
  #hearts-container .heart { font-size: 1.2rem; }
  .lives-count { display: none; }
  /* further in from the corner, where the accessibility button sits on a short screen */
  #stick-base { left: calc(96px + env(safe-area-inset-left)); bottom: calc(36px + env(safe-area-inset-bottom)); }
  #btn-jump { bottom: calc(16px + env(safe-area-inset-bottom)); }
  #btn-sword { bottom: calc(96px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px), (max-height: 560px) {
  .game-modal .modal-card { padding: 20px 16px; border-radius: 20px; }
  #intro-modal h1 { font-size: 1.6rem; }
  #intro-modal .modal-card > p,
  #intro-modal .modal-card > div { margin-bottom: 14px; }
  #quiz-modal .quiz-head { margin-bottom: 12px; padding-bottom: 10px; }
  #quiz-modal .question-box { padding: 14px; margin-bottom: 14px; }
  #question-text { font-size: 1rem; }
  #quiz-modal .options-grid { gap: 10px; margin-bottom: 14px; }
  .quiz-option-btn { padding: 10px 12px; }
  #quiz-feedback { margin-bottom: 14px; padding: 12px; }
  #victory-modal h1 { font-size: 1.7rem; }
}

@media (prefers-reduced-motion: reduce) {
  .animate-bounce, .quiz-option-btn.correct { animation: none; }
  .quiz-option-btn, .timer-ring { transition: none; }
}
