*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:       #0b0c10;
  --surface:   #13151c;
  --card:      #1b1e2a;
  --card2:     #222636;
  --border:    #2a2e42;
  --border2:   #353a52;
  --gold:      #f0b429;
  --gold2:     #ffd166;
  --rose:      #fb7185;
  --green:     #4ade80;
  --text:      #e8eaf2;
  --muted:     #7c85a0;
  --radius:    12px;
  --radius-lg: 18px;
  --ff-head:   'Syne', sans-serif;
  --ff-body:   'DM Sans', sans-serif;
  --shadow:    0 8px 40px rgba(0,0,0,0.5);
}

html { font-size: 16px; }
body {
  font-family: var(--ff-body);
  background: var(--ink);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.site-header {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: rgba(11,12,16,0.85);
  backdrop-filter: blur(12px);
  padding: 0 1.5rem 6px;
}
.header-inner {
  max-width: 820px;
  margin: 0 auto;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-left { display: flex; align-items: center; gap: 0.6rem; }
.globe-anim { font-size: 1.5rem; display: inline-block; }
.site-title {
  font-family: var(--ff-head);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  background: linear-gradient(120deg, var(--gold), var(--gold2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  padding-bottom: 4px;
}
.info-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border2);
  background: var(--card);
  color: var(--muted);
  font-family: var(--ff-head);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.info-btn:hover { border-color: var(--gold); color: var(--gold); }

.screen { display: none; flex: 1; position: relative; z-index: 1; animation: fade-in 0.25s ease; }
.screen.active { display: flex; flex-direction: column; }
@keyframes fade-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.home-hero { text-align: center; padding: 3rem 1.5rem 1.5rem; }
.hero-sub { font-size: 1.05rem; color: var(--muted); font-weight: 300; font-style: italic; }

.setup-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 520px;
  width: calc(100% - 3rem);
  margin: 0 auto 2rem;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  box-shadow: var(--shadow);
}
.setup-section { display: flex; flex-direction: column; gap: 0.55rem; }
.setup-label {
  font-family: var(--ff-head);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.toggle-group { display: flex; gap: 0.5rem; overflow: visible; position: relative; }
.toggle-btn {
  flex: 1;
  padding: 0.65rem 1rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  font-family: var(--ff-body);
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.toggle-btn.active {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--ink);
  font-weight: 700;
}
.toggle-btn:not(.active):not(.coming-soon):hover { border-color: var(--border2); color: var(--text); }

.toggle-btn.coming-soon {
  opacity: 0.38;
  cursor: not-allowed;
}
.toggle-btn.coming-soon:hover { opacity: 0.38 !important; border-color: var(--border) !important; color: var(--muted) !important; }
.toggle-btn.coming-soon::after {
  content: attr(title);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  border: 1px solid var(--gold2);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.72rem;
  white-space: nowrap;
  padding: 0.35rem 0.8rem;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.6);
}
.toggle-btn.coming-soon:hover::after { opacity: 1; }

.batch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; }
.batch-btn {
  padding: 0.55rem;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  font-family: var(--ff-head);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}
.batch-btn.active { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.batch-btn:not(.active):hover { border-color: var(--border2); color: var(--text); }

#custom-batch-wrap { margin-top: 0.4rem; }
.text-input {
  width: 100%;
  background: var(--card2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-family: var(--ff-body);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--gold); }
.text-input.small { max-width: 160px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.65rem 1.4rem;
  border-radius: 8px; border: none;
  font-family: var(--ff-body); font-size: 0.92rem; font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: var(--ink); }
.btn-secondary { background: var(--card2); color: var(--text); border: 1.5px solid var(--border2); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border2); }
.btn-full { width: 100%; }
.btn-big { padding: 0.85rem 1.4rem; font-size: 1.02rem; font-weight: 700; }

.lobby-inner { max-width: 480px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.lobby-title { font-family: var(--ff-head); font-size: 1.4rem; font-weight: 700; }
.qr-wrap { background: #fff; border-radius: 12px; padding: 1rem; display: flex; align-items: center; justify-content: center; }
.lobby-url { font-size: 0.8rem; color: var(--muted); word-break: break-all; text-align: center; }
.lobby-hint { font-size: 0.85rem; color: var(--muted); text-align: center; }
.players-list { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; min-height: 2rem; }
.player-chip { background: var(--card2); border: 1px solid var(--border2); border-radius: 99px; padding: 0.3rem 0.8rem; font-size: 0.82rem; color: var(--text); }

.game-topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative; z-index: 2;
}
.game-progress-wrap { flex: 1; display: flex; align-items: center; gap: 0.7rem; }
.q-counter { font-family: var(--ff-head); font-size: 0.82rem; font-weight: 700; color: var(--muted); white-space: nowrap; }
.progress-track { flex: 1; height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 99px; width: 0%; transition: width 0.4s ease; }
.game-score-wrap { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.score-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.score-value { font-family: var(--ff-head); font-size: 1.4rem; font-weight: 800; color: var(--gold); }
.quit-btn {
  background: none; border: 1.5px solid var(--border); color: var(--muted);
  border-radius: 8px; padding: 0.4rem 0.8rem; font-size: 0.8rem;
  cursor: pointer; transition: border-color 0.15s, color 0.15s; white-space: nowrap;
}
.quit-btn:hover { border-color: var(--rose); color: var(--rose); }

.media-panel {
  max-width: 620px; width: calc(100% - 3rem);
  margin: 1.5rem auto 0;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 1.8rem;
  box-shadow: var(--shadow);
}
.loading-panel { display: flex; flex-direction: column; align-items: center; gap: 1rem; color: var(--muted); font-size: 0.9rem; }
.loader-ring { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--gold); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.audio-vis { display: flex; align-items: flex-end; justify-content: center; gap: 5px; height: 48px; margin-bottom: 1.2rem; }
.av-bar { width: 5px; background: var(--gold); border-radius: 3px; height: 6px; opacity: 0.4; }
.audio-vis.playing .av-bar { animation: bounce-bar 0.6s ease-in-out infinite alternate; opacity: 1; }
.av-bar:nth-child(1) { animation-delay: 0s; }
.av-bar:nth-child(2) { animation-delay: 0.07s; }
.av-bar:nth-child(3) { animation-delay: 0.14s; }
.av-bar:nth-child(4) { animation-delay: 0.21s; }
.av-bar:nth-child(5) { animation-delay: 0.28s; }
.av-bar:nth-child(6) { animation-delay: 0.35s; }
.av-bar:nth-child(7) { animation-delay: 0.42s; }
.av-bar:nth-child(8) { animation-delay: 0.49s; }
.av-bar:nth-child(9) { animation-delay: 0.56s; }
@keyframes bounce-bar { from { height: 6px; } to { height: calc(6px + var(--rh, 30px)); } }

.audio-controls { display: flex; align-items: center; gap: 1rem; }
.audio-play-btn {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--gold); color: var(--ink); border: none;
  font-size: 1.1rem; cursor: pointer; flex-shrink: 0;
  transition: transform 0.1s, opacity 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.audio-play-btn:hover { opacity: 0.88; }
.audio-track-wrap { flex: 1; }
.audio-progress-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.audio-progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold2)); border-radius: 99px; width: 0%; }
.audio-time-row { display: flex; justify-content: space-between; margin-top: 0.35rem; font-size: 0.75rem; color: var(--muted); }

.text-passage { font-size: 1.05rem; line-height: 1.75; color: var(--text); font-weight: 300; max-height: 260px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }

.answer-area { max-width: 620px; width: calc(100% - 3rem); margin: 1rem auto 0; display: flex; gap: 0.6rem; align-items: flex-start; position: relative; }
.autocomplete-wrap { flex: 1; position: relative; }
.answer-input {
  width: 100%; background: var(--card); border: 2px solid var(--border);
  border-radius: 10px; padding: 0.75rem 1rem;
  font-family: var(--ff-body); font-size: 1rem; color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.answer-input:focus { border-color: var(--gold); }
.answer-input:disabled { opacity: 0.5; }
.autocomplete-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--card2); border: 1.5px solid var(--border2);
  border-radius: 10px; list-style: none; max-height: 210px; overflow-y: auto;
  z-index: 100; box-shadow: var(--shadow); scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}
.autocomplete-list li { padding: 0.6rem 1rem; cursor: pointer; font-size: 0.9rem; transition: background 0.1s; display: flex; flex-direction: column; gap: 0.1rem; }
.autocomplete-list li:hover, .autocomplete-list li.selected { background: var(--border); }
.ac-alias { font-size: 0.72rem; color: var(--muted); }
.btn-submit { padding: 0.75rem 1.4rem; flex-shrink: 0; align-self: stretch; }

.feedback-banner {
  max-width: 620px; width: calc(100% - 3rem); margin: 1rem auto 0;
  background: var(--card); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 1rem 1.4rem;
  display: flex; align-items: center; gap: 0.9rem;
  animation: fade-in 0.2s ease;
}
.feedback-banner.correct { border-color: var(--green); background: rgba(74,222,128,0.08); }
.feedback-banner.wrong   { border-color: var(--rose);  background: rgba(251,113,133,0.08); }
.fb-icon { font-size: 1.5rem; flex-shrink: 0; }
.fb-text { flex: 1; font-size: 0.95rem; line-height: 1.4; }
.btn-next { flex-shrink: 0; }

.group-scores-strip { max-width: 620px; width: calc(100% - 3rem); margin: 0.8rem auto; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.gs-chip { background: var(--card2); border: 1px solid var(--border); border-radius: 99px; padding: 0.3rem 0.8rem; font-size: 0.78rem; display: flex; gap: 0.4rem; }
.gs-name { color: var(--text); }
.gs-score { color: var(--gold); font-weight: 700; font-family: var(--ff-head); }

.results-inner { max-width: 560px; margin: 0 auto; padding: 2rem 1.5rem 3rem; display: flex; flex-direction: column; align-items: center; gap: 1.2rem; }
.results-title { font-family: var(--ff-head); font-size: 1.6rem; font-weight: 800; text-align: center; }
.results-score-block { display: flex; align-items: baseline; gap: 0.3rem; }
.results-big-score { font-family: var(--ff-head); font-size: 4rem; font-weight: 800; color: var(--gold); line-height: 1; }
.results-of { font-size: 1.4rem; color: var(--muted); }
.results-pct { color: var(--muted); font-size: 0.9rem; }

.leaderboard-wrap, .review-wrap { width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.2rem 1.5rem; }
.leaderboard-title, .review-title { font-family: var(--ff-head); font-size: 0.75rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 0.8rem; }
.leaderboard-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.lb-row { display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 0.6rem; border-radius: 8px; background: var(--card2); }
.lb-rank { font-family: var(--ff-head); font-size: 0.8rem; color: var(--muted); width: 1.4rem; text-align: center; }
.lb-name { flex: 1; font-size: 0.9rem; }
.lb-score { font-family: var(--ff-head); font-weight: 700; color: var(--gold); }

.review-list { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.rv-row { display: flex; align-items: center; gap: 0.7rem; font-size: 0.88rem; padding: 0.4rem 0; border-bottom: 1px solid var(--border); }
.rv-row:last-child { border-bottom: none; }
.rv-icon { font-size: 1rem; flex-shrink: 0; }
.rv-lang { font-weight: 600; flex: 1; }
.rv-given { color: var(--muted); font-size: 0.8rem; }
.results-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; justify-content: center; }

.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.75); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.modal-overlay[hidden] { display: none; }
.modal-box { background: var(--card); border: 1px solid var(--border2); border-radius: var(--radius-lg); padding: 2rem; max-width: 560px; width: 100%; position: relative; box-shadow: var(--shadow); animation: fade-in 0.2s ease; max-height: 90vh; overflow-y: auto; }
.modal-narrow { max-width: 380px; }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--muted); font-size: 1rem; cursor: pointer; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; transition: color 0.15s; }
.modal-close:hover { color: var(--text); }
.modal-box h2 { font-family: var(--ff-head); font-size: 1.3rem; font-weight: 800; margin-bottom: 1.2rem; }
.modal-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 1rem; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 1.2rem; }
.info-block { background: var(--card2); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.info-icon { font-size: 1.4rem; }
.info-block strong { font-size: 0.88rem; font-weight: 600; }
.info-block p { font-size: 0.8rem; color: var(--muted); line-height: 1.5; }
.info-rules { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.info-rules li { font-size: 0.85rem; color: var(--muted); padding-left: 1.2rem; position: relative; line-height: 1.5; }
.info-rules li::before { content: '›'; position: absolute; left: 0; color: var(--gold); font-weight: 700; }
.info-rules em { color: var(--text); font-style: normal; }

.site-footer { border-top: 1px solid var(--border); text-align: center; padding: 1rem 1.5rem; font-size: 0.78rem; color: var(--muted); position: relative; z-index: 1; }
.site-footer a { color: var(--gold); text-decoration: none; transition: opacity 0.15s; }
.site-footer a:hover { opacity: 0.75; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

@media (max-width: 520px) {
  .site-title { font-size: 1.1rem; }
  .setup-card { padding: 1.4rem; }
  .media-panel { padding: 1.2rem; }
  .info-grid { grid-template-columns: 1fr; }
  .results-big-score { font-size: 3rem; }
}
