* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 clamp(1.5rem, 5vw, 5rem) 4rem;
  font-family: Georgia, "Noto Sans Georgian", serif;
  background: #f5f2ea;
  color: #2b2b2b;
}

header {
  max-width: 1400px;
  margin: 0 auto;
  text-align: center;
  padding: 2.5rem 0 1.5rem;
}

h1 {
  font-size: 2.2rem;
  margin: 0 0 0.5rem;
}

.subtitle {
  color: #555;
  margin: 0 auto;
  max-width: 640px;
  line-height: 1.5;
}

.layout {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 3rem;
  align-items: start;
}

main#quiz {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  min-width: 0;
}

.question {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.4rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.15s ease;
}

.question.answered {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.q-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  font-size: 0.85rem;
  color: #888;
}

.q-number {
  font-weight: bold;
  color: #555;
}

.q-tag {
  background: #eee5d3;
  color: #7a5c2e;
  padding: 0.15rem 0.6rem;
  border-radius: 10px;
  font-size: 0.8rem;
}

.question img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 1.1rem;
}

.prompt {
  margin: 0 0 0.9rem;
  font-weight: bold;
  font-size: 1.1rem;
  text-align: center;
}

.choices {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.choice {
  font-family: inherit;
  padding: 0.7rem 1.75rem;
  border: 2px solid #333;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  min-width: 150px;
  transition: transform 0.08s ease, background 0.15s ease;
}

.choice-label {
  font-size: 1.05rem;
  font-weight: bold;
}

.choice-sub {
  font-size: 0.75rem;
  color: #777;
}

.choice:hover:not(:disabled) {
  background: #f0ede4;
  transform: translateY(-1px);
}

.choice:active:not(:disabled) {
  transform: translateY(0);
}

.choice:disabled {
  cursor: default;
}

.choice.selected {
  background: #eee5d3;
  border-color: #7a5c2e;
}

.choice.correct {
  background: #cfead2;
  border-color: #4a9a56;
}

.choice.correct .choice-sub { color: #2e6b37; }

.choice.wrong {
  background: #f3cfcf;
  border-color: #b44646;
}

.choice.wrong .choice-sub { color: #8a2e2e; }

/* sidebar */
.sidebar {
  position: sticky;
  top: 5.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats-box,
.suggestions-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.3rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.sidebar h2 {
  font-size: 1.1rem;
  margin: 0 0 1rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid #eee;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.5rem 0;
  border-bottom: 1px dashed #eee;
  font-size: 0.9rem;
  color: #555;
}

.stat-row:last-child { border-bottom: none; }

.stat-row strong {
  color: #2b2b2b;
  text-align: right;
}

/* leaderboard */
#leaderboard {
  margin: 0;
  padding: 0 0 0 1.4rem;
  list-style: decimal;
}

#leaderboard li {
  display: flex;
  justify-content: space-between;
  padding: 0.45rem 0;
  border-bottom: 1px dashed #eee;
  font-size: 0.9rem;
}

#leaderboard li:last-child { border-bottom: none; }

#leaderboard li.me {
  font-weight: bold;
  color: #7a5c2e;
}

.lb-name { color: #444; }
.lb-score { color: #888; }
#leaderboard li.me .lb-score { color: #7a5c2e; }

.lb-loading {
  color: #999;
  font-size: 0.85rem;
  list-style: none;
  margin-left: -1.4rem;
}

/* progress bar */
.progress-bar-sticky {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #f5f2ea;
  padding: 0.9rem clamp(1.5rem, 5vw, 5rem) 0.7rem;
  margin: 0 calc(-1 * clamp(1.5rem, 5vw, 5rem)) 1.5rem;
  box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.08);
}

.progress-bar-wrap {
  max-width: 1400px;
  margin: 0 auto;
}

.progress-bar-track {
  height: 8px;
  background: #e6e1d3;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: #2b2b2b;
  transition: width 0.2s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #777;
  margin-top: 0.4rem;
}

#timer {
  font-variant-numeric: tabular-nums;
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
  }
}

footer {
  max-width: 700px;
  margin: 2.5rem auto 0;
  text-align: center;
}

#nickname {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  width: 100%;
  max-width: 360px;
  margin-bottom: 1rem;
}

#submitBtn {
  font-family: inherit;
  font-size: 1.1rem;
  padding: 0.75rem 2.5rem;
  border: none;
  border-radius: 6px;
  background: #2b2b2b;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  transition: background 0.15s ease, transform 0.08s ease;
}

#submitBtn:hover {
  background: #444;
  transform: translateY(-1px);
}

#submitBtn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}

#result {
  margin-top: 1.2rem;
  font-size: 1.15rem;
}

#result.final { font-weight: bold; }
#result.incomplete { color: #8a2e2e; }

.hidden { display: none !important; }

.consent-note {
  margin-top: 0.9rem;
  font-size: 0.8rem;
  color: #888;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
}

.consent-note a {
  color: #7a5c2e;
}

/* tos modal */
.tos-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 10;
}

.tos-box {
  background: #fff;
  border-radius: 6px;
  padding: 1.8rem;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.tos-box h2 {
  margin-top: 0;
}

.tos-scroll {
  overflow-y: auto;
  padding-right: 0.5rem;
  margin-bottom: 1rem;
}

.tos-scroll h3 {
  font-size: 0.98rem;
  margin: 1.1rem 0 0.4rem;
}

.tos-scroll h3:first-child {
  margin-top: 0;
}

.tos-box p {
  font-size: 0.92rem;
  line-height: 1.5;
  color: #444;
  margin: 0 0 0.5rem;
}

#closeTos {
  align-self: center;
}

#closeTos {
  font-family: inherit;
  padding: 0.5rem 1.4rem;
  border: none;
  border-radius: 6px;
  background: #2b2b2b;
  color: #fff;
  cursor: pointer;
}
