:root {
  color-scheme: light;
  --ink: #16201f;
  --muted: #5f6b67;
  --paper: #f4efe5;
  --panel: #fffdf8;
  --line: #d9d0c1;
  --correct: #2f7d59;
  --present: #c98a22;
  --absent: #707a78;
  --accent: #9b2f3d;
  --accent-dark: #762530;
  --key: #e6ded0;
  --gold: #d6a441;
  --shadow: 0 20px 60px rgba(35, 28, 19, 0.16);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 16% 8%, rgba(155, 47, 61, 0.16), transparent 28%),
    radial-gradient(circle at 86% 18%, rgba(47, 125, 89, 0.16), transparent 25%),
    linear-gradient(180deg, rgba(255, 253, 248, 0.85), rgba(244, 239, 229, 0.98)),
    var(--paper);
  color: var(--ink);
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  width: min(100%, 880px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px clamp(14px, 3vw, 30px) 30px;
}

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0 18px;
  border-bottom: 1px solid rgba(118, 37, 48, 0.16);
}

.title-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.eyebrow,
.label,
.source-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 8vw, 4.6rem);
  line-height: 0.95;
  color: var(--accent-dark);
}

.icon-button,
.install-button,
.secondary-button,
.key {
  border: 1px solid rgba(22, 32, 31, 0.12);
  background: var(--panel);
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.icon-button {
  width: 48px;
  height: 48px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 1.35rem;
  font-weight: 800;
}

.install-button {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: #fff8eb;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
  font-weight: 850;
  white-space: nowrap;
}

.install-button.unavailable {
  background: rgba(255, 253, 248, 0.86);
  color: var(--accent-dark);
}

.install-button.guide {
  background: #2f7d59;
  color: #fff8eb;
}

.invite-button {
  background: rgba(255, 253, 248, 0.9);
  color: var(--accent-dark);
}

.icon-button:hover,
.install-button:hover,
.secondary-button:hover,
.key:hover,
.tab-button:hover,
.quiz-option:hover {
  transform: translateY(-1px);
  border-color: rgba(22, 32, 31, 0.3);
}

.game-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
  padding: 6px;
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 10px;
  background: rgba(255, 253, 248, 0.62);
}

.tab-button,
.quiz-option {
  border: 1px solid rgba(22, 32, 31, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.88);
  cursor: pointer;
  font-weight: 850;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease;
}

.tab-button {
  padding: 12px;
}

.tab-button.active,
.tab-button.active {
  border-color: rgba(118, 37, 48, 0.32);
  background: var(--accent-dark);
  color: #fff8eb;
}

.special-banner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin: -4px 0 16px;
  padding: 12px 14px;
  overflow: hidden;
  border: 1px solid rgba(118, 37, 48, 0.18);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 253, 248, 0.92), rgba(255, 247, 224, 0.96), rgba(255, 253, 248, 0.92)),
    var(--panel);
  box-shadow: 0 10px 28px rgba(35, 28, 19, 0.1);
}

.special-banner-track {
  display: flex;
  min-width: 0;
  overflow: hidden;
  mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent);
}

.special-banner-copy {
  display: grid;
  min-width: max-content;
  padding-right: 46px;
  animation: bannerRun 16s linear infinite;
}

.special-banner .flag {
  font-size: 1.35rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgba(35, 28, 19, 0.16));
  animation: flagLift 2400ms ease-in-out infinite;
}

.special-banner .flag:last-child {
  animation-delay: 600ms;
}

.special-banner strong {
  display: block;
  margin-top: 2px;
  color: var(--accent-dark);
  font-size: clamp(0.9rem, 2.4vw, 1rem);
  line-height: 1.25;
}

@keyframes flagLift {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2px);
  }
}

@keyframes bannerRun {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

.celebration-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  overflow: hidden;
}

.tricolor-ribbon {
  position: absolute;
  left: 50%;
  top: 18%;
  width: min(86vw, 620px);
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff9933 0 33%, #fffdf8 33% 66%, #138808 66% 100%);
  box-shadow: 0 10px 28px rgba(35, 28, 19, 0.16);
  transform: translate(-50%, -24px) scaleX(0.2);
  animation: ribbonSweep 1500ms ease-out forwards;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.96;
  animation: confettiFall var(--fall-duration, 1900ms) ease-out forwards;
}

@keyframes ribbonSweep {
  0% {
    opacity: 0;
    transform: translate(-50%, -24px) scaleX(0.2);
  }
  22% {
    opacity: 1;
  }
  60% {
    transform: translate(-50%, 0) scaleX(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 12px) scaleX(1);
  }
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, -20px, 0) rotate(0deg);
  }
  100% {
    transform: translate3d(var(--drift, 0px), 105vh, 0) rotate(var(--spin, 220deg));
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .special-banner-copy,
  .special-banner .flag,
  .confetti-piece,
  .tricolor-ribbon {
    animation: none;
  }

  .celebration-layer {
    display: none;
  }
}

.site-share-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin: 0;
  padding: 18px;
  border: 1px solid rgba(118, 37, 48, 0.14);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.94), rgba(246, 232, 198, 0.76)),
    var(--panel);
  box-shadow: 0 12px 34px rgba(35, 28, 19, 0.1);
}

.site-share-copy strong {
  display: block;
  margin-top: 3px;
  font-size: 1.08rem;
}

.site-share-copy h2 {
  margin: 5px 32px 0 0;
  color: var(--accent-dark);
  font-size: 1.35rem;
  line-height: 1.15;
}

.site-share-copy p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.site-qr-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-qr-code {
  width: 96px;
  height: 96px;
  padding: 7px;
  border: 1px solid rgba(22, 32, 31, 0.12);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.site-qr-code.pending {
  display: none;
}

.account-panel {
  margin: 18px 0 12px;
  padding: 0;
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.54);
}

.account-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}

.account-summary::-webkit-details-marker {
  display: none;
}

.account-summary-action {
  border: 1px solid rgba(118, 37, 48, 0.18);
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255, 253, 248, 0.8);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.account-panel[open] .account-summary {
  border-bottom: 1px solid rgba(22, 32, 31, 0.08);
}

.account-panel[open] .account-summary-action {
  background: var(--accent-dark);
  color: #fff8eb;
}

.account-panel-body {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(280px, 1fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
}

.account-help-button {
  justify-self: start;
  grid-column: 2;
  margin-top: 0;
}

.account-copy strong {
  display: block;
  margin-top: 3px;
  font-size: 1rem;
}

.account-copy p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.account-form-note {
  align-self: start;
  grid-row: span 3;
}

.account-form {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.account-form input {
  width: min(100%, 230px);
  min-height: 42px;
  border: 1px solid rgba(22, 32, 31, 0.16);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  padding: 0 11px;
}

.username-field {
  display: flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  text-transform: uppercase;
}

.username-field input {
  text-transform: none;
}

.secondary-button.subtle {
  background: rgba(255, 253, 248, 0.64);
}

.status-strip {
  display: grid;
  grid-template-columns: 1.5fr 0.75fr 0.75fr 0.55fr;
  gap: 8px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.5);
  padding: 8px;
  box-shadow: 0 12px 36px rgba(36, 29, 19, 0.1);
}

.status-strip > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(22, 32, 31, 0.08);
  border-radius: 7px;
  background: rgba(255, 253, 248, 0.88);
}

.status-strip strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.98rem;
}

.board-wrap {
  display: grid;
  place-items: center;
  margin: 24px 0 16px;
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid rgba(118, 37, 48, 0.12);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.88), rgba(240, 231, 216, 0.72)),
    var(--panel);
  box-shadow: var(--shadow);
}

.board {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  gap: 8px;
  width: min(100%, var(--board-max, 360px));
}

.row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: 8px;
}

.tile {
  display: grid;
  place-items: center;
  border: 2px solid #c9beab;
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  color: var(--ink);
  aspect-ratio: 1;
  font-size: var(--tile-font, 2.35rem);
  font-weight: 850;
  text-transform: uppercase;
  user-select: none;
}

.tile.filled {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
  animation: pop 110ms ease-out;
}

.tile.correct,
.key.correct {
  background: var(--correct);
  border-color: var(--correct);
  color: white;
}

.tile.correct,
.tile.present,
.tile.absent {
  animation: tileReveal 420ms ease both;
}

.row .tile:nth-child(2) {
  animation-delay: 55ms;
}

.row .tile:nth-child(3) {
  animation-delay: 110ms;
}

.row .tile:nth-child(4) {
  animation-delay: 165ms;
}

.row .tile:nth-child(5) {
  animation-delay: 220ms;
}

.row .tile:nth-child(6) {
  animation-delay: 275ms;
}

.row .tile:nth-child(7) {
  animation-delay: 330ms;
}

.row .tile:nth-child(8) {
  animation-delay: 385ms;
}

.row .tile:nth-child(9) {
  animation-delay: 440ms;
}

.row .tile:nth-child(10) {
  animation-delay: 495ms;
}

.row .tile:nth-child(11) {
  animation-delay: 550ms;
}

.row .tile:nth-child(12) {
  animation-delay: 605ms;
}

.tile.present,
.key.present {
  background: var(--present);
  border-color: var(--present);
  color: white;
}

.tile.absent,
.key.absent {
  background: var(--absent);
  border-color: var(--absent);
  color: white;
}

.message {
  display: table;
  min-height: 30px;
  margin: 0 auto 18px;
  padding: 7px 12px;
  border: 1px solid rgba(155, 47, 61, 0.13);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--accent-dark);
  font-weight: 750;
  text-align: center;
}

.message.pulse {
  animation: messagePulse 260ms ease;
}

.keyboard {
  display: grid;
  gap: 7px;
  margin: 0 auto;
  width: min(100%, 620px);
}

.key-row {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.key {
  display: grid;
  place-items: center;
  min-width: 0;
  height: 46px;
  flex: 1 1 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #efe7da, var(--key));
  font-size: 0.92rem;
  font-weight: 850;
  text-transform: uppercase;
}

.key.wide {
  flex: 1.55 1 0;
  font-size: 0.76rem;
}

.key.enter-key {
  flex: 1.55 1 0;
  padding-inline: 0;
  font-size: 1.2rem;
}

.tool-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
}

.secondary-button {
  min-width: 108px;
  padding: 11px 14px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), #f0e7d8);
  font-weight: 800;
}

.install-sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 18px;
  background: rgba(22, 32, 31, 0.42);
}

.install-sheet[hidden] {
  display: none;
}

.install-panel {
  position: relative;
  width: min(100%, 440px);
  padding: 22px;
  border: 1px solid rgba(118, 37, 48, 0.16);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(22, 32, 31, 0.26);
}

.sheet-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(22, 32, 31, 0.12);
  border-radius: 999px;
  background: #fffdf8;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 800;
}

.install-panel h2 {
  margin: 6px 42px 16px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1.05;
  color: var(--accent-dark);
}

.install-steps {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: install-step;
}

.install-steps li {
  position: relative;
  min-height: 54px;
  padding: 10px 12px 10px 54px;
  border: 1px solid rgba(118, 37, 48, 0.12);
  border-radius: 10px;
  background: #fffdf8;
  counter-increment: install-step;
}

.install-steps li::before {
  content: counter(install-step);
  position: absolute;
  top: 12px;
  left: 12px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: #fff8eb;
  font-weight: 850;
}

.install-steps strong,
.install-steps span {
  display: block;
}

.install-steps strong {
  color: var(--ink);
  font-size: 0.96rem;
}

.install-steps span,
.install-note {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.42;
}

.install-note {
  margin: 14px 0 0;
}

.quiz-shell {
  margin-top: 18px;
}

.quiz-header,
.quiz-card {
  border: 1px solid rgba(118, 37, 48, 0.12);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 253, 248, 0.9), rgba(240, 231, 216, 0.72)),
    var(--panel);
  box-shadow: var(--shadow);
}

.quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.quiz-header h2 {
  margin: 2px 0 0;
  color: var(--accent-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 6vw, 2.6rem);
  line-height: 1;
}

.quiz-header strong {
  flex: 0 0 auto;
  color: var(--accent-dark);
}

.quiz-card {
  padding: clamp(16px, 4vw, 24px);
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.quiz-card h3 {
  margin: 14px 0 18px;
  font-size: clamp(1.15rem, 4vw, 1.65rem);
  line-height: 1.28;
}

.quiz-options {
  display: grid;
  gap: 10px;
}

.quiz-option {
  width: 100%;
  padding: 13px 14px;
  text-align: left;
  line-height: 1.35;
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.92;
}

.quiz-option.correct {
  border-color: var(--correct);
  background: var(--correct);
  color: white;
  animation: optionSettle 360ms ease both;
}

.quiz-option.incorrect {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  animation: optionSettle 360ms ease both;
}

.quiz-feedback {
  min-height: 28px;
  margin: 14px 0 0;
  color: var(--accent-dark);
  font-weight: 800;
}

.answer-explanation {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(118, 37, 48, 0.12);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.76);
}

.answer-explanation p {
  margin: 6px 0 0;
  line-height: 1.5;
}

.did-you-know-trigger {
  margin-top: 12px;
}

.did-you-know {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(47, 125, 89, 0.18);
  border-radius: 8px;
  background: rgba(237, 246, 240, 0.86);
}

.did-you-know:not([hidden]) {
  animation: revealPanel 300ms ease both;
}

.did-you-know p {
  margin: 7px 0 0;
  line-height: 1.5;
}

.answer-panel {
  margin: 18px auto 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.92);
  box-shadow: var(--shadow);
}

.answer-panel:not([hidden]) {
  animation: revealPanel 320ms ease both;
}

.answer-panel h2 {
  margin: 2px 0 8px;
  font-size: 1.9rem;
  letter-spacing: 0;
}

.answer-source {
  display: inline-block;
  margin: 0;
  padding: 5px 8px;
  border: 1px solid rgba(22, 32, 31, 0.12);
  border-radius: 999px;
  background: #f0e7d8;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 850;
}

.answer-panel p {
  margin: 8px 0 0;
  line-height: 1.55;
}

.answer-panel a {
  color: var(--accent-dark);
  font-weight: 850;
}

.answer-link {
  font-size: 0.9rem;
}

.stats-panel {
  margin: 18px auto 0;
  padding: 18px;
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: 0 12px 34px rgba(36, 29, 19, 0.09);
}

.stats-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.stats-heading strong {
  color: var(--accent-dark);
  font-size: 0.92rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.stats-grid > div {
  min-width: 0;
  padding: 11px;
  border: 1px solid rgba(22, 32, 31, 0.08);
  border-radius: 7px;
  background: rgba(244, 239, 229, 0.78);
}

.leaderboard-shell {
  margin-top: 18px;
}

.leaderboard-status {
  margin: 12px 0;
  color: var(--accent-dark);
  font-weight: 800;
}

.leaderboard-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.leaderboard-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.72);
}

.leaderboard-toggle-button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 850;
}

.leaderboard-toggle-button.active {
  background: var(--accent-dark);
  color: #fff8eb;
}

.pulse-shell {
  margin-top: 18px;
}

.pulse-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.pulse-card,
.pulse-panel {
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 12px 34px rgba(36, 29, 19, 0.08);
}

.pulse-card {
  padding: 15px;
}

.pulse-card strong {
  display: block;
  margin-top: 4px;
  color: var(--accent-dark);
  font-size: clamp(1.55rem, 5vw, 2.35rem);
  line-height: 1;
}

.pulse-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.pulse-panel {
  margin-top: 14px;
  padding: 16px;
}

.difficulty-rows {
  display: grid;
  gap: 10px;
}

.difficulty-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(120px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.difficulty-row strong,
.difficulty-row span {
  display: block;
}

.difficulty-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.difficulty-bar {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(22, 32, 31, 0.1);
}

.difficulty-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--correct);
}

.leaderboard-table {
  overflow: hidden;
  border: 1px solid rgba(22, 32, 31, 0.1);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.86);
  box-shadow: 0 12px 34px rgba(36, 29, 19, 0.09);
}

.leaderboard-head,
.leaderboard-row {
  display: grid;
  grid-template-columns: 0.45fr minmax(105px, 1.1fr) 0.55fr minmax(170px, 1.45fr) minmax(170px, 1.45fr) 0.55fr;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
}

.leaderboard-head {
  background: rgba(118, 37, 48, 0.08);
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
}

.leaderboard-row {
  border-top: 1px solid rgba(22, 32, 31, 0.08);
}

.leaderboard-row strong {
  color: var(--accent-dark);
}

.rank-cell,
.score-cell,
.streak-cell {
  font-weight: 900;
}

.performance-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metric-chip {
  display: inline-flex;
  gap: 5px;
  align-items: baseline;
  padding: 5px 7px;
  border: 1px solid rgba(22, 32, 31, 0.09);
  border-radius: 999px;
  background: rgba(244, 239, 229, 0.78);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}

.metric-chip small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-chip b {
  color: var(--ink);
  font-size: 0.78rem;
}

.site-footer {
  display: flex;
  justify-content: center;
  margin: 28px 0 0;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.privacy-sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(22, 32, 31, 0.42);
}

.privacy-panel {
  position: relative;
  width: min(100%, 680px);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(22, 32, 31, 0.12);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.privacy-panel h2 {
  margin: 4px 0 12px;
  color: var(--accent-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 5vw, 2.2rem);
}

.privacy-panel h3 {
  margin: 18px 0 6px;
  color: var(--ink);
  font-size: 1rem;
}

.privacy-panel p,
.privacy-panel li {
  color: var(--muted);
  line-height: 1.55;
}

.privacy-panel ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.stats-grid strong {
  display: block;
  margin-top: 2px;
  font-size: 1.25rem;
}

.wizard-badge {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(214, 164, 65, 0.5);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(118, 37, 48, 0.95), rgba(155, 47, 61, 0.9));
  color: #fff8eb;
}

.wizard-badge[hidden] {
  display: none !important;
}

.medal-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: radial-gradient(circle at 32% 28%, #fff2bd, var(--gold) 48%, #a86919 100%);
  box-shadow: inset 0 0 0 3px rgba(255, 248, 235, 0.38), 0 8px 18px rgba(36, 29, 19, 0.25);
}

.medal-icon svg {
  width: 46px;
  height: 46px;
}

.medal-icon circle {
  fill: transparent;
  stroke: rgba(118, 37, 48, 0.78);
  stroke-width: 4;
}

.medal-icon path {
  fill: var(--accent-dark);
}

.wizard-badge span {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.05rem, 4vw, 1.28rem);
  font-weight: 850;
  line-height: 1.08;
}

.wizard-badge p {
  margin: 4px 0 0;
  color: rgba(255, 248, 235, 0.86);
  font-weight: 750;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.sample {
  display: inline-block;
  width: 13px;
  height: 13px;
  margin-right: 5px;
  border-radius: 3px;
  vertical-align: -2px;
}

.sample.correct {
  background: var(--correct);
}

.sample.present {
  background: var(--present);
}

.sample.absent {
  background: var(--absent);
}

@keyframes pop {
  50% {
    transform: scale(1.06);
  }
}

@keyframes tileReveal {
  0% {
    opacity: 0.72;
    transform: rotateX(72deg) scale(0.98);
  }

  55% {
    transform: rotateX(-8deg) scale(1.02);
  }

  100% {
    opacity: 1;
    transform: rotateX(0) scale(1);
  }
}

@keyframes revealPanel {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes optionSettle {
  0% {
    transform: translateY(4px);
  }

  100% {
    transform: translateY(0);
  }
}

@keyframes messagePulse {
  50% {
    transform: scale(1.025);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-top: 12px;
  }

  .masthead {
    align-items: flex-start;
  }

  .header-actions {
    flex-direction: column-reverse;
    align-items: flex-end;
  }

  .install-button {
    min-height: 38px;
    padding: 0 11px;
    font-size: 0.78rem;
  }

  .account-panel {
    margin-top: -2px;
  }

  .account-summary,
  .account-panel-body {
    grid-template-columns: 1fr;
  }

  .account-summary-action {
    justify-self: start;
  }

  .account-help-button {
    grid-column: auto;
    justify-self: start;
    margin-top: 0;
  }

  .account-form {
    flex-direction: column;
    align-items: stretch;
  }

  .account-form input {
    width: 100%;
  }

  .username-field {
    display: grid;
    gap: 5px;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .game-tabs {
    grid-template-columns: 1fr;
  }

  .site-share-card,
  .site-qr-wrap {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .site-share-card {
    display: grid;
  }

  .site-qr-wrap {
    display: grid;
  }

  .site-qr-code {
    justify-self: center;
  }

  .pulse-grid {
    grid-template-columns: 1fr;
  }

  .difficulty-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .leaderboard-head,
  .leaderboard-row {
    grid-template-columns: 0.45fr minmax(92px, 1fr) 0.55fr;
  }

  .leaderboard-head span:nth-child(4),
  .leaderboard-head span:nth-child(5),
  .leaderboard-head span:nth-child(6),
  .leaderboard-row > .performance-cell,
  .leaderboard-row > .streak-cell {
    display: none;
  }

  .status-strip strong {
    white-space: normal;
  }

  .board {
    width: min(100%, var(--board-max, 330px));
    gap: 7px;
  }

  .row {
    gap: 7px;
  }

  .key {
    height: 42px;
    border-radius: 6px;
    font-size: 0.78rem;
  }

  .key.wide {
    font-size: 0.68rem;
  }

  .key.enter-key {
    font-size: 1.05rem;
  }

  .stats-heading {
    display: block;
  }

  .stats-heading strong {
    display: block;
    margin-top: 4px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
