/* ========================================
   Japanese Onomatopoeia Quiz - Styles
   ======================================== */

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', 'Hiragino Sans', 'Noto Sans JP', sans-serif;
  background: linear-gradient(180deg, #0a1220 0%, #101d2e 50%, #0d1826 100%);
  color: #e0e0e0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* Container */
#app {
  width: 100%;
  max-width: 640px;
  position: relative;
  z-index: 1;
}

/* Screen visibility */
.screen {
  /* All screens are visible by default; .hidden hides them */
}

.hidden {
  display: none !important;
}

/* ========================================
   Start Screen
   ======================================== */
.start-screen {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.start-screen h1 {
  font-size: 2.2rem;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #ff6b9d, #c084fc, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.start-screen .subtitle {
  color: #888;
  font-size: 1rem;
  margin-bottom: 32px;
}

.start-screen .description {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 32px;
  text-align: left;
  line-height: 1.7;
  color: #aaa;
  font-size: 0.95rem;
}

.start-screen .description strong {
  color: #c084fc;
}

.start-screen .description .desc-icons {
  margin-top: 12px;
  text-align: center;
  color: #777;
}

.btn-start {
  display: inline-block;
  padding: 16px 48px;
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.btn-start:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.6);
}

.btn-start:active {
  transform: translateY(0);
}

/* ========================================
   Quiz Screen
   ======================================== */
.quiz-screen {
  animation: fadeIn 0.3s ease;
}

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin-bottom: 16px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c3aed, #a855f7);
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}

/* Question Header */
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.question-number {
  font-size: 0.85rem;
  color: #888;
}

.score-display {
  font-size: 0.85rem;
  color: #a855f7;
  font-weight: bold;
}

/* Question Text */
.question-text {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 24px;
  color: #f0f0f0;
}

/* ========================================
   Choices
   ======================================== */
.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.choice-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: #e0e0e0;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  user-select: none;
}

/* Hover */
.choice-btn:hover:not(.disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(168, 85, 247, 0.5);
  transform: translateX(4px);
}

/* Disabled (after answering) */
.choice-btn.disabled {
  cursor: default;
  opacity: 0.7;
}

.choice-btn.disabled:hover {
  transform: none;
}

/* Correct answer still fully visible */
.choice-btn.correct,
.choice-btn.wrong {
  opacity: 1;
}

/* Playing state — audio is playing for this choice */
.choice-btn.playing {
  border-color: rgba(103, 232, 249, 0.7);
  box-shadow: 0 0 14px rgba(103, 232, 249, 0.2);
}

.choice-btn.playing .play-sound {
  background: rgba(103, 232, 249, 0.35);
  animation: pulse-play 1.2s infinite;
}

@keyframes pulse-play {
  0%, 100% { box-shadow: 0 0 0 0 rgba(103, 232, 249, 0.3); }
  50%      { box-shadow: 0 0 10px 3px rgba(103, 232, 249, 0.15); }
}

/* Choice number badge */
.choice-btn .choice-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.85rem;
  font-weight: bold;
  color: #888;
  flex-shrink: 0;
}

/* Choice text (Japanese onomatopoeia) */
.choice-btn .choice-text {
  flex: 1;
  font-size: 1.3rem;
  font-weight: 600;
}

/* Play sound button */
.choice-btn .play-sound {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(103, 232, 249, 0.15);
  border: none;
  color: #67e8f9;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.choice-btn .play-sound:hover {
  background: rgba(103, 232, 249, 0.3);
  transform: scale(1.1);
}

/* ========================================
   Answer States
   ======================================== */
.choice-btn.correct {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
}

.choice-btn.correct .choice-number {
  background: #22c55e;
  color: #fff;
}

.choice-btn.wrong {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.choice-btn.wrong .choice-number {
  background: #ef4444;
  color: #fff;
}

/* Selected (the one the user clicked) */
.choice-btn.selected {
  border-width: 3px;
}

/* ========================================
   Explanation
   ======================================== */
.explanation {
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  line-height: 1.6;
  color: #ccc;
  animation: slideUp 0.3s ease;
}

.explanation .label {
  color: #a855f7;
  font-weight: bold;
  margin-bottom: 4px;
}

/* ========================================
   Next Button
   ======================================== */
.btn-next {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  animation: slideUp 0.3s ease;
}

.btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}

/* ========================================
   Result Screen
   ======================================== */
.result-screen {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.result-screen h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
  color: #f0f0f0;
}

.score-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 4px solid;
}

.score-circle.excellent {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
}

.score-circle.great {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.1);
}

.score-circle.good {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
}

.score-circle.poor {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.score-circle .score-value {
  font-size: 3rem;
  font-weight: bold;
  line-height: 1;
}

.score-circle.excellent .score-value { color: #22c55e; }
.score-circle.great .score-value     { color: #3b82f6; }
.score-circle.good .score-value      { color: #f59e0b; }
.score-circle.poor .score-value      { color: #ef4444; }

.score-circle .score-total {
  font-size: 1rem;
  color: #888;
  margin-top: 4px;
}

.result-percent {
  font-size: 1.4rem;
  font-weight: 700;
  color: #c084fc;
  margin-bottom: 8px;
}

.result-message {
  font-size: 1.05rem;
  color: #aaa;
  margin-bottom: 32px;
  line-height: 1.6;
}

.btn-retry {
  display: inline-block;
  padding: 16px 48px;
  font-size: 1.1rem;
  font-weight: bold;
  color: #fff;
  background: linear-gradient(135deg, #7c3aed, #a855f7);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.4);
}

.btn-retry:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.6);
}

/* ========================================
   Error Screen
   ======================================== */
.error-screen {
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.error-screen h2 {
  color: #ef4444;
  margin-bottom: 16px;
}

.error-screen p {
  color: #aaa;
  font-size: 1rem;
}

/* ========================================
   Keyboard Hint
   ======================================== */
.keyboard-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 0.78rem;
  color: #555;
}

.keyboard-hint kbd {
  display: inline-block;
  padding: 2px 7px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.75rem;
  margin: 0 2px;
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ========================================
   Answer FX — Confetti
   ======================================== */
.answer-fx {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.confetti-particle {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.9;
  animation: confetti-fall 1s ease-out forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
  80%  { opacity: 0.7; }
  100% { transform: translateY(85vh) rotate(720deg) scale(0.4); opacity: 0; }
}

/* ========================================
   Answer FX — Correct flash
   ======================================== */
.choice-btn.correct-flash {
  animation: correct-glow 0.6s ease;
}

@keyframes correct-glow {
  0%   { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  30%  { box-shadow: 0 0 30px 10px rgba(34, 197, 94, 0.4); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* ========================================
   Answer FX — Wrong pulse
   ======================================== */
.choice-btn.wrong-pulse {
  animation: wrong-shake 0.4s ease;
}

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

/* ========================================
   Answer FX — Screen shake
   ======================================== */
.quiz-screen.shake {
  animation: screen-shake 0.45s ease;
}

@keyframes screen-shake {
  0%, 100% { transform: translateX(0); }
  15%      { transform: translateX(-5px) rotate(-0.3deg); }
  30%      { transform: translateX(5px) rotate(0.3deg); }
  45%      { transform: translateX(-4px); }
  60%      { transform: translateX(4px); }
  75%      { transform: translateX(-2px); }
}

/* ========================================
   Background Rain
   ======================================== */
.bg-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.rain-drop {
  position: absolute;
  top: -2em;
  color: rgba(100, 160, 220, 0.12);
  font-weight: 700;
  white-space: nowrap;
  animation: rain-fall linear infinite;
  will-change: transform;
}

.rain-drop {
  --rain-rotate: 0deg;
}

@keyframes rain-fall {
  0%   { transform: translateY(-2em) rotate(var(--rain-rotate)); opacity: 0; }
  5%   { opacity: 1; }
  90%  { opacity: 1; }
  100% { transform: translateY(105vh) rotate(var(--rain-rotate)); opacity: 0; }
}

/* ========================================
   Mastery Bar Graph (Genre-based)
   ======================================== */
.mastery-section {
  margin: 32px 0;
  text-align: left;
}

.mastery-title {
  font-size: 1rem;
  color: #c084fc;
  margin-bottom: 16px;
  text-align: center;
  font-weight: 600;
}

.mastery-graph {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mastery-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mastery-label-wrap {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.mastery-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #ccc;
}

.mastery-stat {
  font-size: 0.75rem;
  color: #888;
  font-variant-numeric: tabular-nums;
}

.mastery-track {
  width: 100%;
  height: 20px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.mastery-fill {
  height: 100%;
  border-radius: 6px;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.mastery-pct {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: bold;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 480px) {
  body { padding: 12px; }

  .start-screen h1 { font-size: 1.6rem; }

  .question-text { font-size: 1.1rem; }

  .choice-btn { padding: 12px; }
  .choice-btn .choice-text { font-size: 1.1rem; }

  .score-circle { width: 140px; height: 140px; }
  .score-circle .score-value { font-size: 2.4rem; }

  .result-percent { font-size: 1.2rem; }

  .start-donut-svg { width: 100px; height: 100px; }
}

/* ========================================
   Start Screen Mastery Graph
   ======================================== */
.start-mastery-section {
  margin-top: 36px;
  padding-top: 28px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.start-mastery-header {
  text-align: center;
  margin-bottom: 16px;
}

.start-mastery-count {
  font-size: 2.4rem;
  font-weight: 800;
  background: linear-gradient(135deg, #c084fc, #67e8f9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.start-mastery-sep {
  font-size: 1.2rem;
  color: #666;
  font-weight: 600;
}

.start-mastery-label {
  display: block;
  font-size: 0.78rem;
  color: #888;
  margin-top: 2px;
  letter-spacing: 0.5px;
}

/* Donut chart */
.start-donut-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.start-donut-svg {
  width: 128px;
  height: 128px;
}

.donut-pct-text {
  font-size: 1.2rem;
  font-weight: 700;
  fill: rgba(255, 255, 255, 0.7);
}
