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.4rem;
  font-weight: 700;
  padding: 14px 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 { max-width: 100%; padding: 0; position: relative; width: 100vw; height: 100vh; }
#game.active { display: block; }

/* Leave room for ad sidebars */
@media (min-width: 1201px) {
  #game { width: calc(100vw - 360px); margin: 0 auto; }
}

#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: flex-start;
  z-index: 10;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 20px 0;
  order: 1;
}

.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: 12px 20px 8px;
  gap: 8px;
  order: -1;
}

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

.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.4rem;
  font-weight: 700;
  text-align: center;
  padding: 10px 20px;
  width: 160px;
  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); }
