@font-face {
  font-family: "Nokia Pure Headline";
  src: url("/fonts/NokiaPureHeadline_Regular.ttf") format("truetype");
  font-weight: 400;
}

@font-face {
  font-family: "Nokia Pure Headline";
  src: url("/fonts/NokiaPureHeadline_Bold.ttf") format("truetype");
  font-weight: 700;
}

@font-face {
  font-family: "Nokia Pure Headline";
  src: url("/fonts/NokiaPureHeadline_Light.ttf") format("truetype");
  font-weight: 300;
}

@font-face {
  font-family: "Nokia Pure Text";
  src: url("/fonts/NokiaPureText-Light.ttf") format("truetype");
  font-weight: 300;
}

@font-face {
  font-family: "Nokia Pure Text";
  src: url("/fonts/NokiaPureText-Bold.ttf") format("truetype");
  font-weight: 700;
}

/* ─── Design Tokens ─── */
:root {
  --black: #0a0a0a;
  --ink: #1a1a1a;
  --soft-ink: #6b6b6b;
  --muted: #999999;
  --line: #e8e8e8;
  --line-light: #f2f2f2;
  --surface: #ffffff;
  --page: #ffffff;
  --accent: #0a0a0a;
  --accent-soft: rgba(10, 10, 10, 0.06);
  --green: #1a8d5f;
  --green-bg: rgba(26, 141, 95, 0.06);
  --green-border: rgba(26, 141, 95, 0.25);
  --red: #d44040;
  --red-bg: rgba(212, 64, 64, 0.06);
  --red-border: rgba(212, 64, 64, 0.25);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ─── */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "Nokia Pure Text", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 300;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input {
  font: inherit;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2 {
  font-family: "Nokia Pure Headline", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 300;
  letter-spacing: -0.02em;
  color: var(--black);
}

h1 {
  font-size: clamp(2.2rem, 4.5vw, 3.8rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
}

/* ─── Layout Shell ─── */
.app-shell {
  width: min(860px, calc(100% - 48px));
  margin: 0 auto;
  padding: 2vh 0; /* Reduced padding to fit screen height */
}

/* ─── Brand Strip ─── */
.brand-strip {
  display: flex;
  justify-content: center;
  text-align: center;
  gap: 24px;
  align-items: center;
  min-height: auto;
  padding: 16px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.brand-strip:hover {
  box-shadow: var(--shadow-md);
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.muted {
  color: var(--soft-ink);
  line-height: 1.6;
  font-size: 0.95rem;
}

.status-pill {
  min-width: 90px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface);
  transition: all var(--transition);
}

/* ─── Panels ─── */
.panel {
  display: none;
  margin-top: 16px;
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: panelFadeIn 0.5s ease both;
}

.view.active {
  display: block;
}

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

/* ─── Start View: 2-Column Layout ─── */
.start-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  align-items: stretch;
}

.start-left {
  padding: 8px 40px 8px 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 24px;
  justify-content: space-between;
}

.start-right {
  padding: 8px 0 8px 40px;
  display: flex;
  flex-direction: column;
}

/* ─── Left: Hero ─── */
.start-hero h2 {
  margin-top: 6px;
  font-size: clamp(1.6rem, 2.8vw, 2.2rem);
}

.start-hero .muted {
  margin-top: 10px;
  font-size: 0.9rem;
}

/* ─── Left: Form ─── */
.start-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.start-form label {
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.start-submit {
  width: 100%;
  height: 52px;
  font-size: 0.95rem;
  border-radius: var(--radius);
  margin-top: 4px;
}

/* ─── Left: Stats strip ─── */
.start-stats {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 20px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  margin-top: 0;
}

.stat-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.stat-num {
  font-family: "Nokia Pure Headline", sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--black);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stat-divider {
  width: 1px;
  height: 36px;
  background: var(--line);
  flex-shrink: 0;
}

/* ─── Right: Leaderboard panel ─── */
.leaderboard-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: flex-start;
}

.leaderboard-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.leaderboard-panel-header h2 {
  font-size: 1.15rem;
  margin-top: 4px;
}

.leaderboard-panel .leaderboard {
  flex: 1;
  margin: 0;
  padding-right: 4px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input {
  min-height: 50px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 18px;
  color: var(--ink);
  background: var(--surface);
  font-size: 0.95rem;
  transition: all var(--transition);
}

input::placeholder {
  color: var(--muted);
}

input:focus {
  border-color: var(--black);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

.form-error {
  min-height: 24px;
  margin-top: 8px;
  color: var(--red);
  font-size: 0.85rem;
}

/* ─── Buttons ─── */
.primary-button,
.ghost-button,
.answer-button {
  min-height: 48px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 24px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  transition: all var(--transition);
}

.primary-button {
  color: white;
  background: var(--black);
  box-shadow: var(--shadow-sm);
}

.primary-button:hover {
  background: #2a2a2a;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.primary-button:disabled,
.answer-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.ghost-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
}

.ghost-button:hover {
  border-color: var(--black);
  background: var(--accent-soft);
}

/* ─── Leaderboard ─── */
.leaderboard-block {
  border-top: 1px solid var(--line-light);
  padding-top: 28px;
  margin-top: 8px;
}

.block-header,
.game-topline,
.question-meta,
.leaderboard li,
.rank-eleven {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.leaderboard {
  display: grid;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.leaderboard li,
.rank-eleven {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 16px;
  background: var(--surface);
  transition: all var(--transition);
}

.leaderboard li:hover {
  border-color: var(--black);
  box-shadow: var(--shadow-sm);
}

.leaderboard .rank {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-right: 10px;
  border-radius: 50%;
  color: white;
  background: var(--black);
  font-weight: 700;
  font-size: 0.78rem;
}

/* Gold, silver, bronze for top 3 */
.leaderboard li:nth-child(1) .rank {
  background: #1a1a1a;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.08);
}

.leaderboard li:nth-child(2) .rank {
  background: #444;
}

.leaderboard li:nth-child(3) .rank {
  background: #777;
}

.leaderboard .name {
  font-weight: 700;
  font-size: 0.92rem;
}

.leaderboard .meta,
.rank-eleven {
  color: var(--muted);
  font-size: 0.85rem;
}

.score {
  color: var(--black);
  font-weight: 700;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
}

/* ─── Game View: Top Line ─── */
.game-topline {
  align-items: flex-start;
}

.home-button {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.8rem;
  border-radius: var(--radius);
  flex-shrink: 0;
  align-self: center;
}

.score-box {
  min-width: 100px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: center;
  background: var(--surface);
  transition: all var(--transition);
}

.score-box span {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.score-box strong {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--black);
}

/* ─── Progress Bar ─── */
.progress-track {
  height: 3px;
  margin: 28px 0;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--line-light);
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--black);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Question Card ─── */
.question-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 32px;
  background: var(--surface);
  transition: box-shadow var(--transition);
  animation: cardAppear 0.4s ease both;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.question-meta {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.question-text {
  margin: 24px 0 28px;
  font-family: "Nokia Pure Headline", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(1.2rem, 2.2vw, 1.65rem);
  font-weight: 400;
  line-height: 1.4;
  color: var(--black);
}

/* ─── Answer Buttons ─── */
.answers {
  display: grid;
  gap: 10px;
}

.answer-button {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 14px;
  align-items: center;
  min-height: 60px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  padding: 12px 16px;
  font-size: 0.92rem;
  animation: answerSlide 0.35s ease both;
}

.answer-button:nth-child(1) { animation-delay: 0.05s; }
.answer-button:nth-child(2) { animation-delay: 0.1s; }
.answer-button:nth-child(3) { animation-delay: 0.15s; }
.answer-button:nth-child(4) { animation-delay: 0.2s; }

@keyframes answerSlide {
  from {
    opacity: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.answer-button:hover:not(:disabled) {
  border-color: var(--black);
  background: var(--accent-soft);
  transform: translateX(4px);
}

.answer-button:active:not(:disabled) {
  transform: translateX(2px);
}

.answer-key {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: white;
  background: var(--black);
  font-weight: 700;
  font-size: 0.82rem;
  transition: all var(--transition);
}

.answer-button:hover:not(:disabled) .answer-key {
  border-radius: 50%;
}

/* Correct / Wrong States */
.answer-button.correct {
  border-color: var(--green-border);
  background: var(--green-bg);
  animation: correctPulse 0.5s ease;
}

.answer-button.correct .answer-key {
  background: var(--green);
  border-radius: 50%;
}

.answer-button.wrong {
  border-color: var(--red-border);
  background: var(--red-bg);
  animation: wrongShake 0.4s ease;
}

.answer-button.wrong .answer-key {
  background: var(--red);
  border-radius: 50%;
}

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

/* ─── Score Popup ─── */
.score-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.5);
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: scorePop 1.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.score-popup-points {
  font-family: "Nokia Pure Headline", sans-serif;
  font-size: clamp(3.5rem, 10vw, 6rem);
  font-weight: 700;
  color: var(--black);
  line-height: 1;
  letter-spacing: -0.04em;
}

.score-popup-label {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--soft-ink);
}

@keyframes scorePop {
  0% {
    opacity: 0;
    transform: translate(-50%, -40%) scale(0.5);
  }
  25% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
  }
  55% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -65%) scale(0.9);
  }
}

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

/* ─── Feedback Panel ─── */
.feedback {
  margin-top: 20px;
  border-left: 3px solid var(--black);
  border-radius: var(--radius);
  padding: 24px;
  background: var(--accent-soft);
  animation: feedbackSlide 0.35s ease both;
}

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

.feedback strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1rem;
  color: var(--black);
}

.feedback p {
  color: var(--soft-ink);
  font-size: 0.9rem;
  line-height: 1.6;
}

.feedback .primary-button {
  margin-top: 16px;
}

/* ─── End View ─── */
.end-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.end-hero-left {
  padding: 8px 40px 8px 0;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
}

.end-hero-right {
  padding: 8px 0 8px 40px;
  display: flex;
  flex-direction: column;
}

/* Score display */
.end-score-display {
  display: flex;
  align-items: baseline;
  gap: 10px;
  line-height: 1;
}

.end-score-number {
  font-family: "Nokia Pure Headline", sans-serif;
  font-size: clamp(4rem, 10vw, 7.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--black);
  font-variant-numeric: tabular-nums;
  animation: scoreReveal 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

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

.end-score-unit {
  font-family: "Nokia Pure Headline", sans-serif;
  font-size: clamp(1.2rem, 2.5vw, 1.8rem);
  font-weight: 300;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.end-tagline {
  font-size: clamp(1.4rem, 2.5vw, 1.9rem);
  font-weight: 300;
  color: var(--black);
  letter-spacing: -0.01em;
  margin: 0;
}

.end-rank-label {
  font-size: 0.88rem;
  color: var(--soft-ink);
  line-height: 1.5;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  display: inline-block;
}

.end-actions {
  margin-top: 8px;
}

.end-actions .primary-button {
  min-width: 160px;
}

/* Leaderboard right column */
.end-leaderboard-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.end-lb-title {
  font-family: "Nokia Pure Headline", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--black);
  margin: 4px 0 14px;
  letter-spacing: -0.01em;
}

.end-leaderboard-wrap .leaderboard {
  flex: 1;
  margin: 0;
  padding-right: 4px;
}

/* ─── Rank Eleven ─── */
.rank-eleven {
  margin-top: 10px;
  border-color: var(--line);
  background: var(--accent-soft);
  font-size: 0.88rem;
}

/* ─── Decorative Divider ─── */
.leaderboard-block .block-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ─── Responsive ─── */
@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 24px, 860px);
    padding-top: 16px;
    padding-bottom: 60px;
  }

  .brand-strip,
  .game-topline,
  .block-header {
    display: block;
  }

  .brand-strip,
  .panel {
    padding: 20px;
  }

  .question-card {
    padding: 20px;
  }

  .status-pill,
  .primary-button,
  .ghost-button {
    width: 100%;
    margin-top: 12px;
  }

  .score-box {
    margin-top: 14px;
    text-align: center;
  }

  .leaderboard li,
  .rank-eleven {
    align-items: flex-start;
  }

  /* Collapse end-hero to single column on mobile */
  .end-hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .end-hero-left {
    padding: 0 0 28px 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    justify-content: flex-start;
  }

  .end-hero-right {
    padding: 28px 0 0 0;
  }

  .end-score-number {
    font-size: clamp(3rem, 15vw, 5rem);
  }

  .end-leaderboard-wrap .leaderboard {
    max-height: 260px;
  }

  /* Collapse 2-column into single column on mobile */
  .start-columns {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .start-left {
    padding: 0 0 28px 0;
    border-right: none;
    border-bottom: 1px solid var(--line);
    gap: 20px;
  }

  .start-right {
    padding: 28px 0 0 0;
  }

  .start-submit {
    width: 100%;
  }

  .stat-divider {
    height: 24px;
  }

  .stat-num {
    font-size: 1.3rem;
  }

  .leaderboard-panel .leaderboard,
  .end-leaderboard-wrap .leaderboard {
    max-height: none;
  }
}


/* ─── Subtle page dot pattern ─── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.03) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: -1;
}

/* ─── Selection color ─── */
::selection {
  background: rgba(0, 0, 0, 0.08);
  color: var(--black);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted);
}
