/* ==========================================================================
   Quiz Arena — Gamified, vibrant, energetic
   ========================================================================== */

:root {
  --bg-deep: #0d0b2e;
  --bg-mid: #1a1748;
  --bg-light: #2d2768;
  --accent-pink: #ff3d8a;
  --accent-purple: #a855f7;
  --accent-cyan: #22d3ee;
  --accent-yellow: #facc15;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-orange: #f97316;
  --text: #ffffff;
  --text-soft: rgba(255, 255, 255, 0.75);
  --text-mute: rgba(255, 255, 255, 0.50);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(255, 255, 255, 0.10);

  --font-display: 'Plus Jakarta Sans', 'Noto Sans JP', system-ui, sans-serif;
  --font-jp: 'Noto Sans JP', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--font-jp);
  background:
    radial-gradient(ellipse at top left, rgba(168, 85, 247, 0.30), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(255, 61, 138, 0.25), transparent 50%),
    radial-gradient(ellipse at center, rgba(34, 211, 238, 0.10), transparent 60%),
    linear-gradient(180deg, #0d0b2e 0%, #1a1748 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================ Topbar ============================ */
.qa-topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 11, 46, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.qa-back, .qa-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border-radius: 999px;
  transition: all 0.2s ease;
}

.qa-back:hover, .qa-icon-btn:hover {
  color: var(--text);
  background: var(--surface-strong);
}

.qa-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qa-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(168, 85, 247, 0.40);
}

.qa-brand-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #ff3d8a 0%, #a855f7 50%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ============================ Screen system ============================ */
.qa-app { position: relative; }

.qa-screen { display: none; padding: 40px 24px 80px; min-height: calc(100vh - 64px); }
.qa-screen.is-active { display: block; }

.qa-container { max-width: 880px; margin: 0 auto; }
.qa-container-wide { max-width: 1100px; margin: 0 auto; }

.qa-screen-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.qa-screen-subtitle {
  color: var(--text-soft);
  font-size: 15px;
  margin-bottom: 36px;
}

.qa-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface);
  border-radius: 999px;
  margin-bottom: 24px;
  transition: all 0.2s ease;
}

.qa-back-btn:hover { background: var(--surface-strong); color: var(--text); }

.qa-section-label {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-cyan);
  margin: 32px 0 16px;
}

/* ============================ Buttons ============================ */
.qa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: all 0.2s ease;
  border: 1px solid var(--border);
}

.qa-btn:hover:not(:disabled) {
  background: var(--surface-strong);
  transform: translateY(-1px);
}

.qa-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.qa-btn-primary {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border: none;
  box-shadow: 0 12px 28px rgba(255, 61, 138, 0.30);
}

.qa-btn-primary:hover:not(:disabled) {
  box-shadow: 0 18px 36px rgba(255, 61, 138, 0.40);
  transform: translateY(-2px);
}

.qa-btn-secondary {
  background: var(--surface);
  border: 1px solid var(--border);
}

.qa-btn-large {
  padding: 16px 32px;
  font-size: 17px;
  border-radius: 14px;
}

/* ============================ Home Screen ============================ */
.qa-home {
  max-width: 1000px;
  margin: 0 auto;
  text-align: center;
}

.qa-hero {
  position: relative;
  padding: 60px 0 50px;
}

.qa-hero-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(255, 61, 138, 0.30), transparent 60%);
  filter: blur(40px);
  z-index: -1;
}

.qa-hero-title {
  font-family: var(--font-display);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.92;
  margin-bottom: 16px;
}

.qa-title-line-1, .qa-title-line-2 {
  display: block;
  font-size: clamp(64px, 12vw, 156px);
}

.qa-title-line-1 {
  background: linear-gradient(135deg, #fff 0%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 8px 32px rgba(168, 85, 247, 0.40);
}

.qa-title-line-2 {
  background: linear-gradient(120deg, #ff3d8a 0%, #a855f7 50%, #22d3ee 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 32px rgba(255, 61, 138, 0.40));
}

.qa-hero-tagline {
  font-family: var(--font-display);
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 600;
  letter-spacing: 0.10em;
  color: var(--text-soft);
  text-transform: uppercase;
}

.qa-home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 60px;
}

.qa-tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  text-align: left;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.qa-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(168, 85, 247, 0.10) 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.qa-tile:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.20);
  background: var(--surface-strong);
}

.qa-tile:hover::before { opacity: 1; }

.qa-tile-primary {
  background: linear-gradient(135deg, #ff3d8a 0%, #a855f7 100%);
  border: none;
  box-shadow: 0 16px 40px rgba(255, 61, 138, 0.30);
}

.qa-tile-primary:hover {
  box-shadow: 0 24px 56px rgba(255, 61, 138, 0.45);
}

.qa-tile-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.qa-tile-primary .qa-tile-icon { background: rgba(255, 255, 255, 0.20); }

.qa-tile-text h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.qa-tile-text p {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.6;
}

.qa-tile-primary .qa-tile-text p { color: rgba(255, 255, 255, 0.85); }

.qa-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.qa-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.5;
}

.qa-feature-emoji { font-size: 28px; }
.qa-feature strong { font-family: var(--font-display); font-weight: 700; }

/* ============================ Quiz Select ============================ */
.qa-quiz-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.qa-quiz-item {
  position: relative;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qa-quiz-item:hover {
  background: var(--surface-strong);
  border-color: var(--accent-purple);
  transform: translateY(-2px);
}

.qa-quiz-item-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.qa-quiz-item-desc {
  font-size: 13px;
  color: var(--text-soft);
  line-height: 1.5;
}

.qa-quiz-item-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-mute);
  margin-top: 6px;
}

.qa-quiz-item-meta span { display: inline-flex; align-items: center; gap: 4px; }

.qa-quiz-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.qa-mini-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text-soft);
  transition: all 0.15s ease;
}

.qa-mini-btn:hover { background: rgba(255,255,255,0.20); color: white; }
.qa-mini-btn.danger:hover { background: var(--accent-red); color: white; }

.qa-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-mute);
  background: var(--surface);
  border-radius: 12px;
  border: 1px dashed var(--border);
  font-size: 14px;
}

/* ============================ Player Setup ============================ */
.qa-player-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  min-height: 80px;
}

.qa-player-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  font-weight: 600;
  position: relative;
  animation: chipPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes chipPop {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.qa-player-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
}

.qa-player-name { flex-grow: 1; font-size: 14.5px; }

.qa-player-remove {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.10);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-mute);
  transition: all 0.2s ease;
}

.qa-player-remove:hover { background: var(--accent-red); color: white; }

.qa-player-add {
  display: flex;
  gap: 10px;
  margin-bottom: 32px;
}

.qa-player-add input {
  flex-grow: 1;
  padding: 14px 18px;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: white;
  transition: all 0.2s ease;
}

.qa-player-add input:focus {
  outline: none;
  border-color: var(--accent-purple);
  background: var(--surface-strong);
}

.qa-quiz-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 22px;
  background: var(--surface);
  border-radius: 14px;
  margin-bottom: 28px;
}

.qa-summary-label {
  font-size: 12px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 4px;
}

.qa-summary-value {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

/* ============================ Gameplay HUD ============================ */
#screen-game.is-active {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
}

.qa-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.qa-hud-left { text-align: left; }
.qa-hud-right { text-align: right; }
.qa-hud-center { display: flex; justify-content: center; }

.qa-question-count {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
}

.qa-question-count span:first-child {
  background: linear-gradient(120deg, #ff3d8a 0%, #a855f7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.qa-current-player-label {
  font-size: 11px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-bottom: 4px;
}

.qa-current-player-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
}

/* Timer */
.qa-timer {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qa-timer-svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.qa-timer-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.10);
  stroke-width: 8;
}

.qa-timer-progress {
  fill: none;
  stroke: url(#timerGradient);
  stroke: var(--accent-cyan);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.1s linear, stroke 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.60));
}

.qa-timer.warning .qa-timer-progress { stroke: var(--accent-yellow); filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.60)); }
.qa-timer.danger .qa-timer-progress { stroke: var(--accent-red); filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.60)); }
.qa-timer.frozen .qa-timer-progress { stroke: #93c5fd; filter: drop-shadow(0 0 12px rgba(147, 197, 253, 0.80)); }

.qa-timer-text {
  position: relative;
  font-family: var(--font-mono);
  font-size: 32px;
  font-weight: 700;
  z-index: 1;
}

.qa-timer.frozen { animation: freezePulse 1s ease-in-out infinite; }
@keyframes freezePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 20px rgba(147, 197, 253, 0.80)); }
}

/* Power-ups */
.qa-powerups {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.qa-powerup {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.qa-powerup:hover:not(:disabled) {
  transform: translateY(-2px);
  background: var(--surface-strong);
  border-color: var(--accent-yellow);
}

.qa-powerup:disabled { opacity: 0.30; cursor: not-allowed; }

.qa-powerup-icon { font-size: 16px; }

/* Question Card */
.qa-question-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.04) 100%);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.qa-question-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 60%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(168, 85, 247, 0.20), transparent 70%);
  pointer-events: none;
}

.qa-question-type {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  padding: 5px 12px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.qa-question-text {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.3;
  position: relative;
  z-index: 1;
}

/* Answers */
.qa-answers {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.qa-answer {
  position: relative;
  padding: 24px 28px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: white;
  text-align: left;
  border-radius: 16px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: none;
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 90px;
  overflow: hidden;
  cursor: pointer;
}

.qa-answer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0);
  transition: background 0.2s ease;
  pointer-events: none;
}

.qa-answer:hover:not(:disabled)::before { background: rgba(255, 255, 255, 0.10); }
.qa-answer:hover:not(:disabled) { transform: translateY(-3px); }
.qa-answer:disabled { cursor: not-allowed; }

.qa-answer.eliminated { opacity: 0.25; }
.qa-answer.eliminated::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 12px;
  right: 12px;
  height: 3px;
  background: rgba(255, 255, 255, 0.40);
  transform: rotate(-3deg);
}

.qa-answer-shape {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.20);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.qa-answer-text { flex-grow: 1; line-height: 1.3; }

.qa-answer-0 { background: linear-gradient(135deg, #e11d48 0%, #ef4444 100%); }
.qa-answer-1 { background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%); }
.qa-answer-2 { background: linear-gradient(135deg, #ca8a04 0%, #facc15 100%); }
.qa-answer-3 { background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%); }

.qa-answer.correct {
  animation: correctPulse 0.5s ease;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.50), 0 0 40px rgba(34, 197, 94, 0.50);
}

.qa-answer.wrong {
  opacity: 0.4;
}

@keyframes correctPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* True/False */
.qa-answers.tf {
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.qa-answers.tf .qa-answer { min-height: 130px; justify-content: center; font-size: 36px; }

/* Typed answer */
.qa-typed-input {
  width: 100%;
  padding: 22px 28px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  background: var(--surface-strong);
  border: 2px solid var(--border);
  border-radius: 16px;
  color: white;
  text-align: center;
  letter-spacing: 0.02em;
}

.qa-typed-input:focus {
  outline: none;
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.10);
}

.qa-typed-submit {
  margin-top: 14px;
  width: 100%;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-radius: 12px;
  color: white;
  transition: all 0.2s ease;
}

.qa-typed-submit:hover { transform: translateY(-2px); }

/* Order */
.qa-order-area {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.qa-order-target {
  min-height: 80px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 2px dashed var(--border);
  border-radius: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}

.qa-order-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px;
  background: var(--surface);
  border-radius: 14px;
}

.qa-order-token {
  padding: 12px 18px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-pink) 100%);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.qa-order-token:hover { transform: translateY(-2px); }
.qa-order-token.placed {
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid var(--border);
}

.qa-order-submit {
  width: 100%;
  padding: 16px;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-radius: 12px;
  color: white;
}

/* Combo */
.qa-combo {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: clamp(60px, 12vw, 140px);
  font-weight: 900;
  letter-spacing: -0.04em;
  background: linear-gradient(120deg, #ff3d8a 0%, #facc15 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 8px 32px rgba(255, 61, 138, 0.60));
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

.qa-combo.show {
  animation: comboShow 1.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes comboShow {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3) rotate(-10deg); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  35% { transform: translate(-50%, -50%) scale(1) rotate(-1deg); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

/* Feedback overlay */
.qa-feedback {
  position: fixed;
  inset: 0;
  background: rgba(13, 11, 46, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.qa-feedback.show { display: flex; animation: feedbackFadeIn 0.3s ease; }

@keyframes feedbackFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.qa-feedback-content {
  text-align: center;
  max-width: 500px;
}

.qa-feedback-icon {
  font-size: 100px;
  margin-bottom: 16px;
  animation: iconBounce 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iconBounce {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.qa-feedback-title {
  font-family: var(--font-display);
  font-size: clamp(36px, 6vw, 56px);
  font-weight: 900;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}

.qa-feedback-title.correct {
  background: linear-gradient(120deg, #22c55e 0%, #facc15 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.qa-feedback-title.wrong {
  background: linear-gradient(120deg, #ef4444 0%, #f97316 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.qa-feedback-points {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 18px;
}

.qa-feedback-correct {
  font-size: 16px;
  color: var(--text-soft);
  margin-bottom: 28px;
}

.qa-feedback-correct strong { color: var(--accent-green); font-size: 22px; font-weight: 800; }

/* Scoreboard */
.qa-scoreboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.qa-score-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.qa-score-cell.is-current {
  background: linear-gradient(135deg, rgba(255, 61, 138, 0.20) 0%, rgba(168, 85, 247, 0.20) 100%);
  border-color: var(--accent-pink);
  box-shadow: 0 0 24px rgba(255, 61, 138, 0.30);
}

.qa-score-cell .qa-player-avatar { width: 28px; height: 28px; font-size: 12px; }

.qa-score-name {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.qa-score-points {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
}

/* ============================ Results ============================ */
.qa-results-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 900;
  text-align: center;
  margin-bottom: 40px;
  background: linear-gradient(120deg, #ff3d8a 0%, #facc15 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.qa-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 48px;
  min-height: 280px;
}

.qa-podium-spot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  flex: 1 1 0;
  max-width: 220px;
}

.qa-podium-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: white;
  border: 4px solid;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.30);
}

.qa-podium-rank-1 .qa-podium-avatar { width: 100px; height: 100px; font-size: 38px; border-color: #facc15; }
.qa-podium-rank-2 .qa-podium-avatar { border-color: #cbd5e0; }
.qa-podium-rank-3 .qa-podium-avatar { border-color: #fb923c; }

.qa-podium-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 800;
  text-align: center;
  word-break: break-word;
}

.qa-podium-score {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-yellow);
}

.qa-podium-bar {
  width: 100%;
  border-radius: 14px 14px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.35);
}

.qa-podium-rank-1 .qa-podium-bar {
  height: 180px;
  background: linear-gradient(180deg, #fde047 0%, #facc15 100%);
  color: rgba(13, 11, 46, 0.6);
  box-shadow: 0 -8px 30px rgba(250, 204, 21, 0.40);
}

.qa-podium-rank-2 .qa-podium-bar {
  height: 130px;
  background: linear-gradient(180deg, #e2e8f0 0%, #94a3b8 100%);
  color: rgba(13, 11, 46, 0.5);
}

.qa-podium-rank-3 .qa-podium-bar {
  height: 100px;
  background: linear-gradient(180deg, #fdba74 0%, #f97316 100%);
  color: rgba(13, 11, 46, 0.5);
}

.qa-results-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}

.qa-result-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border-radius: 12px;
}

.qa-result-rank {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  width: 30px;
  color: var(--text-mute);
}

.qa-result-name { flex-grow: 1; font-weight: 600; }

.qa-result-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-soft);
}

.qa-result-points {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-yellow);
}

.qa-results-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ============================ Editor ============================ */
.qa-editor-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 28px;
}

.qa-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.qa-field span {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-mute);
}

.qa-field input, .qa-field textarea, .qa-field select {
  padding: 12px 16px;
  font-size: 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: white;
}

.qa-field input:focus, .qa-field textarea:focus, .qa-field select:focus {
  outline: none;
  border-color: var(--accent-purple);
}

.qa-editor-questions {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.qa-q-card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.qa-q-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.qa-q-num {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 16px;
  color: var(--accent-cyan);
}

.qa-q-type-pill {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.20);
  color: #c4b5fd;
}

.qa-q-remove {
  padding: 6px 10px;
  font-size: 12px;
  background: transparent;
  border-radius: 6px;
  color: var(--text-mute);
  transition: all 0.15s ease;
}

.qa-q-remove:hover { background: var(--accent-red); color: white; }

.qa-q-card .qa-field { margin-bottom: 12px; }

.qa-q-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.qa-q-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.20);
  border-radius: 8px;
}

.qa-q-option-row input[type="radio"], .qa-q-option-row input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: var(--accent-purple);
  width: 18px;
  height: 18px;
}

.qa-q-option-row input[type="text"] {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: white;
  font-size: 14px;
  padding: 4px;
}

.qa-q-option-row input[type="text"]:focus { outline: none; }

.qa-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 20px;
  background: var(--surface);
  border-radius: 14px;
  position: sticky;
  bottom: 16px;
  backdrop-filter: blur(12px);
}

.qa-add-question-menu {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* How to Play */
.qa-how-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.qa-how-card {
  padding: 28px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  position: relative;
}

.qa-how-num {
  position: absolute;
  top: -16px;
  left: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 18px;
  box-shadow: 0 8px 20px rgba(255, 61, 138, 0.40);
}

.qa-how-card h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  margin: 12px 0 12px;
}

.qa-how-card p {
  font-size: 14px;
  color: var(--text-soft);
  line-height: 1.7;
}

.qa-how-list {
  list-style: none;
  padding: 0;
  margin-top: 14px;
}

.qa-how-list li {
  padding: 8px 0;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--text-soft);
}

.qa-how-list strong { color: var(--accent-yellow); }

/* Confetti */
.qa-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 300;
}

/* Tablet */
@media (max-width: 900px) {
  .qa-home-grid { grid-template-columns: repeat(2, 1fr); }
  .qa-features { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile */
@media (max-width: 640px) {
  .qa-topbar { padding: 12px 14px; gap: 8px; }
  .qa-back span { display: none; }                /* hide "ツールボックスへ" text, keep arrow */
  .qa-back { padding: 8px 10px; }
  .qa-brand-text { font-size: 16px; }
  .qa-icon-btn { padding: 8px 10px; }

  .qa-screen { padding: 24px 16px 60px; }
  .qa-hud { grid-template-columns: 1fr; gap: 16px; }
  .qa-hud-left, .qa-hud-right { text-align: center; }
  .qa-question-card { padding: 28px 20px; }
  .qa-question-text { font-size: 22px; }
  .qa-answers { grid-template-columns: 1fr; }
  .qa-answer { min-height: 70px; padding: 18px 20px; font-size: 16px; }
  .qa-editor-meta { grid-template-columns: 1fr; }
  .qa-q-options { grid-template-columns: 1fr; }
  .qa-podium { gap: 8px; }
  .qa-podium-rank-1 .qa-podium-avatar { width: 80px; height: 80px; font-size: 28px; }

  .qa-home-grid { grid-template-columns: 1fr; }
  .qa-features { grid-template-columns: 1fr; }
  .qa-tile { padding: 22px 20px; }

  .qa-powerups { gap: 8px; }
  .qa-powerup { padding: 8px 14px; font-size: 12px; }

  .qa-scoreboard { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .qa-scoreboard { grid-template-columns: 1fr; }
}
