/* ── Custom properties ── */
:root {
  --bg:           #0d0d1a;
  --surface:      #1a1230;
  --text:         #e8e8ff;
  --text-dim:     #55557a;
  --accent:       #9d6ee8;
  --accent-glow:  rgba(157, 110, 232, 0.5);
}

/* ── Base ── */
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

/* ── Question mark animations ── */
@keyframes qPulse {
  0%, 100% { opacity: 0.85; transform: scale(1); }
  50%       { opacity: 1;    transform: scale(1.04); }
}

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

/* ── Question mark ── */
.question-mark {
  font-size: clamp(5rem, 15vw, 9rem);
  font-weight: bold;
  color: var(--text);
  cursor: default;
  user-select: none;
  /* Run both animations simultaneously */
  animation: qPulse 3s ease-in-out infinite, qFloat 4.5s ease-in-out infinite;
  transition: text-shadow 0.35s ease, color 0.35s ease;
  outline: none;
}

.question-mark:hover,
.question-mark:focus {
  text-shadow:
    0 0  25px var(--accent-glow),
    0 0  60px var(--accent-glow),
    0 0 100px var(--accent-glow);
  color: var(--accent);
}

/* ── Day indicator ── */
.day-indicator {
  position: fixed;
  top: 0.75rem;
  left: 1rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.open {
  display: flex;
}

.overlay-panel {
  background: var(--surface);
  border-radius: 12px;
  padding: 2rem;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

h2 {
  margin: 0 0 1.25rem;
  color: var(--text);
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

textarea,
input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
  resize: vertical;
  margin-bottom: 0.75rem;
}

/* ── Character counter ── */
.char-counter {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-align: right;
  margin-top: -0.5rem;
  margin-bottom: 0.75rem;
}

/* ── Fixed button tray — all bottom-right UI lives here ── */
/* Add new buttons inside .ui-buttons in index.html; never position them individually */
.ui-buttons {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  z-index: 50;
}

.feedback-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(157, 110, 232, 0.4);
}

.changelog-btn,
.about-btn {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  min-height: 44px; /* visual audit: enforce minimum touch target */
}

/* ── Submit button ── */
.submit-btn {
  width: 100%;
  padding: 0.65rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

/* ── Feedback success state ── */
.feedback-success {
  display: none;
  text-align: center;
  padding: 1.5rem 0;
}

.feedback-success.visible {
  display: block;
}

/* ── Feedback history sections ── */
.my-suggestions,
.feedback-history {
  margin-top: 1rem;
  font-size: 0.85rem;
}

/* ── About footer line ── */
.about-footer {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 1.5rem;
}

/* ── Screen reader only (visually hidden) ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* ── Archive button (same style as changelog/about) ── */
.archive-btn {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  min-height: 44px; /* visual audit: enforce minimum touch target */
}

/* ── Leaderboard button ── */
.leaderboard-btn {
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  min-height: 44px;
  min-width: 44px;
}

/* ── Leaderboard overlay close button ── */
.overlay-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

/* ── Leaderboard list ── */
#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#leaderboard-list li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.lb-rank  { color: #9d6ee8; font-weight: bold; min-width: 28px; }
.lb-score { color: #ffd700; margin-left: auto; }
.lb-wave  { color: rgba(255, 255, 255, 0.5); font-size: 0.85em; }
.lb-empty { color: rgba(255, 255, 255, 0.4); font-style: italic; padding: 20px 0; text-align: center; }
.lb-my-row { background: rgba(255,215,0,0.12); color: #ffd700; font-weight: bold; border-color: rgba(255,215,0,0.3); }

.lb-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.lb-tab { flex: 1; padding: 8px; min-height: 44px; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; color: rgba(255,255,255,0.5); cursor: pointer; font-family: monospace; font-size: 0.85em; transition: background 0.15s, color 0.15s; }
.lb-tab:hover { background: rgba(157,110,232,0.1); color: #fff; }
.lb-tab.lb-tab-active { background: rgba(157,110,232,0.2); border-color: #9d6ee8; color: #ffffff; font-weight: bold; }

/* ── Archive entries ── */
.archive-entry {
  padding: 1rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.archive-entry:last-child { border-bottom: none; }
.archive-name { font-size: 1rem; color: var(--text); margin-bottom: 0.25rem; }
.archive-meta { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.5rem; }
.archive-link { font-size: 0.85rem; color: var(--accent); text-decoration: none; }
.archive-link:hover { text-decoration: underline; }

/* ── Game canvas ── */
/* width/height are set by resizeCanvas() via JS attributes; no CSS size override */
/* left is also overridden by resizeCanvas() to center the capped canvas in landscape */
#gameCanvas {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
}

/* When the game is active, hide the question mark and show the canvas */
body.game-active #questionMark { display: none; }
body.game-active #gameCanvas   { display: block; }

/* Keep HUD buttons above the canvas */
body.game-active .ui-buttons { z-index: 110; }

/* ── Mobile tap-to-shoot hint ── */
/* Shown briefly at game start on touch devices via .show class added by startGame() */
.tap-hint {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(157, 110, 232, 0.85);
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 20px;
  font-size: 0.9rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s;
  z-index: 60;
  white-space: nowrap;
}
.tap-hint.show { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .tap-hint { transition: none; }
}

/* ── Arcade CRT effects ── */
#scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.07) 2px,
    rgba(0,0,0,0.07) 4px
  );
  pointer-events: none;
  z-index: 5;
}

#vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
  z-index: 5;
}

@media (prefers-reduced-motion: reduce) {
  #scanlines { display: none; }
}

/* ── Name capture overlay ── */
.name-capture-panel {
  text-align: center;
  max-width: 360px;
}

.name-capture-prompt {
  color: var(--text-dim);
  margin: 0 0 1rem;
  font-size: 0.95rem;
}

#leaderboard-name-input {
  /* inherits textarea/input[type=text] base styles */
  margin-bottom: 0.3rem;
  font-size: 1.05rem;
  text-align: center;
}

.char-count {
  display: block;
  font-size: 11px;
  color: #aaa;
  text-align: right;
  margin-top: 2px;
  margin-bottom: 1rem;
}

@keyframes shake-input {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

#leaderboard-name-input.error {
  border-color: #e05555;
  animation: shake-input 0.4s ease;
}

.name-capture-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.name-capture-submit {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
}

.name-capture-submit:hover,
.name-capture-submit:focus {
  background: #b388f5;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.name-capture-submit:active {
  background: #8a5cd0;
}

.name-capture-skip {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
  cursor: pointer;
}

.name-capture-skip:hover,
.name-capture-skip:focus {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.3);
  outline: 2px solid rgba(255, 255, 255, 0.2);
  outline-offset: 2px;
}

.name-capture-skip:active {
  background: rgba(255, 255, 255, 0.05);
}
