/* ============================================================
   NihonGO! - Multiplayer Japanese Learning Game
   Production CSS  |  Dark Theme  |  Mobile-First
   ============================================================ */

/* --- Google Fonts (loaded in HTML) ---
   @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800&family=Noto+Sans+JP:wght@400;500;700&display=swap');
*/

/* ============================================================
   1. CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Backgrounds */
  --bg-deepest:    #0D0D1A;
  --bg-card:       #1A1A2E;
  --bg-elevated:   #252540;

  /* Accents */
  --accent-sakura: #F2A7B0;
  --accent-gold:   #E8C547;
  --accent-mint:   #7ECFB3;
  --accent-red:    #E85D5D;

  /* Text */
  --text-primary:   #F0EDE6;
  --text-secondary: #9B97A8;
  --text-japanese:  #FFFFFF;

  /* Derived */
  --sakura-border:  rgba(242, 167, 176, 0.10);
  --sakura-glow:    rgba(242, 167, 176, 0.25);
  --gold-glow:      rgba(232, 197, 71, 0.35);
  --card-shadow:    0 4px 24px rgba(0, 0, 0, 0.30);
  --card-shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.45);

  /* Layout */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-pill: 999px;

  /* Timing */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
}


/* ============================================================
   2. RESET & GLOBAL
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-deepest);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg {
  display: block;
  max-width: 100%;
}

ul, ol {
  list-style: none;
}

a {
  color: var(--accent-sakura);
  text-decoration: none;
}


/* ============================================================
   3. TYPOGRAPHY HELPERS
   ============================================================ */
.font-jp,
.jp-text {
  font-family: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-sakura {
  color: var(--accent-sakura);
}

.text-gold {
  color: var(--accent-gold);
}

.text-mint {
  color: var(--accent-mint);
}


/* ============================================================
   4. SCREEN SYSTEM
   ============================================================ */
.screen {
  display: none;
  opacity: 0;
  width: 100%;
  padding: 16px;
  transition: opacity 0.4s var(--ease-out-expo);
}

.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 1;
}


/* ============================================================
   5. CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--sakura-border);
  box-shadow: var(--card-shadow);
  padding: 24px;
  width: 100%;
}

.card-elevated {
  background: var(--bg-elevated);
}


/* ============================================================
   6. BUTTONS
   ============================================================ */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  padding: 0 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Outfit', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  white-space: nowrap;
  gap: 8px;
}

button:hover,
.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

button:active,
.btn:active {
  transform: scale(0.97);
}

button:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

button:disabled:hover,
.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Primary - Sakura */
.btn-primary {
  background: var(--accent-sakura);
  color: var(--bg-deepest);
}

.btn-primary:hover {
  background: #f4b8c0;
  box-shadow: 0 6px 24px var(--sakura-glow);
}

/* Gold - Host actions */
.btn-gold {
  background: var(--accent-gold);
  color: var(--bg-deepest);
}

.btn-gold:hover {
  background: #efd060;
  box-shadow: 0 6px 24px var(--gold-glow);
}

/* Outline */
.btn-outline {
  background: transparent;
  border: 2px solid var(--accent-sakura);
  color: var(--accent-sakura);
}

.btn-outline:hover {
  background: rgba(242, 167, 176, 0.08);
  box-shadow: 0 4px 16px var(--sakura-glow);
}

/* Full-width button */
.btn-block {
  width: 100%;
}

/* Large button */
.btn-lg {
  height: 60px;
  font-size: 18px;
  border-radius: var(--radius-md);
}


/* ============================================================
   7. INPUTS
   ============================================================ */
input[type="text"],
input[type="number"],
input[type="url"],
input,
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  color: var(--text-primary);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 18px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-sakura);
  box-shadow: 0 0 0 3px rgba(242, 167, 176, 0.12);
}

input::placeholder {
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Japanese answer textarea */
textarea,
#answer-input {
  width: 100%;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 24px;
  min-height: 120px;
  resize: vertical;
  background: var(--bg-elevated);
  border: 2px solid transparent;
  color: var(--text-japanese);
  border-radius: var(--radius-md);
  padding: 16px;
  line-height: 1.6;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  outline: none;
}

textarea:focus,
#answer-input:focus {
  border-color: var(--accent-sakura);
  box-shadow: 0 0 0 3px rgba(242, 167, 176, 0.12);
}

textarea::placeholder,
#answer-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
  font-size: 20px;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}


/* ============================================================
   8. JOIN SCREEN
   ============================================================ */
#join-screen {
  justify-content: center;
  min-height: 100vh;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

.join-title {
  font-family: 'Outfit', sans-serif;
  font-size: 56px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--accent-sakura) 0%, var(--accent-gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.1;
}

.join-subtitle {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 16px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 40px;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

.join-form .btn {
  margin-top: 8px;
}

/* Join divider (OR JOIN) */
.join-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0;
}

.join-divider-line {
  flex: 1;
  height: 1px;
  background: var(--text-secondary);
  opacity: 0.3;
}

.join-divider-text {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Room code input row */
.room-code-row {
  display: flex;
  gap: 12px;
}

.room-code-input {
  width: 120px;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 700;
  font-family: 'Outfit', monospace;
  letter-spacing: 0.3em;
  background: var(--bg-card);
  border: 2px solid var(--sakura-border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 12px;
}

.room-code-input::placeholder {
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  font-weight: 400;
}

.room-code-input:focus {
  outline: none;
  border-color: var(--accent-sakura);
  box-shadow: 0 0 0 3px var(--sakura-glow);
}

.room-code-row .btn {
  flex: 1;
}

/* Room code display in lobby */
.room-code-display {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.room-code-badge {
  display: inline-block;
  font-size: 1.3rem;
  font-weight: 800;
  font-family: 'Outfit', monospace;
  letter-spacing: 0.25em;
  color: var(--accent-gold);
  background: rgba(232, 197, 71, 0.1);
  border: 1px solid rgba(232, 197, 71, 0.3);
  border-radius: var(--radius-sm);
  padding: 4px 16px;
  margin-left: 8px;
  user-select: all;
  cursor: pointer;
}

.room-code-badge:hover {
  background: rgba(232, 197, 71, 0.2);
}

/* Room browser */
.room-browser {
  margin-top: 8px;
  width: 100%;
}

.room-browser-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.room-item:hover {
  border-color: var(--accent-sakura);
  background: var(--bg-elevated);
  transform: translateY(-1px);
}

.room-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-item-host {
  font-family: 'Outfit', sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.room-item-details {
  display: flex;
  gap: 12px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.room-item-code {
  font-family: 'Outfit', monospace;
  font-weight: 600;
  color: var(--accent-gold);
}

.room-item-status {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
}

.room-status-waiting {
  background: rgba(126, 207, 179, 0.15);
  color: var(--accent-mint);
}

.room-status-playing {
  background: rgba(232, 197, 71, 0.15);
  color: var(--accent-gold);
}

/* Mode tag on questions */
.mode-tag {
  display: block;
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-mint);
  margin-bottom: 10px;
}

[data-mode="conversation"] .mode-tag {
  color: var(--accent-sakura);
}

[data-mode="reading"] .mode-tag {
  color: var(--accent-gold);
}

/* Leave / quit buttons */
.lobby-actions {
  margin-top: 20px;
  text-align: center;
}

.btn-leave {
  font-family: 'Outfit', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid rgba(155, 151, 168, 0.3);
  border-radius: var(--radius-md);
  padding: 8px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-leave:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
  background: rgba(232, 93, 93, 0.1);
}

.btn-leave-small {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid rgba(155, 151, 168, 0.2);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-leave-small:hover {
  color: var(--accent-red);
  border-color: var(--accent-red);
}

/* Sakura floating particles */
.sakura-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.sakura-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-sakura);
  opacity: 0;
  animation: sakuraFloat linear infinite;
}

.sakura-particle:nth-child(1) {
  left: 10%;
  width: 6px; height: 6px;
  animation-duration: 8s;
  animation-delay: 0s;
}
.sakura-particle:nth-child(2) {
  left: 25%;
  width: 10px; height: 10px;
  animation-duration: 10s;
  animation-delay: 1.5s;
}
.sakura-particle:nth-child(3) {
  left: 42%;
  width: 5px; height: 5px;
  animation-duration: 7s;
  animation-delay: 0.8s;
}
.sakura-particle:nth-child(4) {
  left: 60%;
  width: 8px; height: 8px;
  animation-duration: 9s;
  animation-delay: 2.2s;
}
.sakura-particle:nth-child(5) {
  left: 75%;
  width: 7px; height: 7px;
  animation-duration: 11s;
  animation-delay: 0.4s;
}
.sakura-particle:nth-child(6) {
  left: 88%;
  width: 9px; height: 9px;
  animation-duration: 8.5s;
  animation-delay: 3s;
}
.sakura-particle:nth-child(7) {
  left: 35%;
  width: 6px; height: 6px;
  animation-duration: 12s;
  animation-delay: 1s;
}
.sakura-particle:nth-child(8) {
  left: 55%;
  width: 4px; height: 4px;
  animation-duration: 9.5s;
  animation-delay: 4s;
}


/* ============================================================
   9. LOBBY SCREEN
   ============================================================ */
#lobby-screen {
  max-width: 700px;
  margin: 0 auto;
  padding-top: 32px;
}

.lobby-header {
  text-align: center;
  margin-bottom: 32px;
}

.lobby-header h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.lobby-room-code {
  font-family: 'Outfit', monospace;
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-gold);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}

.lobby-room-code-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Player cards grid */
.player-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-bottom: 32px;
}

.player-card {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 600;
  animation: fadeIn 0.3s var(--ease-out-expo);
}

.player-card .connected-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mint);
  flex-shrink: 0;
}

.player-card .connected-dot.disconnected {
  background: var(--accent-red);
}

.player-card .host-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-gold);
  background: rgba(232, 197, 71, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

/* Host controls */
.host-controls {
  width: 100%;
  margin-bottom: 24px;
}

.option-group {
  margin-bottom: 20px;
}

.option-group-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.option-group-desc {
  font-size: 12px;
  color: var(--text-secondary);
  opacity: 0.7;
  margin-bottom: 8px;
}

.option-detail {
  font-size: 12px;
  color: var(--accent-sakura);
  margin-top: 6px;
  min-height: 18px;
  transition: opacity 0.2s ease;
}

.option-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.option-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.option-pill:hover {
  background: #2e2e50;
  color: var(--text-primary);
  transform: none;
  box-shadow: none;
}

.option-pill.selected {
  background: var(--accent-sakura);
  color: var(--bg-deepest);
}

.option-pill.selected:hover {
  background: #f4b8c0;
}

.start-btn-wrapper {
  margin-top: 12px;
}


/* ============================================================
   10. QUESTION SCREEN
   ============================================================ */
#screen-question {
  max-width: 600px;
  margin: 0 auto;
  padding-top: 24px;
  position: relative;
}

.question-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.question-number {
  font-weight: 700;
  color: var(--text-primary);
}

/* Timer circle */
.timer-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 28px;
}

.timer-circle {
  position: relative;
  width: 100px;
  height: 100px;
}

.timer-circle svg {
  width: 100px;
  height: 100px;
  transform: rotate(-90deg);
}

.timer-circle .timer-bg {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 6;
}

.timer-circle .timer-progress {
  fill: none;
  stroke: var(--accent-mint);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s ease;
}

.timer-circle .timer-progress.warning {
  stroke: var(--accent-gold);
}

.timer-circle .timer-progress.danger {
  stroke: var(--accent-red);
}

.timer-circle .timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

.timer-circle.timer-urgent {
  animation: pulseGlow 0.8s ease-in-out infinite;
}

/* Sentence display */
.sentence-card {
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  margin-bottom: 24px;
  text-align: center;
  width: 100%;
}

.sentence-text {
  font-family: 'Outfit', sans-serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--text-japanese);
  line-height: 1.6;
}

.sentence-hint {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
}

/* Answer section */
.answer-section {
  width: 100%;
  position: relative;
  margin-bottom: 16px;
}

.answer-section .btn {
  margin-top: 12px;
}

/* Waiting overlay */
#waiting-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 26, 0.85);
  backdrop-filter: blur(4px);
  border-radius: var(--radius-md);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  animation: fadeIn 0.3s ease;
}

#waiting-overlay.active {
  display: flex;
}

#waiting-overlay .overlay-icon {
  width: 56px;
  height: 56px;
  position: relative;
}

#waiting-overlay .checkmark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-mint);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--bg-deepest);
  font-weight: 700;
}

#waiting-overlay .spinner {
  width: 56px;
  height: 56px;
  position: absolute;
  top: 0;
  left: 0;
}

#waiting-overlay .spinner svg {
  width: 56px;
  height: 56px;
  animation: spin 1.2s linear infinite;
}

#waiting-overlay .spinner[hidden] {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#waiting-overlay .waiting-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

#waiting-overlay.loading .waiting-text {
  animation: pulseDots 1.5s ease-in-out infinite;
}

#waiting-overlay.loading .checkmark {
  display: none;
}

#waiting-overlay.loading .spinner {
  display: block;
}

@keyframes pulseDots {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Player submission dots */
.player-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid rgba(155, 151, 168, 0.3);
  transition: background 0.3s ease, border-color 0.3s ease, transform 0.3s var(--ease-spring);
}

.player-dot.submitted {
  background: var(--accent-sakura);
  border-color: var(--accent-sakura);
  transform: scale(1.15);
}


/* ============================================================
   11. RESULTS SCREEN
   ============================================================ */
#screen-results {
  max-width: 600px;
  margin: 0 auto;
  padding-top: 24px;
}

.results-header {
  text-align: center;
  margin-bottom: 24px;
}

.results-header h2 {
  font-size: 24px;
  font-weight: 700;
}

/* Model answer card */
.model-answer {
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-left: 4px solid var(--accent-gold);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  width: 100%;
}

.model-answer-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold);
  margin-bottom: 12px;
}

.model-answer .jp-answer {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-japanese);
  line-height: 1.4;
  margin-bottom: 8px;
}

.model-answer .romaji {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.model-answer .grammar-notes {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.model-answer .grammar-notes strong {
  color: var(--text-primary);
}

/* Player result cards */
.player-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  margin-bottom: 28px;
}

.player-result-card {
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  animation: slideUp 0.4s var(--ease-out-expo) backwards;
}

.player-result-card:nth-child(1) { animation-delay: 0.05s; }
.player-result-card:nth-child(2) { animation-delay: 0.10s; }
.player-result-card:nth-child(3) { animation-delay: 0.15s; }
.player-result-card:nth-child(4) { animation-delay: 0.20s; }
.player-result-card:nth-child(5) { animation-delay: 0.25s; }
.player-result-card:nth-child(6) { animation-delay: 0.30s; }

.result-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.result-name {
  font-weight: 700;
  font-size: 16px;
}

.result-score {
  font-weight: 700;
  font-size: 18px;
  color: var(--accent-gold);
}

.result-answer {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 20px;
  color: var(--text-japanese);
  margin-bottom: 12px;
  line-height: 1.5;
  word-break: break-word;
}

/* Score bar */
.score-bar-track {
  width: 100%;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.score-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent-red) 0%, var(--accent-gold) 50%, var(--accent-mint) 100%);
  width: 0%;
  animation: scoreReveal 1s var(--ease-out-expo) forwards;
}

/* Speed bonus */
.speed-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-gold);
  background: rgba(232, 197, 71, 0.12);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  margin-right: 8px;
}

.result-feedback {
  font-size: 14px;
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
  margin-top: 8px;
}

/* Standings */
.standings {
  width: 100%;
  margin-bottom: 24px;
}

.standings h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  text-align: center;
}

.standings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.standings-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  font-weight: 600;
  transition: background 0.2s ease;
}

.standings-row.highlight {
  background: var(--bg-elevated);
  border: 1px solid var(--sakura-border);
}

.standings-rank {
  font-size: 14px;
  color: var(--text-secondary);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.standings-name {
  flex: 1;
}

.standings-score {
  color: var(--accent-gold);
  font-weight: 700;
}

/* Next button */
.results-actions {
  text-align: center;
  margin-top: 8px;
  margin-bottom: 32px;
  width: 100%;
}


/* ============================================================
   12. FINAL SCREEN
   ============================================================ */
#screen-final {
  max-width: 600px;
  margin: 0 auto;
  padding-top: 32px;
}

.final-header {
  text-align: center;
  margin-bottom: 36px;
}

.final-header h2 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
}

.final-header p {
  color: var(--text-secondary);
}

/* Podium */
.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin-bottom: 40px;
  width: 100%;
  padding: 0 8px;
}

.podium-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 16px 24px;
  text-align: center;
  width: 33.33%;
  max-width: 180px;
  position: relative;
  animation: podiumRise 0.8s var(--ease-spring) backwards;
}

/* 1st place - Center */
.podium-block.first {
  height: 200px;
  background: linear-gradient(180deg, rgba(232, 197, 71, 0.15) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(232, 197, 71, 0.3);
  border-bottom: none;
  box-shadow: 0 -8px 40px rgba(232, 197, 71, 0.15);
  order: 2;
  animation-delay: 0.3s;
}

.podium-block.first .podium-rank {
  color: var(--accent-gold);
  font-size: 32px;
}

/* 2nd place - Left */
.podium-block.second {
  height: 160px;
  background: linear-gradient(180deg, rgba(192, 192, 192, 0.10) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(192, 192, 192, 0.2);
  border-bottom: none;
  order: 1;
  animation-delay: 0.5s;
}

.podium-block.second .podium-rank {
  color: #C0C0C0;
  font-size: 28px;
}

/* 3rd place - Right */
.podium-block.third {
  height: 120px;
  background: linear-gradient(180deg, rgba(205, 127, 50, 0.10) 0%, var(--bg-card) 100%);
  border: 1px solid rgba(205, 127, 50, 0.2);
  border-bottom: none;
  order: 3;
  animation-delay: 0.7s;
}

.podium-block.third .podium-rank {
  color: #CD7F32;
  font-size: 24px;
}

.podium-rank {
  font-family: 'Outfit', sans-serif;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 8px;
}

.podium-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.podium-score {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Final rankings list */
.final-rankings {
  width: 100%;
  margin-bottom: 32px;
}

.final-rankings h3 {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 14px;
}

.final-rank-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  animation: slideUp 0.4s var(--ease-out-expo) backwards;
}

.final-rank-row:nth-child(1) { animation-delay: 0.8s; }
.final-rank-row:nth-child(2) { animation-delay: 0.85s; }
.final-rank-row:nth-child(3) { animation-delay: 0.9s; }
.final-rank-row:nth-child(4) { animation-delay: 0.95s; }
.final-rank-row:nth-child(5) { animation-delay: 1.0s; }

.final-rank-number {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.final-rank-name {
  flex: 1;
  font-weight: 600;
}

.final-rank-score {
  font-weight: 700;
  color: var(--accent-gold);
}

.final-actions {
  text-align: center;
  margin-bottom: 48px;
  width: 100%;
}


/* ============================================================
   13. TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100% - 40px);
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--sakura-border);
  border-left: 4px solid var(--accent-red);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--card-shadow-lg);
  animation: slideInRight 0.4s var(--ease-out-expo),
             fadeOut 0.4s ease 4.6s forwards;
  pointer-events: auto;
  line-height: 1.4;
}

.toast.toast-success {
  border-left-color: var(--accent-mint);
}

.toast.toast-info {
  border-left-color: var(--accent-sakura);
}


/* ============================================================
   14. UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.w-full { width: 100%; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


/* ============================================================
   15. KEYFRAME ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

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

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

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes sakuraFloat {
  0% {
    transform: translateY(100vh) translateX(0);
    opacity: 0;
  }
  10% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.3;
  }
  90% {
    opacity: 0.5;
  }
  100% {
    transform: translateY(-100vh) translateX(30px);
    opacity: 0;
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 12px rgba(232, 93, 93, 0.2);
  }
  50% {
    box-shadow: 0 0 28px rgba(232, 93, 93, 0.5);
  }
}

@keyframes scoreReveal {
  from { width: 0%; }
  /* "to" width is set inline via style attribute */
}

@keyframes podiumRise {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ============================================================
   16. RESPONSIVE BREAKPOINTS
   ============================================================ */

/* Small phones */
@media (max-width: 380px) {
  .join-title {
    font-size: 44px;
  }

  .model-answer .jp-answer {
    font-size: 26px;
  }

  .sentence-text {
    font-size: 20px;
  }

  textarea,
  #answer-input {
    font-size: 20px;
    min-height: 100px;
  }

  .podium-block.first  { height: 160px; }
  .podium-block.second { height: 130px; }
  .podium-block.third  { height: 100px; }
}

/* Tablet and up */
@media (min-width: 768px) {
  .screen {
    padding: 32px 24px;
  }

  .join-title {
    font-size: 64px;
  }

  .join-subtitle {
    font-size: 18px;
  }

  .sentence-text {
    font-size: 28px;
  }

  .model-answer .jp-answer {
    font-size: 36px;
  }

  .lobby-header h2 {
    font-size: 32px;
  }

  .podium {
    gap: 20px;
  }

  .podium-block {
    padding: 24px 20px 28px;
  }

  .podium-block.first  { height: 220px; }
  .podium-block.second { height: 180px; }
  .podium-block.third  { height: 140px; }

  .final-header h2 {
    font-size: 40px;
  }
}

/* Large desktop */
@media (min-width: 1024px) {
  body {
    font-size: 17px;
  }

  .card {
    padding: 32px;
  }
}

/* Japanese text minimum size guard */
@media (max-width: 767px) {
  .font-jp,
  .jp-text,
  .jp-answer,
  .result-answer,
  .model-answer .jp-answer,
  textarea,
  #answer-input {
    font-size: max(20px, 1em);
  }

  .sentence-text {
    font-size: max(22px, 1em);
  }
}


/* ============================================================
   17. ACCESSIBILITY
   ============================================================ */

/* Focus-visible outlines */
:focus-visible {
  outline: 2px solid var(--accent-sakura);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--accent-sakura);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none; /* Already has border-color change */
  border-color: var(--accent-sakura);
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }

  .sakura-particle {
    display: none;
  }

  .timer-circle.timer-urgent {
    animation: none;
    box-shadow: 0 0 16px rgba(232, 93, 93, 0.4);
  }

  .score-bar-fill {
    animation: none;
  }

  .podium-block {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* High contrast mode support */
@media (forced-colors: active) {
  .btn-primary,
  .btn-gold,
  .option-pill.selected {
    border: 2px solid ButtonText;
  }

  .score-bar-fill {
    background: Highlight;
  }
}


/* ============================================================
   18. SCROLLBAR STYLING
   ============================================================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-deepest);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #35355a;
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) var(--bg-deepest);
}
