@font-face {
  font-family: 'Gochi Hand';
  src: url('../vendor/fonts/GochiHand-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: radial-gradient(ellipse at top, #1e293b, #0f172a 60%);
  color: #f1f5f9;
  min-height: 100vh;
  min-height: 100dvh;
}

.app {
  max-width: 60rem;
  margin: 0 auto;
  padding: 3rem 1rem;
  padding-bottom: calc(3rem + env(safe-area-inset-bottom));
}

button {
  cursor: pointer;
}

a {
  cursor: pointer;
}

/* ---------- Landing / category select ---------- */

.logo {
  align-self: center;
  margin: 0 auto 0.4rem;
  font-size: clamp(1.15rem, 5.2vw, 3.9rem);
  font-weight: 900;
  letter-spacing: 0.15em;
  white-space: nowrap;
  background: linear-gradient(90deg, #38bdf8, #a78bfa, #f472b6);
  background-size: 200% 100%;
  animation: logo-gradient 36s ease-in-out infinite alternate;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.home-subtitle {
  margin: 0 auto 3rem;
  color: #cbd5e1;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
}

@keyframes logo-gradient {
  from { background-position: 0% 50%; }
  to { background-position: 100% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .logo {
    animation: none;
  }
}

.board-title {
  grid-column: 1 / -1;
  margin: 0 auto;
  padding-bottom: 0.4rem;
  color: #cbd5e1;
  font-family: 'Gochi Hand', 'Comic Sans MS', 'Segoe Script', cursive;
  font-size: 1.65rem;
  font-weight: 100;
  text-align: center;
}

.category-grid {
  display: grid;
  /* Cards must stay at least ~16rem wide or the ten grade dots (about
     15.2rem incl. gaps) spill over the card edges */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 56rem;
  margin: auto;
}

.home {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 6rem);
  min-height: calc(100dvh - 6rem);
}

.home.session-active {
  padding-top: 1rem;
}

/* No session yet — the game cards are hidden, so center the start options */
.home:not(.session-active) {
  justify-content: center;
}

.home:not(.session-active) .session-options {
  margin-top: 0;
}

.home-profile-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.8rem;
  max-width: 44rem;
  margin: 0 auto 2.4rem;
}

.home-profile-card {
  display: flex;
  width: 9rem;
  min-height: 9rem;
  padding: 0.9rem 0.7rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 2px solid #334155;
  border-radius: 1rem;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  color: #f1f5f9;
  font: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.home-profile-card:hover {
  transform: translateY(-3px);
  border-color: #38bdf8;
}

.home-profile-card.selected {
  border-color: #38bdf8;
  background: linear-gradient(145deg, #243b53, #13243a);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.home-profile-card:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 3px;
}

.home-profile-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.home-profile-name {
  max-width: 100%;
  overflow: hidden;
  font-size: 1.05rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.home-profile-wallet {
  color: #fbbf24;
  font-size: 0.95rem;
  font-weight: 800;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .big-btn.start-btn {
    padding: 0.9rem 0.5rem;
    font-size: 0.95rem;
  }
}

.category-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem 1rem 2.5rem;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 1.5rem;
  color: #fff;
  background-size: 200% 200%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease;
  animation: card-pop 0.275s cubic-bezier(0.34, 1.56, 0.64, 1) backwards,
    gradient-drift 8s ease-in-out infinite;
}

.category-card:nth-child(1) { animation-delay: 0.025s, 0s; }
.category-card:nth-child(2) { animation-delay: 0.09s, -3s; }
.category-card:nth-child(3) { animation-delay: 0.155s, -5s; }
.category-card:nth-child(4) { animation-delay: 0.22s, -7s; }
.category-card:nth-child(5) { animation-delay: 0.285s, -9s; }
.category-card:nth-child(6) { animation-delay: 0.35s, -11s; }
.category-card:nth-child(7) { animation-delay: 0.415s, -13s; }
.category-card:nth-child(8) { animation-delay: 0.48s, -15s; }
.category-card:nth-child(9) { animation-delay: 0.545s, -17s; }
.category-card:nth-child(10) { animation-delay: 0.61s, -19s; }
.category-card:nth-child(11) { animation-delay: 0.675s, -21s; }
.category-card:nth-child(12) { animation-delay: 0.74s, -23s; }
.category-card:nth-child(13) { animation-delay: 0.805s, -25s; }

@keyframes card-pop {
  from {
    opacity: 0;
    transform: translateY(28px) scale(0.85);
  }
}

@keyframes gradient-drift {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 100% 100%; }
}

/* Soft glow blob drifting in the corner */
.category-card::before {
  content: '';
  position: absolute;
  width: 11rem;
  height: 11rem;
  right: -3.5rem;
  bottom: -3.5rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28), transparent 70%);
  pointer-events: none;
  z-index: -1;
  animation: floaty 5s ease-in-out infinite;
}

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

/* Shine sweep across the card on hover */
.category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 70%
  );
  transform: translateX(-130%);
  transition: transform 0.6s ease;
  pointer-events: none;
}

.category-card:hover {
  transform: translateY(-7px) scale(1.04) rotate(-1deg);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5), 0 0 32px var(--glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.category-card:hover::after {
  transform: translateX(130%);
}

.category-card:not(.is-disabled) {
  cursor: pointer;
}

.category-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

.category-card.plus {
  --glow: rgba(74, 222, 128, 0.45);
  background-image: linear-gradient(160deg, #4ade80, #10b981 45%, #0d9488);
}

.category-card.minus {
  --glow: rgba(251, 146, 60, 0.5);
  background-image: linear-gradient(160deg, #fbbf24, #f97316 45%, #e11d48);
}

.category-card.gange {
  --glow: rgba(192, 132, 252, 0.45);
  background-image: linear-gradient(160deg, #c084fc, #8b5cf6 45%, #4f46e5);
}

.category-card.dividere {
  --glow: rgba(103, 232, 249, 0.45);
  background-image: linear-gradient(160deg, #67e8f9, #0ea5e9 45%, #2563eb);
}

.category-card.ligninger {
  --glow: rgba(253, 164, 175, 0.45);
  background-image: linear-gradient(160deg, #fda4af, #f472b6 45%, #a21caf);
}

.category-card.broeker {
  --glow: rgba(251, 191, 36, 0.45);
  background-image: linear-gradient(160deg, #fcd34d, #f59e0b 45%, #b45309);
}

.category-card.decimaltal {
  --glow: rgba(45, 212, 191, 0.45);
  background-image: linear-gradient(160deg, #5eead4, #14b8a6 45%, #0f766e);
}

.category-card.negative {
  --glow: rgba(251, 113, 133, 0.5);
  background-image: linear-gradient(160deg, #fda4af, #f43f5e 45%, #9f1239);
}

.category-card.procent {
  --glow: rgba(165, 180, 252, 0.45);
  background-image: linear-gradient(160deg, #a5b4fc, #6366f1 45%, #3730a3);
}

.category-card.sprog {
  --glow: rgba(132, 204, 22, 0.5);
  background-image: linear-gradient(160deg, #bef264, #84cc16 45%, #15803d);
}

.category-card.enheder {
  --glow: rgba(163, 230, 53, 0.45);
  background-image: linear-gradient(160deg, #a3e635, #65a30d 45%, #3f6212);
}

.category-card.datotid {
  --glow: rgba(148, 163, 184, 0.5);
  background-image: linear-gradient(160deg, #e2e8f0, #64748b 45%, #1e293b);
}

.category-card.viden {
  --glow: rgba(255, 255, 255, 0.5);
  background-image: linear-gradient(160deg, #f87171, #c8102e 45%, #7f1d1d);
}

.category-launch {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  user-select: none;
}

.card-name {
  padding-bottom: 0.45rem;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.grade-dots {
  position: absolute;
  z-index: 2;
  right: 0.35rem;
  bottom: 1.1rem;
  left: 0.35rem;
  display: flex;
  justify-content: center;
  gap: 0.22rem;
}

.grade-dot {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 1.32rem;
  height: 1.32rem;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.22);
  color: #fff;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 800;
  font-style: normal;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.grade-dot.passed {
  border-color: #4ade80;
  background: #f8fafc;
  color: #0f172a;
  text-shadow: none;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.55);
}

/* Grades above the global grade — not unlocked yet, no ring around them */
.grade-dot.locked {
  border-color: transparent;
  opacity: 0.35;
}

/* The current grade failed this session — a red ✗ instead of the number */
.grade-dot.failed {
  border-color: #f87171;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
}

/* A passed grade the board hasn't reached yet — its replay waits there.
   Muted inverted look: a white face and a dimmed dark number, so the
   pending replay doesn't compete with the grade that actually plays next */
.grade-dot.replay-pending {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.43);
  color: rgba(15, 23, 42, 0.5);
  text-shadow: none;
}

/* A passed grade awaiting its one-question replay — the same lightly
   shaded, slightly see-through face as the unplayed dots; a lost replay
   shows a red ✗ like a failed game */
.grade-dot.replay-todo {
  border-color: rgba(255, 255, 255, 0.9);
  background: rgba(15, 23, 42, 0.22);
  color: #fff;
  box-shadow: none;
}

.grade-dot.replay-lost {
  overflow: visible;
  border-color: #f87171;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.55);
}

/* The grade the next card click starts — a steady gold ring, number and
   lightly tinted face, with a small solid chevron pointing down at it */
.grade-dot.next-play {
  border-color: #fbbf24;
  background: #a16207;
  color: #fbbf24;
}

.grade-dot.next-play::before {
  content: '';
  position: absolute;
  top: -0.52rem;
  left: 50%;
  width: 0.52rem;
  height: 0.38rem;
  background: #fbbf24;
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 40%, 50% 95%, 0 40%);
  animation: next-play-chevron 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes next-play-chevron {
  0%, 100% {
    transform: translateX(-50%) translateY(0);
  }
  50% {
    transform: translateX(-50%) translateY(-0.14rem);
  }
}

.grade-progress-summary {
  width: fit-content;
  max-width: 100%;
  margin: -1.5rem auto 1.5rem;
  padding: 0.55rem 1rem;
  border: 1px solid rgba(125, 211, 252, 0.35);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #bae6fd;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.grade-label {
  display: grid;
  gap: 0.55rem;
  margin-top: 1.5rem;
  color: #cbd5e1;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
}

.grade-select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  border: 2px solid #334155;
  border-radius: 0.75rem;
  background: #0f172a;
  color: #f1f5f9;
  font: inherit;
  cursor: pointer;
}

.grade-select:focus {
  border-color: #38bdf8;
  outline: none;
}

.session-options {
  display: flex;
  width: min(100%, 42rem);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 3.5rem auto 2.5rem;
}

.session-options-label {
  color: #f1f5f9;
  font-size: 1.2rem;
  font-weight: 800;
  white-space: nowrap;
}

.session-options-btns {
  display: flex;
  flex: 0 1 auto;
  width: 100%;
  flex-direction: column;
  gap: 0.75rem;
}

.session-options-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.big-btn.start-btn {
  flex: 1 1 8rem;
  max-width: 12rem;
  margin: 0;
  padding: 1.1rem 0.75rem;
  font-size: 1.2rem;
  white-space: nowrap;
  background: transparent;
  border: 2.5px solid #38bdf8;
  color: #7dd3fc;
}

.big-btn.start-btn:hover {
  background: transparent;
  filter: none;
}

.big-btn.start-btn:disabled {
  opacity: 0.35;
  transform: none;
}

/* Cards dim outside a session; their progress markers stay visible. */
.category-card.is-disabled {
  cursor: default;
  filter: brightness(0.72);
  animation: none;
}

.category-card.is-disabled:hover {
  transform: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.category-card.is-disabled::after {
  display: none;
}

/* Spent cards — played or failed at the current grade. Locked dark look;
   the title gets a thin, slightly tilted strike so it reads as crossed out */
.category-card.played,
.category-card.failed {
  filter: none;
  color: #64748b;
  background-image: linear-gradient(160deg, #334155, #1e293b 45%, #020617);
}

.category-card.played .card-name,
.category-card.failed .card-name {
  position: relative;
}

.category-card.played .card-name::after,
.category-card.failed .card-name::after {
  content: '';
  position: absolute;
  right: -0.3rem;
  left: -0.3rem;
  top: 50%;
  height: 2px;
  border-radius: 2px;
  background: rgba(148, 163, 184, 0.85);
  transform: rotate(-2.2deg);
}


/* "Afslut Spil" — pill button in the topbar while a session is running */
.end-btn {
  padding: 0.4rem 0.9rem;
  border: 2px solid #334155;
  border-radius: 999px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.end-btn:hover {
  border-color: #f87171;
  color: #f87171;
}

.end-btn.confirm {
  border-color: #f87171;
  color: #f87171;
}

/* "Tidligere spil" — compact audit list at the bottom of the landing page */
.history {
  min-height: 12rem;
  margin: 2.5rem auto 0;
  text-align: left;
}

.history-title {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 10.5rem;
  overflow-y: auto;
  font-size: 0.85rem;
  color: #94a3b8;
}

.history-list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid #1e293b;
}

.h-date,
.h-time,
.h-kr {
  white-space: nowrap;
}

.h-name {
  flex: 1;
  min-width: 0;
}

.h-kr {
  color: #fbbf24;
}

/* payouts show as negative kroner — money leaving the wallet */
.h-kr.neg {
  color: #f87171;
}

/* ---------- Quiz ---------- */

.quiz-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 2.25rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.close-btn {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top));
  right: calc(0.9rem + env(safe-area-inset-right));
  z-index: 200;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: rgba(241, 245, 249, 0.45);
  font-size: 1.3rem;
  line-height: 1;
  transition: color 0.15s ease, transform 0.15s ease;
}

.close-btn:hover {
  color: #f1f5f9;
  transform: scale(1.1);
}

.level-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.45rem 1.35rem;
  border: 2px solid #334155;
  border-radius: 999px;
  background: #1e293b;
  font-size: 1.4rem;
  font-weight: 800;
  color: #f1f5f9;
}

.level-checks {
  display: inline-flex;
  gap: 0.3rem;
  padding-left: 0.9rem;
  border-left: 2px solid #334155;
}

.check {
  font-size: 1.15rem;
  line-height: 1;
  color: #475569;
  transition: color 0.2s ease, transform 0.2s ease;
}

.check.filled {
  color: #4ade80;
  transform: scale(1.15);
  text-shadow: 0 0 8px rgba(74, 222, 128, 0.5);
}

.check.missed {
  color: #f87171;
  transform: scale(1.15);
  text-shadow: 0 0 8px rgba(248, 113, 113, 0.5);
}

.problem {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* ---------- Chalkboard ---------- */

.chalkboard {
  position: relative;
  container-type: inline-size;
  /* Full app width on roomier screens; on shorter screens the width (and thus
     height, via the 16:9 ratio) shrinks so the board, the option row and about
     10% breathing room at the bottom still fit the viewport. */
  width: min(100%, 56rem, max(20rem, calc((90dvh - 18rem) * 16 / 9)));
  aspect-ratio: 16 / 9;
  margin-right: auto;
  margin-left: auto;
  justify-content: center;
  gap: 1.75rem;
  margin-top: 1rem;
  padding: 1.5rem;
  font-family: 'Gochi Hand', 'Comic Sans MS', 'Segoe Script', cursive;
  background:
    radial-gradient(ellipse 28rem 9rem at 25% 30%, rgba(255, 255, 255, 0.05), transparent 70%),
    radial-gradient(ellipse 20rem 8rem at 78% 62%, rgba(255, 255, 255, 0.035), transparent 70%),
    radial-gradient(ellipse 14rem 6rem at 55% 80%, rgba(255, 255, 255, 0.04), transparent 70%),
    #202428;
  border: 0.9rem solid transparent;
  border-image: linear-gradient(160deg, #a97a4f, #7c4f2c 35%, #96633a 65%, #5f3b20) 1;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55),
    inset 0 0 60px rgba(0, 0, 0, 0.45);
}

.quiz.is-exiting {
  pointer-events: none;
}

.chalkboard.exiting {
  transform-origin: center center;
  animation: chalkboard-exit 250ms ease-in-out forwards;
}

@keyframes chalkboard-exit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.04);
  }
}

/* Wooden ledge below the frame */
.chalkboard::before {
  content: '';
  position: absolute;
  left: 2rem;
  right: 2rem;
  bottom: -1.35rem;
  height: 0.5rem;
  border-radius: 0.15rem;
  background: linear-gradient(180deg, #8a5a34, #4e2f18);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
}

/* Chalk pieces resting on the ledge */
.chalkboard::after {
  content: '';
  position: absolute;
  right: 4.5rem;
  bottom: -0.9rem;
  width: 2.2rem;
  height: 0.55rem;
  border-radius: 0.28rem;
  background: #f5f2ea;
  box-shadow: -3.4rem 0 0 -0.04rem #f7b8cf,
    0 3px 4px rgba(0, 0, 0, 0.45);
  rotate: -3deg;
}

/* Board content: letters write in one by one, wipes away on swap */
.board-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(0.7rem, 5cqw, 1.75rem);
}

.board-content.erasing {
  animation: chalk-erase 0.38s ease-in forwards;
}

.ch {
  display: inline-block;
  opacity: 0;
  animation: ch-write 0.15s ease-out forwards;
}

@keyframes ch-write {
  0% {
    opacity: 0;
    transform: translateY(0.15em) rotate(-10deg) scale(0.6);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes chalk-erase {
  0% {
    clip-path: inset(-25% 0 -25% 0);
    opacity: 1;
    filter: blur(0);
  }
  100% {
    clip-path: inset(-25% 0 -25% 100%);
    opacity: 0;
    filter: blur(3px);
  }
}

.chalkboard .problem-text {
  font-family: inherit;
  font-size: clamp(1.5rem, 6cqw, 3.3rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #f7f3e8;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.85),
    0 0 10px rgba(255, 255, 255, 0.2),
    2px 2px 1px rgba(0, 0, 0, 0.35);
  rotate: -1.2deg;
}

/* Equations render horizontally — slightly smaller so long ones fit */
.chalkboard .problem-text.equation {
  font-size: clamp(1.5rem, 6.2cqw, 3.45rem);
}

/* Long word problems (e.g. rabat) shrink to stay on the board */
.chalkboard .problem-text.equation.long {
  font-size: clamp(1.1rem, 4cqw, 2.3rem);
}

.chalkboard .problem-text.equation .ch {
  margin: 0 0.08em;
}

/* Stacked fractions on the chalkboard (Brøker) */
.fracboard {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.15em 0.3em;
}

.fb-tok {
  display: inline-flex;
  align-items: center;
}

.fb-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 0.18em;
  text-align: center;
}

.fb-num,
.fb-den {
  padding: 0 0.22em;
  line-height: 1.15;
}

.fb-bar {
  height: 0.07em;
  border-radius: 999px;
  background: #f7f3e8;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
}

/* vertical column layout for problems */
.vprob {
  display: flex;
  flex-direction: column;
  line-height: 1.08;
}

.vrow {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
}

.vcell {
  width: 0.62em;
  text-align: center;
}

.vcell.vop {
  width: 0.85em;
  padding-right: 0.12em;
  text-align: left;
}

.vline {
  height: 0.09em;
  margin: 0.08em 0 0.3em;
  border-radius: 999px;
  background: #f7f3e8;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.35);
  transform-origin: left center;
  animation: line-draw 0.25s ease-out backwards;
}

@keyframes line-draw {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

.chalkboard .qmark {
  color: #ffe08a;
}

.chalkboard .feedback {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1.1rem;
  margin-top: 0;
  text-align: center;
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(1rem, 4.6cqw, 1.9rem);
}

.chalkboard .feedback.ok {
  color: #a5f3a0;
  text-shadow: 0 0 10px rgba(165, 243, 160, 0.4);
}

.chalkboard .feedback.wrong {
  color: #ffb1b1;
  text-shadow: 0 0 10px rgba(255, 177, 177, 0.35);
}

.chalkboard .feedback.levelup {
  color: #ffe08a;
  font-size: clamp(1.1rem, 5cqw, 2.1rem);
  text-shadow: 0 0 14px rgba(255, 224, 138, 0.55);
}

/* Step-by-step working shown under the verdict on the chalkboard (Brøker) */
.chalkboard .feedback-explain {
  margin-top: 0.45rem;
  font-size: clamp(0.8rem, 3.6cqw, 1.3rem);
  line-height: 1.3;
  color: rgba(247, 243, 232, 0.85);
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}

/* Visual working: real stacked fractions, one readable chain */
.work-line {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.15em 0.4em;
}

.work-frac .fb-num,
.work-frac .fb-den {
  font-size: 1.16rem;
  padding: 0 0.28em;
}

/* The board is small on phones — shrink the work chain with it (cqw is
   relative to .chalkboard's inline size). Guides outside the board keep
   the base sizes above. */
.chalkboard .work-frac .fb-num,
.chalkboard .work-frac .fb-den {
  font-size: clamp(0.72rem, 3.4cqw, 1.16rem);
}

.chalkboard .work-text {
  font-size: clamp(0.75rem, 3.5cqw, 1.27rem);
}

.chalkboard .frac-tag {
  font-size: clamp(0.6rem, 2.6cqw, 0.75rem);
}

.work-frac .fb-bar {
  height: 0.06em;
}

.work-text {
  font-size: 1.27rem;
  white-space: pre;
}

/* Semantic colors in work chains: blue arrows = rewriting a stage,
   green equals = the expression evaluated to its result */
.work-text.blue {
  color: #7cc3ff;
}

.work-text.green {
  color: #6ee7a0;
}

.work-text.yellow,
.work-frac.yellow .fb-num,
.work-frac.yellow .fb-den {
  color: #fbbf24;
}

.work-frac.yellow .fb-bar {
  background: #fbbf24;
}

.work-frac.green .fb-num,
.work-frac.green .fb-den {
  color: #6ee7a0;
}

.work-frac.green .fb-bar {
  background: #6ee7a0;
}

/* Mini chalkboards behind the start problem and the final result */
.work-grp {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.15em 0.35em;
  justify-content: center;
}

.mini-board {
  padding: 0.25rem 0.6rem;
  border-radius: 0.5rem;
  background: #202428;
  border: 2.5px solid #7c4f2c;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* The revealed answer on the board: green = right, yellow = wrong */
.fb-frac.yellow .fb-num,
.fb-frac.yellow .fb-den {
  color: #fbbf24;
}

.fb-frac.yellow .fb-bar {
  background: #fbbf24;
}

.fb-frac.green .fb-num,
.fb-frac.green .fb-den {
  color: #6ee7a0;
}

.fb-frac.green .fb-bar {
  background: #6ee7a0;
}

.fb-tok .green,
.ch.green {
  color: #6ee7a0;
}

.ch.red {
  color: #ff8a8a;
}

.fb-tok .yellow,
.ch.yellow {
  color: #fbbf24;
}

/* Pill annotation between fractions — e.g. "del begge med 2" (Brøker) */
.frac-tag {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 0.2rem 0.7rem;
  border: 1.5px dashed rgba(251, 191, 36, 0.7);
  border-radius: 0.8rem;
  font-family: system-ui, sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fbbf24;
  white-space: nowrap;
}

/* The "why" under a pill: e.g. "3 × 2 = 6" under "gang begge med 2" */
.tag-sub {
  font-size: 0.6rem;
  font-weight: 600;
  opacity: 0.85;
  letter-spacing: 0.02em;
  margin-top: 0.1rem;
}

/* Method hint under the answer options (e.g. how to add fractions) */
.quiz-hint {
  margin: 1.4rem auto 0;
  max-width: 42rem;
  padding: 0 1rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: #94a3b8;
}

/* Chalkboard pulses while it waits for a click to continue (Brøker) */
.chalkboard.clickable {
  cursor: pointer;
  animation: board-pulse 1.4s ease-in-out infinite;
}

@keyframes board-pulse {
  50% {
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55),
      0 0 26px rgba(255, 224, 138, 0.4),
      inset 0 0 60px rgba(0, 0, 0, 0.45);
  }
}

/* Worked example under the answers — a mini lesson per method (Brøker).
   Each step is its own column, reading left to right like a recipe. */
.frac-demo {
  margin: 1.1rem auto 0;
  width: 100%;
  padding: 0.9rem 1.1rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 0.55rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.04);
  font-family: 'Gochi Hand', 'Comic Sans MS', 'Segoe Script', cursive;
  color: #e2e8f0;
  text-align: center;
}

.demo-title {
  width: 100%;
  font-family: system-ui, sans-serif;
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fbbf24;
}

.demo-note {
  width: 100%;
  margin: 0.35rem 0 0;
  font-family: system-ui, sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
}

/* The guide's single worked example sits slightly apart from the text */
.guide-work {
  width: 100%;
}

.guide-head {
  margin-bottom: 0.15rem;
  font-family: system-ui, sans-serif;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: #fbbf24;
  text-transform: uppercase;
}

.guide-ex {
  font-size: 1.3rem;
  color: #f1f5f9;
}

.guide-step {
  font-family: system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 1.35;
  color: #cbd5e1;
  opacity: 0.88;
}

/* The step's math, rendered like the chalkboard work chain — slightly bigger */
.guide-work {
  margin-bottom: 0.35rem;
}

.guide-work .fb-num,
.guide-work .fb-den {
  font-size: 1.8rem;
}

.guide-work .work-text {
  font-size: 1.7rem;
}

.guide-work .frac-tag {
  font-size: 0.95rem;
}

/* feedback fades out in place while the board is wiped */
.chalkboard .feedback.fadeout {
  animation: fb-fade 0.3s ease-in forwards;
}

@keyframes fb-fade {
  to {
    opacity: 0;
  }
}

.problem-text {
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.qmark {
  color: #38bdf8;
}

.shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

/* Analog clock board (Dato og Tid) */
.clockboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.clock-face {
  width: min(13rem, 48cqw);
  height: auto;
  animation: clock-in 0.45s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

@keyframes clock-in {
  from {
    opacity: 0;
    transform: scale(0.6) rotate(-10deg);
  }
}

.clock-rim {
  fill: rgba(255, 255, 255, 0.04);
  stroke: #f7f3e8;
  stroke-width: 5;
  opacity: 0.9;
}

.clock-tick {
  stroke: #f7f3e8;
  stroke-width: 3;
  stroke-linecap: round;
  opacity: 0.7;
}

.clock-tick.hour {
  stroke-width: 5;
  opacity: 1;
}

.clock-num {
  fill: #f7f3e8;
  font-family: inherit;
  font-size: 21px;
}

.clock-hand {
  stroke: #f7f3e8;
  stroke-linecap: round;
}

.clock-hand.hour {
  stroke-width: 8;
}

.clock-hand.minute {
  stroke-width: 5;
  opacity: 0.95;
}

.clock-pin {
  fill: #f7f3e8;
}

.clock-line {
  display: flex;
  align-items: baseline;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 1.4em;
  font-size: clamp(1.4rem, 4.5cqw, 2.4rem);
  color: #f7f3e8;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.85),
    2px 2px 1px rgba(0, 0, 0, 0.35);
}

.clock-caption {
  margin: 0 0.08em;
}

.clock-answer {
  display: block;
  margin-top: 0.35rem;
  min-height: 1.2em;
  font-size: clamp(1.8rem, 6cqw, 3rem);
  font-weight: 700;
  animation: ch-write 0.15s ease-out backwards;
}

.clock-answer.green {
  color: #6ee7a0;
}

.clock-answer.red {
  color: #ff8a8a;
}

.clock-answer.qmark {
  color: #ffe08a;
}

/* ---------- Paper answer options ---------- */

.options {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 2.75rem;
  margin-bottom: 10dvh;
}

.option {
  --tilt: 0deg;
  position: relative;
  min-width: 5.625rem;
  padding: 1.25rem 0.9375rem 1.0625rem;
  font-family: 'Gochi Hand', 'Comic Sans MS', 'Segoe Script', cursive;
  font-size: 2.5rem;
  line-height: 1;
  color: #3f3a33;
  background: linear-gradient(160deg, #fdfbf3, #f2ead6);
  border: none;
  /* torn-paper edges */
  clip-path: polygon(
    2% 4%, 10% 0%, 32% 3%, 55% 0%, 78% 3%, 97% 1%, 100% 28%,
    98% 55%, 100% 88%, 96% 100%, 62% 98%, 32% 100%, 6% 97%,
    0% 90%, 2% 55%, 0% 24%
  );
  rotate: var(--tilt);
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.45));
  transition: transform 0.12s ease, filter 0.12s ease;
  animation: opt-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

/* staggered pop-in */
.option:nth-child(1) { animation-delay: 0.02s; }
.option:nth-child(2) { animation-delay: 0.07s; }
.option:nth-child(3) { animation-delay: 0.12s; }
.option:nth-child(4) { animation-delay: 0.17s; }
.option:nth-child(5) { animation-delay: 0.22s; }
.option:nth-child(6) { animation-delay: 0.27s; }

@keyframes opt-pop {
  0% {
    transform: scale(0) rotate(-18deg);
    opacity: 0;
  }
  100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
}

/* options that were neither picked nor correct collapse away */
.option.vanish {
  animation: opt-collapse 0.32s ease-in forwards;
}

.option.vanish:nth-child(even) {
  animation-name: opt-collapse-ccw;
}

@keyframes opt-collapse {
  to {
    transform: scale(0) rotate(20deg);
    opacity: 0;
  }
}

@keyframes opt-collapse-ccw {
  to {
    transform: scale(0) rotate(-20deg);
    opacity: 0;
  }
}

.option:nth-child(odd) { --tilt: -2deg; }
.option:nth-child(even) { --tilt: 1.6deg; }
.option:nth-child(3n) { --tilt: -0.9deg; }

/* bit of tape across the top of each note */
.option::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  width: 2.1rem;
  height: 0.65rem;
  translate: -50% 0;
  rotate: -3deg;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.option:hover:not(:disabled) {
  transform: translateY(-5px) scale(1.07);
  filter: drop-shadow(0 9px 12px rgba(0, 0, 0, 0.5));
}

.option:disabled {
  cursor: default;
}

.option.correct {
  color: #14532d;
  background: linear-gradient(160deg, #d7f2cd, #a8e09a);
  animation: paper-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes paper-pop {
  0% {
    transform: scale(1) translateY(0);
    rotate: var(--tilt);
  }
  30% {
    transform: scale(1.35) translateY(-16px);
    rotate: -5deg;
  }
  55% {
    transform: scale(0.9) translateY(-4px);
    rotate: 3deg;
  }
  75% {
    transform: scale(1.16) translateY(-9px);
    rotate: -2deg;
  }
  100% {
    transform: scale(1.12) translateY(-6px);
    rotate: var(--tilt);
  }
}

.option.wrong {
  color: #7f1d1d;
  background: linear-gradient(160deg, #f6d3d3, #e8a8a8);
  animation: shake 0.4s ease;
}

/* Fraction answer options — stacked like on the chalkboard, smaller */
.ofrac {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 0.1em;
  font-size: 0.85em;
  line-height: 1.1;
}

.onum,
.oden {
  padding: 0 0.15em;
}

.obar {
  height: 0.09em;
  border-radius: 999px;
  background: #3f3a33;
}

/* ---------- Confetti ---------- */

.confetti {
  position: fixed;
  z-index: 300;
  pointer-events: none;
  border-radius: 2px;
  animation: confetti-pop 1s cubic-bezier(0.15, 0.6, 0.4, 1) var(--delay, 0s)
    backwards;
}

.confetti.round {
  border-radius: 50%;
}

@keyframes confetti-pop {
  0% {
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  55% {
    transform: translate(calc(-50% + var(--dx) * 0.8), calc(-50% + var(--dy) * 0.8 - 40px))
      rotate(calc(var(--rot) * 0.6)) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy) + 130px))
      rotate(var(--rot)) scale(0.6);
    opacity: 0;
  }
}

.big-btn {
  padding: 0.9rem 2.5rem;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  color: #fff;
  font-size: 1.2rem;
  font-weight: 800;
  transition: transform 0.1s ease, filter 0.1s ease;
}

.big-btn:hover {
  transform: scale(1.04);
  filter: brightness(1.1);
}

.big-btn:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
  filter: none;
}

.feedback {
  margin-top: 2rem;
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
}

.feedback.ok {
  color: #4ade80;
}

.feedback.wrong {
  color: #f87171;
}

/* ---------- Result ---------- */

.result-icon {
  font-size: 4rem;
}

.score-label {
  color: #94a3b8;
  margin-top: 0.5rem;
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 2.5rem;
}

.ghost-btn {
  padding: 0.9rem 2rem;
  border: 2px solid #334155;
  border-radius: 0.75rem;
  background: none;
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 700;
}

.ghost-btn:hover {
  border-color: #64748b;
  color: #f1f5f9;
}

/* ---------- Top bar / profile dropdown ---------- */

/* In-game session countdown — top middle of the navbar row */
.game-timer {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  padding: 0.4rem 1rem;
  border: 2px solid #334155;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  font-size: 1.05rem;
  font-weight: 800;
  color: #7dd3fc;
  font-variant-numeric: tabular-nums;
}

.game-timer.low {
  border-color: #f87171;
  color: #f87171;
}

.topbar {
  position: fixed;
  top: calc(0.9rem + env(safe-area-inset-top));
  right: calc(0.9rem + env(safe-area-inset-right));
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Pill link to the admin page — sits next to the profile menu */
.admin-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.9rem;
  border: 2px solid #334155;
  border-radius: 999px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: none;
  transition: border-color 0.15s ease;
}

.admin-btn:hover {
  border-color: #38bdf8;
}

.profile-menu {
  position: relative;
}

.profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  border: 2px solid #334155;
  border-radius: 999px;
  background: #1e293b;
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 700;
  transition: border-color 0.15s ease;
}

.profile-btn:hover {
  border-color: #38bdf8;
}

.p-avatar {
  font-size: 1.3rem;
}

/* Cap long names so the topbar pill stays compact on narrow screens */
.p-name {
  max-width: 9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sound on/off toggle — round button in the bottom-left corner */
.sound-btn {
  position: fixed;
  bottom: calc(0.9rem + env(safe-area-inset-bottom));
  left: calc(0.9rem + env(safe-area-inset-left));
  z-index: 150;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 2px solid #334155;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.sound-btn:hover {
  border-color: #64748b;
  transform: scale(1.08);
}

.wallet-badge {
  position: fixed;
  display: inline-flex;
  align-items: center;
  gap: 0.25em;
  top: calc(0.9rem + env(safe-area-inset-top));
  left: calc(0.9rem + env(safe-area-inset-left));
  z-index: 150;
  padding: 0.4rem 0.95rem;
  border: 2px solid rgba(251, 191, 36, 0.45);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #fbbf24;
  transition: border-color 0.15s ease;
}

/* Soft golden pulse while the badge is clickable (no session running) —
   signals to the player that their kroner can be paid out */
.wallet-badge:not(:disabled) {
  animation: wallet-glow 2.6s ease-in-out infinite;
}

/* the balance-change flash still plays on top of the pulse */
.wallet-badge.flash:not(:disabled) {
  animation:
    wallet-glow 2.6s ease-in-out infinite,
    wallet-flash 0.6s ease-out;
}

@keyframes wallet-glow {
  0%,
  100% {
    border-color: rgba(251, 191, 36, 0.45);
    box-shadow: 0 0 4px rgba(251, 191, 36, 0.12);
  }
  50% {
    border-color: rgba(253, 230, 138, 0.85);
    box-shadow: 0 0 14px rgba(251, 191, 36, 0.35);
  }
}

/* hover pauses the pulse and turns the glow steady and bright */
.wallet-badge:not(:disabled):hover {
  animation: none;
  border-color: #fbbf24;
  box-shadow: 0 0 14px rgba(251, 191, 36, 0.4);
}

.wallet-badge:disabled {
  cursor: not-allowed;
}

.wallet-badge .coin {
  width: 1.1em;
  height: 1.1em;
  flex: 0 0 auto;
  margin-right: 0.1em;
}

/* soft gold glow whenever the amount changes */
.wallet-badge.flash {
  animation: wallet-flash 0.6s ease-out;
}

@keyframes wallet-flash {
  0% {
    border-color: #fde68a;
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.45);
    transform: scale(1.04);
  }
}

/* odometer: old digits roll up out, new digits roll up in */
.wallet-badge .amount {
  display: inline-block;
  position: relative;
  overflow: hidden;
  min-width: 1ch;
  height: 1.15em;
  line-height: 1.15em;
  vertical-align: bottom;
  text-align: right;
}

.odo-num {
  display: inline-block;
}

/* Odometer text (session clocks): each changed character rolls downward */
.odo-text {
  display: inline-flex;
  vertical-align: bottom;
}

.odo-text-up {
  gap: 0.02em;
}

.odo-text-up .odo-pos {
  width: 1ch;
  text-align: center;
}

.odo-text-up .odo-pos-separator {
  width: 0.45ch;
}

.odo-pos {
  display: inline-block;
  position: relative;
  overflow: hidden;
  height: 1.15em;
  line-height: 1.15em;
  vertical-align: bottom;
}

.odo-wheel-track {
  display: flex;
  flex-direction: column;
  transition: transform 0.45s linear;
}

.odo-wheel-track > span {
  display: block;
  height: 1.15em;
  line-height: 1.15em;
}

.odo-down-enter-active,
.odo-down-leave-active {
  transition: transform 0.45s ease, opacity 0.45s ease;
}

.odo-down-enter-from {
  transform: translateY(-110%);
  opacity: 0;
}

.odo-down-leave-to {
  transform: translateY(110%);
  opacity: 0;
}

.odo-down-leave-active {
  position: absolute;
  right: 0;
  top: 0;
}

.chev {
  color: #94a3b8;
  font-size: 0.8rem;
}

.dropdown-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 13rem;
  max-height: 70vh;
  max-height: 70dvh;
  overflow-y: auto;
  padding: 0.4rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.9rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 50;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: none;
  border-radius: 0.6rem;
  background: none;
  color: #f1f5f9;
  font-size: 1rem;
  font-weight: 600;
  text-align: left;
}

.dd-item:hover {
  background: #334155;
}

.dd-item.current {
  background: rgba(56, 189, 248, 0.15);
}

.dd-avatar {
  font-size: 1.3rem;
}

.dd-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-wallet {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fbbf24;
}

.dd-check {
  color: #38bdf8;
  font-weight: 800;
}

.dd-item.new-profile {
  margin-top: 0.25rem;
  border-top: 1px solid #334155;
  border-radius: 0 0 0.6rem 0.6rem;
  color: #38bdf8;
}

/* ---------- Profile form (onboarding + modal) ---------- */

.profile-form {
  max-width: 26rem;
  margin: 2rem auto;
  padding: 2rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1.25rem;
  text-align: center;
}

.profile-form h2 {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
}

.form-sub {
  color: #94a3b8;
  margin: 0 0 1.25rem;
}

.name-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
  color: #f1f5f9;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 0.75rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.name-input:focus {
  border-color: #38bdf8;
}

.avatar-label {
  color: #94a3b8;
  font-size: 0.95rem;
  margin: 1.5rem 0 0.75rem;
}

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.5rem;
}

.avatar-opt {
  padding: 0.35rem;
  font-size: 1.7rem;
  background: #0f172a;
  border: 2px solid transparent;
  border-radius: 0.6rem;
  transition: transform 0.1s ease, border-color 0.1s ease;
}

.avatar-opt:hover {
  transform: scale(1.15);
}

.avatar-opt.sel {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  transform: scale(1.1);
}

.form-error {
  color: #f87171;
  font-weight: 600;
  margin: 1rem 0 0;
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.75rem;
}

.form-actions .big-btn {
  width: 100%;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  overflow-y: auto;
  background: rgba(2, 6, 23, 0.7);
  z-index: 100;
  padding: 1rem;
}

/* Auto margins center the dialog but let it scroll when it's taller than
   the viewport (e.g. a phone held in landscape) */
.modal-backdrop > * {
  margin: auto;
}

.modal-backdrop .profile-form {
  margin: auto;
  width: 100%;
}

/* ---------- "Udbetaling" payout modal ---------- */

.payout-modal {
  width: 100%;
  max-width: 24rem;
  padding: 2rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1.25rem;
  text-align: center;
}

.payout-modal h2 {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
}

.payout-sub {
  color: #94a3b8;
  margin: 0.5rem 0;
}

.payout-balance {
  margin: 0.5rem 0 1rem;
  font-size: 2.4rem;
  font-weight: 800;
  color: #fbbf24;
}

/* ---------- Scoreboard (end of session) ---------- */

.scoreboard {
  text-align: center;
  padding-top: 1rem;
}

.scoreboard .result-icon {
  font-size: 2.5rem;
}

.scoreboard h2 {
  font-size: 1.8rem;
  margin: 0.75rem 0 0.4rem;
}

/* Compact grid so all 9 games fit on screen at once — ~3 columns wide,
   collapsing to fewer on narrow viewports. */
.sb-table {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
  gap: 0.75rem;
  max-width: 52rem;
  margin: 1.25rem auto 0;
  text-align: left;
}

.sb-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.7rem;
  padding: 0.6rem 0.85rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 0.8rem;
}

.sb-row.skipped {
  opacity: 0.55;
}

/* Name gets its own line; checkmarks/level/kr share the second */
.sb-name {
  flex-basis: 100%;
  font-weight: 800;
  font-size: 0.95rem;
}

.sb-marks {
  display: inline-flex;
  gap: 0.2rem;
  font-size: 0.95rem;
}

.sb-mark.ok {
  color: #4ade80;
}

.sb-mark.x {
  color: #f87171;
}

.sb-level {
  font-size: 0.9rem;
  font-weight: 700;
  color: #38bdf8;
}

.sb-kr {
  margin-left: auto;
  font-weight: 800;
  color: #fbbf24;
}

.sb-none {
  margin-left: auto;
  color: #64748b;
  font-style: italic;
}

.sb-total {
  margin-top: 1.25rem;
  font-size: 1.25rem;
  font-weight: 800;
  color: #fbbf24;
}

.scoreboard .result-actions {
  margin-top: 1.75rem;
}

/* ---------- Player administration ---------- */

.admin-page {
  width: min(100%, 72rem);
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.admin-header {
  position: relative;
  overflow: hidden;
  margin-bottom: 0.85rem;
  padding: 0.9rem 1.25rem 1.05rem;
  border: 1px solid rgba(251, 191, 36, 0.28);
  border-radius: 1rem;
  background:
    radial-gradient(ellipse at 95% 0%, rgba(251, 191, 36, 0.2), transparent 42%),
    linear-gradient(140deg, #243449, #172554 70%, #0f172a);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.admin-logout {
  padding: 0.5rem 0.9rem;
  border: 1px solid rgba(251, 191, 36, 0.4);
  border-radius: 0.6rem;
  background: #172554;
  color: #fcd34d;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.admin-logout:hover:not(:disabled) {
  background: #243449;
  color: #fff;
}

.admin-logout:disabled {
  opacity: 0.6;
}

.admin-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-header-copy {
  min-width: 0;
}

.admin-back {
  display: inline-block;
  color: #fcd34d;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.admin-back:hover {
  color: #fff;
}

.admin-kicker {
  display: block;
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.16em;
}

.admin-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.1;
}

.admin-header p {
  margin: 0.3rem 0 0;
  color: #cbd5e1;
  font-size: 0.85rem;
}

.admin-add-player {
  flex: 0 0 auto;
  padding: 0.55rem 0.9rem;
  border: 1px solid #fcd34d;
  border-radius: 0.7rem;
  background: #fbbf24;
  color: #172033;
  font: inherit;
  font-weight: 850;
  box-shadow: 0 5px 14px rgba(251, 191, 36, 0.18);
  transition: transform 0.15s ease, filter 0.15s ease;
  cursor: pointer;
}

.admin-add-player:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
}

.admin-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr));
  gap: 0.7rem;
}

.admin-player {
  padding: 0.8rem;
  border: 1px solid #334155;
  border-radius: 1.15rem;
  background: linear-gradient(120deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.94));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  animation: card-pop 0.35s ease both;
}

.admin-player.saved {
  animation: player-saved-flash 0.55s ease-in-out 2;
}

@keyframes player-saved-flash {
  0%,
  100% {
    border-color: #334155;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
  }
  35%,
  70% {
    border-color: #4ade80;
    box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.2), 0 10px 28px rgba(74, 222, 128, 0.2);
  }
}

.admin-player-info {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.admin-icon-control {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  min-width: 2.8rem;
  padding: 0 0.35rem;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.admin-avatar-preview {
  display: grid;
  flex: 0 0 2.8rem;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 0.8rem;
  background: rgba(251, 191, 36, 0.1);
  font-size: 1.5rem;
}

.admin-inline-icon {
  position: relative;
  padding: 0;
  color: inherit;
  font-family: inherit;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.admin-inline-icon::after {
  content: '✎';
  position: absolute;
  right: -0.3rem;
  bottom: -0.3rem;
  display: grid;
  width: 1.15rem;
  height: 1.15rem;
  place-items: center;
  border: 1px solid #334155;
  border-radius: 50%;
  background: #0f172a;
  color: #fcd34d;
  font-size: 0.7rem;
}

.admin-inline-icon:hover {
  transform: scale(1.06);
  border-color: #fbbf24;
}

.admin-icon-modal {
  width: min(100%, 29rem);
  padding: 1.35rem;
  border: 1px solid #475569;
  border-radius: 1.2rem;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.55);
  animation: card-pop 0.25s ease both;
}

.admin-icon-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.admin-icon-modal-header h2 {
  margin: 0.35rem 0 0;
  color: #f1f5f9;
  font-size: clamp(1.25rem, 5vw, 1.65rem);
}

.admin-icon-close {
  display: grid;
  flex: 0 0 2.5rem;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  border: 1px solid #475569;
  border-radius: 0.7rem;
  background: #0f172a;
  color: #cbd5e1;
  font-size: 1.6rem;
  line-height: 1;
}

.admin-icon-close:hover {
  border-color: #fbbf24;
  color: #fff;
}

.admin-icon-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.admin-icon-grid .admin-avatar-choice {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.8);
  font-size: 1.8rem;
}

.admin-icon-grid .admin-avatar-choice:hover:not(:disabled) {
  border-color: #fbbf24;
  transform: translateY(-2px);
}

.admin-icon-grid .admin-avatar-choice:disabled {
  cursor: default;
  opacity: 0.6;
}

.admin-player-copy {
  min-width: 0;
  flex: 1;
}

.admin-player-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.5rem;
}

.admin-name-field {
  min-width: 0;
}

.admin-grade-field select {
  cursor: pointer;
}

.admin-wallet {
  margin: 0;
  color: #fbbf24;
  font-size: 0.8rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  margin-top: 0.6rem;
}

.admin-actions button {
  min-height: 2.2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 0.6rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  transition: transform 0.15s ease, filter 0.15s ease, border-color 0.15s ease;
}

.admin-actions button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.12);
}

.admin-reset,
.admin-delete {
  min-height: 0;
  padding: 0.15rem 0;
  border: none;
  background: none;
  font-size: 0.75rem;
  font-weight: 400;
  text-decoration: none;
}

.admin-reset {
  color: #fcd34d;
}

.admin-delete {
  color: #fca5a5;
}

.admin-reset:hover:not(:disabled),
.admin-delete:hover:not(:disabled) {
  transform: none;
  filter: none;
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.admin-reset:hover:not(:disabled) {
  color: #fde68a;
}

.admin-delete:hover:not(:disabled) {
  color: #f87171;
}

.admin-actions button:disabled {
  opacity: 0.6;
  cursor: default;
}

.admin-field {
  display: grid;
  gap: 0.3rem;
  color: #cbd5e1;
  font-size: 0.8rem;
  font-weight: 700;
}

.admin-field input,
.admin-field select {
  width: 100%;
  height: 2.3rem;
  padding: 0.4rem 0.6rem;
  border: 1px solid #475569;
  border-radius: 0.65rem;
  outline: none;
  background: #0f172a;
  color: #f8fafc;
  font: inherit;
}

.admin-field input:focus,
.admin-field select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.13);
}

.admin-avatar-choice {
  width: 2.55rem;
  height: 2.55rem;
  border: 1px solid #334155;
  border-radius: 0.65rem;
  background: #0f172a;
  font-size: 1.35rem;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.admin-avatar-choice:hover {
  transform: translateY(-2px);
}

.admin-avatar-choice.selected {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.13);
}

.admin-message,
.admin-empty {
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  border: 1px solid #334155;
  border-radius: 0.85rem;
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
}

.admin-error {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.admin-menu-link {
  display: block;
  text-decoration: none;
}

/* ---------- Reward matrix (øre per correct answer per grade) ---------- */

.admin-rewards {
  margin-top: 1.5rem;
  overflow-x: auto;
  padding: 1rem 1.25rem 1.2rem;
  border: 1px solid #334155;
  border-radius: 1.15rem;
  background: linear-gradient(120deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.94));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.admin-rewards-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}

.admin-rewards-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.admin-rewards-header p {
  margin: 0.25rem 0 0;
  color: #cbd5e1;
  font-size: 0.8rem;
}

.admin-saved {
  flex: 0 0 auto;
  padding: 0.2rem 0.6rem;
  border: 1px solid rgba(74, 222, 128, 0.5);
  border-radius: 99px;
  background: rgba(74, 222, 128, 0.12);
  color: #4ade80;
  font-size: 0.75rem;
  font-weight: 800;
  animation: card-pop 0.25s ease both;
}

.reward-matrix {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0.3rem;
}

.reward-matrix th {
  padding: 0.35rem 0.4rem;
  color: #cbd5e1;
  font-size: 0.78rem;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.reward-matrix thead th {
  color: #fbbf24;
}

.reward-matrix tbody th[scope='row'] {
  text-align: left;
}

.reward-matrix td {
  padding: 0;
  text-align: center;
}

.reward-cell {
  display: grid;
  width: 100%;
  min-width: 3.4rem;
  height: 2.3rem;
  place-items: center;
  border: 1px solid #334155;
  border-radius: 0.65rem;
  background: #0f172a;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.reward-cell:hover:not(:disabled) {
  border-color: #fbbf24;
}

.reward-cell:disabled {
  cursor: default;
  opacity: 0.6;
}

.reward-cell.active {
  border-color: #fbbf24;
  background: rgba(251, 191, 36, 0.13);
}

.reward-dot {
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: #475569;
}

.reward-cell.active .reward-dot {
  background: #fbbf24;
  box-shadow: 0 0 8px rgba(251, 191, 36, 0.7);
}

@media (max-width: 520px) {
  .admin-page {
    padding: 0.75rem 0.75rem 2rem;
  }

  .admin-header {
    padding: 0.8rem 1rem;
  }

  .admin-header-main {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-add-player {
    align-self: flex-start;
  }

  .admin-player {
    padding: 0.75rem;
  }

  .admin-player-info {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: start;
  }

  .admin-player-copy {
    min-width: 0;
  }

  .admin-icon-modal {
    padding: 1rem;
  }

  .admin-icon-grid {
    gap: 0.45rem;
  }
}

/* ---------- Login ---------- */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 26rem;
  padding: 2rem;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 1.25rem;
  text-align: center;
}

.login-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.7rem;
}

.login-sub {
  color: #94a3b8;
  margin: 0.5rem 0 1.25rem;
}

/* ---------- Phones (≤ ~35rem) ---------- */
/* One shared breakpoint for every phone tweak: compact fixed bars, a
   bottom-right session clock, a smaller chalkboard frame, slimmer modals
   and a denser reward matrix. */
@media (max-width: 560px) {
  .logo {
    letter-spacing: 0.1em;
  }

  .home-profile-card {
    width: 8.5rem;
    min-height: 8.5rem;
    padding: 0.7rem 0.5rem;
  }

  /* The fixed top row shares ~360px with the wallet badge — keep every
     pill small so wallet, timer and buttons never overlap */
  .wallet-badge {
    padding: 0.35rem 0.7rem;
    font-size: 0.9rem;
  }

  .topbar {
    gap: 0.4rem;
  }

  .end-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.9rem;
  }

  .admin-btn {
    padding: 0.4rem 0.6rem;
  }

  .admin-btn-label {
    display: none;
  }

  .profile-btn {
    padding: 0.35rem 0.7rem;
    font-size: 0.9rem;
  }

  .p-name {
    max-width: 4.5rem;
  }

  /* The session clock floats to the bottom-right corner — the top row is
     already busy with the wallet and the end/admin buttons */
  .game-timer {
    top: auto;
    bottom: calc(0.9rem + env(safe-area-inset-bottom));
    right: calc(0.9rem + env(safe-area-inset-right));
    left: auto;
    transform: none;
    padding: 0.35rem 0.8rem;
    font-size: 0.9rem;
  }

  .quiz-top {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
  }

  .level-chip {
    gap: 0.6rem;
    padding: 0.35rem 0.9rem;
    font-size: 1.1rem;
  }

  .level-checks {
    padding-left: 0.6rem;
  }

  /* A slimmer wooden frame leaves more of the 16:9 board for the problem */
  .chalkboard {
    margin-top: 0.5rem;
    padding: 1rem;
    border-width: 0.65rem;
  }

  .chalkboard::before {
    right: 1.2rem;
    bottom: -1.05rem;
    left: 1.2rem;
  }

  .chalkboard::after {
    right: 3rem;
    bottom: -0.7rem;
  }

  .options {
    gap: 0.7rem;
    margin-top: 1.75rem;
  }

  .option {
    min-width: 5rem;
    padding: 1rem 0.75rem 0.85rem;
    font-size: 2.1rem;
  }

  .profile-form,
  .payout-modal,
  .login-card {
    padding: 1.4rem 1.1rem;
  }

  .demo-title {
    font-size: 1.3rem;
  }

  .reward-matrix {
    border-spacing: 0.2rem;
  }

  .reward-matrix th {
    padding: 0.3rem 0.2rem;
    font-size: 0.7rem;
  }

  .reward-cell {
    min-width: 2.8rem;
    height: 2.1rem;
  }
}
