* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #05061A;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.back-link {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  font: 600 14px/1 Arial, sans-serif;
  color: #22D3EE;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(10, 15, 44, 0.7);
  border: 1px solid rgba(34, 211, 238, 0.35);
  backdrop-filter: blur(6px);
  transition: background 0.15s ease, transform 0.15s ease;
}
.back-link.story-link { left: auto; right: 16px; }
.back-link:hover { background: rgba(34, 211, 238, 0.16); transform: translateY(-1px); }

#stage {
  position: relative;
  width: 640px;
  height: 420px;
  max-width: 100vw;
  overflow: hidden;
  background: #000;
  box-shadow: 0 0 24px rgba(0,0,0,0.6);
}

@media (max-width: 660px) {
  #stage {
    width: 100vw;
    height: calc(100vw * 420 / 640);
  }
}

.screen {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 1;
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 2;
}

#screen-start, #screen-win {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  background: radial-gradient(circle at 50% 30%, #163a2e 0%, #0a1f18 60%, #05061A 100%);
}
#screen-start h1, #screen-win h2 {
  font-size: 32px;
  margin: 0 0 4px;
  color: #ffe37a;
  text-shadow: 0 2px 0 #7a5230;
}
.subtitle {
  color: #7fe0c9;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 18px;
}
.blurb {
  max-width: 440px;
  line-height: 1.5;
  color: #cfd6e6;
  margin: 0 0 24px;
}
.cta {
  font: 700 16px Arial, sans-serif;
  padding: 12px 28px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(#ffe37a, #f2b632);
  color: #3a2a05;
  cursor: pointer;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.cta:hover { transform: scale(1.05); }
.cta:active { transform: scale(0.96); }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

#hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none;
}
#hud > div {
  background: rgba(5, 6, 26, 0.55);
  padding: 4px 10px;
  border-radius: 8px;
}
#btn-mute {
  pointer-events: auto;
  background: rgba(5, 6, 26, 0.55);
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
#btn-mute:hover {
  background: rgba(5, 6, 26, 0.8);
}

.quiz-box {
  position: absolute;
  inset: 8%;
  background: #f5f5f0;
  color: #222;
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#quiz-question {
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin: 0;
}
.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.quiz-choice {
  font: 600 13px Arial, sans-serif;
  padding: 10px 8px;
  border-radius: 8px;
  border: 2px solid #333;
  background: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.15s ease;
}
.quiz-choice:hover:not(:disabled) { background: #ffe680; transform: scale(1.03); }
.quiz-choice.correct { background: #7be07b; border-color: #2e7d32; }
.quiz-choice.wrong { background: #f08080; border-color: #b71c1c; }
#quiz-feedback {
  text-align: center;
  font-weight: 700;
  margin: 0;
}
.hidden { display: none; }
