body { overflow: hidden; }

/* ---------- Screens ---------- */
.screen { display: none; width: 100%; max-width: 500px; padding: 20px; text-align: center; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ---------- Menu ---------- */
#menu h1 { font-size: 2rem; margin-bottom: 8px; }
#menu p { opacity: .8; margin-bottom: 24px; }

.table-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 320px;
  margin-bottom: 24px;
}

.table-btn {
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(255,255,255,.3);
  border-radius: 12px;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 700;
  padding: 18px 0;
  cursor: pointer;
  transition: .2s;
}
.table-btn:hover { background: rgba(255,255,255,.3); transform: scale(1.08); }
.table-btn.selected { background: #fff; color: #764ba2; border-color: #fff; }

.start-btn {
  background: #fff;
  color: #764ba2;
  border: none;
  border-radius: 50px;
  padding: 14px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
  opacity: .4;
  pointer-events: none;
}
.start-btn.ready { opacity: 1; pointer-events: auto; }
.start-btn.ready:hover { transform: scale(1.05); box-shadow: 0 4px 20px rgba(0,0,0,.25); }

/* ---------- Game ---------- */
#game {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  padding: 0;
  overflow: hidden;
}
#game.active { display: block; }

#gameCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 44px 16px 0; /* top: clear back button */
}

.hud-lives { font-size: 1.6rem; text-shadow: 0 2px 6px rgba(0,0,0,.5); }

.hud-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  font-weight: 700;
  font-size: 1.1rem;
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
}

.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 12px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  gap: 4px;
}

.hud-question {
  font-size: 1.5rem;
  font-weight: 800;
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  min-height: 28px;
}

.hud-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  pointer-events: auto;
}

.answer-input {
  background: rgba(0,0,0,.5);
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 12px;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  padding: 14px 24px;
  width: 200px;
  outline: none;
  transition: .2s;
  -moz-appearance: textfield;
}
.answer-input::-webkit-outer-spin-button,
.answer-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.answer-input:focus { border-color: rgba(255,255,255,.8); background: rgba(0,0,0,.65); }
.answer-input::placeholder { color: rgba(255,255,255,.4); font-weight: 400; font-size: 1rem; }
.answer-input.wrong { border-color: #f44; animation: inputShake .3s ease; }

@keyframes inputShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.mic-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .85rem;
  opacity: .7;
}
.mic-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #f44;
  animation: pulse 1s infinite;
}
.mic-dot.off { background: #888; animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .5; transform: scale(1.3); }
}

/* ---------- Results ---------- */
#results h2 { font-size: 2rem; margin-bottom: 8px; }
.final-score { font-size: 3rem; font-weight: 800; margin: 16px 0; }
#results .stats { opacity: .85; margin-bottom: 24px; line-height: 1.8; font-size: 1.1rem; }

.replay-btn {
  background: #fff;
  color: #764ba2;
  border: none;
  border-radius: 50px;
  padding: 14px 48px;
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: .2s;
}
.replay-btn:hover { transform: scale(1.05); }

/* ---------- QCM buttons on sides of base ---------- */
#game .choices-grid {
  position: absolute;
  bottom: 6%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  max-width: none;
  width: 100%;
  padding: 0 6px;
  gap: 0;
  pointer-events: none;
  z-index: 11;
  grid-template-columns: none;
}
#game .choices-grid .choice-btn {
  pointer-events: auto;
  width: 23%;
  padding: 10px 0;
  font-size: 1.2rem;
  border-radius: 10px;
}

/* ---------- Mobile tighten ---------- */
@media (max-width: 600px) {
  .hud-top { padding: 44px 12px 0; }
  .hud-lives { font-size: 1.3rem; }
  .hud-info { font-size: .95rem; }
  .hud-bottom { padding: 2px 10px; padding-bottom: max(4px, env(safe-area-inset-bottom)); gap: 3px; }
  .hud-question { font-size: 1.3rem; min-height: 22px; }
  #game .choices-grid .choice-btn { padding: 8px 0; font-size: 1.1rem; }
}
