@font-face {
  font-family: 'Patrick Hand';
  src: url('/PatrickHand-Regular.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #fb0101;
  --ink-dark: #c40000;
  --text: #2b2323;
  --muted: #7a6a6a;
  --paper: #ffffff;
  --rule: #dfe8f5;
  --margin: #f6b3b3;
  --card: #ffffff;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.06), 0 8px 24px rgba(60, 20, 20, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Patrick Hand', 'Comic Sans MS', cursive, sans-serif;
  font-size: 20px;
  line-height: 1.5;
  color: var(--text);
  /* Notebook paper: faint blue lines and a red margin line. */
  background-color: var(--paper);
  background-image:
    linear-gradient(90deg, transparent 63px, var(--margin) 63px, var(--margin) 65px, transparent 65px),
    repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px);
  overflow-x: hidden;
}

a { color: var(--ink); }

img { max-width: 100%; }

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8em;
  background: #fff0f0;
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(6px);
  border-bottom: 2px solid #f3dede;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 24px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav nav { display: flex; gap: 20px; align-items: center; }
.nav nav a { color: var(--text); text-decoration: none; font-size: 21px; }
.nav nav a:hover { color: var(--ink); }
.nav nav a.nav-join {
  color: #fff;
  background: var(--ink);
  padding: 2px 16px;
  border-radius: 999px;
}
.nav nav a.nav-join:hover { background: var(--ink-dark); color: #fff; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  text-align: center;
  padding: 48px 24px 72px;
  min-height: 640px;
  overflow: hidden;
}
.hero-logo {
  width: 210px;
  height: auto;
  animation: wobble 6s ease-in-out infinite;
}
.hero h1 { margin: 6px 0 0; line-height: 0; }
.hero-title { width: min(720px, 92vw); height: auto; }
.hero-tagline {
  max-width: 560px;
  margin: 18px auto 26px;
  font-size: 23px;
}
.hero-tagline strong { color: var(--ink); font-weight: normal; }

@keyframes wobble {
  0%, 100% { transform: rotate(-2deg); }
  50% { transform: rotate(2deg) scale(1.02); }
}

/* Desk clutter around the edges, like the banner. */
.doodle { position: absolute; pointer-events: none; user-select: none; }
.doodle-eraser { left: 0; top: 70px; width: 150px; }
.doodle-scissors { right: 0; top: 0; width: 180px; }
/* The pencil and calculator are cut off on one side, so that side always sits past the page edge. */
.doodle-pencil { right: -235px; top: 50px; width: 415px; animation: scribble 3.5s ease-in-out infinite; }
.doodle-calculator { left: 0; top: 400px; width: 79px; }

@keyframes scribble {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-6px, 4px) rotate(-2deg); }
  50% { transform: translate(-2px, -3px) rotate(1deg); }
  75% { transform: translate(-8px, 2px) rotate(-1deg); }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font: inherit;
  font-size: 22px;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  /* Uneven corners read as hand-drawn. */
  border-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  padding: 6px 26px;
  text-decoration: none;
  box-shadow: 3px 4px 0 rgba(251, 1, 1, 0.18);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { transform: translate(-1px, -2px) rotate(-1deg); box-shadow: 5px 7px 0 rgba(251, 1, 1, 0.22); }
.btn-big {
  font-size: 30px;
  color: #fff;
  background: var(--ink);
  padding: 10px 40px;
}
.btn-big:hover { background: var(--ink-dark); }

/* ---------- stats ---------- */
.stats {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 34px;
  margin: 28px 0 0;
  font-size: 24px;
}
.stat-num { color: var(--ink); font-size: 32px; }
.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  border-radius: 50%;
  background: #2ecc71;
  vertical-align: 2px;
}

/* ---------- sections ---------- */
.paper {
  max-width: 920px;
  margin: 0 auto 64px;
  padding: 0 24px;
}
.scribble {
  display: inline-block;
  position: relative;
  margin: 0 0 14px;
  font-size: 42px;
  font-weight: normal;
  color: var(--ink);
}
/* A red-pen underline under each heading. */
.scribble::after {
  content: '';
  position: absolute;
  left: -4px;
  right: -10px;
  bottom: 2px;
  height: 10px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 10' preserveAspectRatio='none'%3E%3Cpath d='M2 6 C 40 2, 80 9, 120 5 S 180 3, 198 6' fill='none' stroke='%23fb0101' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat center / 100% 100%;
}
.muted { color: var(--muted); }

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 18px;
}
.card {
  background: var(--card);
  border: 2px solid #f0d6d6;
  border-radius: 14px 4px 14px 4px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.card:nth-child(odd) { transform: rotate(-0.6deg); }
.card:nth-child(even) { transform: rotate(0.6deg); }
.card h3 { margin: 0 0 4px; font-size: 26px; font-weight: normal; color: var(--ink); }
.card p { margin: 0; font-size: 19px; }

/* ---------- live ---------- */
.live-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.live-text { margin: 0; font-size: 22px; }
.badge {
  font-size: 18px;
  padding: 1px 12px;
  border-radius: 999px;
  border: 2px solid var(--muted);
  color: var(--muted);
}
.badge.is-live { border-color: var(--ink); background: var(--ink); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(251, 1, 1, 0.15); } }
.live-player {
  position: relative;
  aspect-ratio: 16 / 9;
  margin-bottom: 16px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}
.live-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* ---------- leaderboard ---------- */
.board { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.board-row {
  display: grid;
  grid-template-columns: 48px 52px 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 2px solid #f0d6d6;
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.board-rank { font-size: 26px; color: var(--muted); text-align: center; }
.board-row:nth-child(1) .board-rank,
.board-row:nth-child(2) .board-rank,
.board-row:nth-child(3) .board-rank {
  color: #fff;
  background: var(--ink);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  line-height: 40px;
  margin: auto;
  font-size: 22px;
}
.board-row:nth-child(2) .board-rank { background: #e0565b; }
.board-row:nth-child(3) .board-rank { background: #f08b8b; }
.board-avatar { width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--ink); background: #fff0f0; }
.board-name { min-width: 0; }
.board-name strong { display: block; font-weight: normal; font-size: 22px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-bar { height: 8px; border-radius: 4px; background: #f6e3e3; overflow: hidden; margin-top: 2px; max-width: 320px; }
.board-bar span { display: block; height: 100%; background: var(--ink); border-radius: 4px; }
.board-level { text-align: right; font-size: 18px; color: var(--muted); white-space: nowrap; }
.board-level b { display: block; font-weight: normal; font-size: 24px; color: var(--ink); }
.board-empty { text-align: center; color: var(--muted); padding: 20px; }

/* ---------- footer ---------- */
.footer { text-align: center; padding: 30px 24px 40px; border-top: 2px solid #f3dede; background: rgba(255, 255, 255, 0.85); }
.footer-links { display: flex; justify-content: center; gap: 26px; margin: 0 0 6px; font-size: 22px; }

/* ---------- phones ---------- */
@media (max-width: 760px) {
  body { font-size: 19px; background-image: repeating-linear-gradient(180deg, transparent 0 31px, var(--rule) 31px 32px); }
  .nav { padding: 8px 16px; }
  .nav-brand { font-size: 0; }
  .nav nav { gap: 14px; }
  .hero { padding: 32px 16px 120px; min-height: 0; }
  .hero-logo { width: 150px; }
  .doodle-eraser { width: 80px; top: 40px; left: -20px; }
  .doodle-scissors { width: 100px; right: -20px; }
  .doodle-pencil { display: none; }
  .doodle-calculator { width: 46px; top: auto; bottom: 24px; }
  .paper { padding: 0 16px; }
  .scribble { font-size: 36px; }
  .board-row { grid-template-columns: 34px 42px 1fr auto; gap: 8px; padding: 8px 10px; }
  .board-avatar { width: 40px; height: 40px; }
  .board-row:nth-child(-n+3) .board-rank { width: 32px; height: 32px; line-height: 32px; font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- seasonal: Halloween ---------- */
.deco { display: none; }

[data-theme='halloween'] {
  --ink: #ff7a18;
  --ink-dark: #e0600a;
  --text: #efe6ff;
  --muted: #b7a6cf;
  --paper: #1c1028;
  --rule: rgba(190, 160, 230, 0.10);
  --margin: rgba(255, 122, 24, 0.35);
  --card: #2a1838;
  --shadow: 0 2px 0 rgba(0, 0, 0, 0.25), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
[data-theme='halloween'] body { background-color: var(--paper); }
[data-theme='halloween'] .nav { background: rgba(28, 16, 40, 0.92); border-bottom-color: #3b2550; }
[data-theme='halloween'] .footer { background: rgba(28, 16, 40, 0.9); border-top-color: #3b2550; }
[data-theme='halloween'] .card,
[data-theme='halloween'] .board-row { border-color: #4a2e63; }
[data-theme='halloween'] .btn { background: transparent; box-shadow: 3px 4px 0 rgba(255, 122, 24, 0.25); }
[data-theme='halloween'] .btn-big { background: var(--ink); color: #1c1028; }
[data-theme='halloween'] .nav nav a.nav-join { color: #1c1028; }
[data-theme='halloween'] code { background: #3b2550; }
[data-theme='halloween'] .board-bar { background: #3b2550; }
[data-theme='halloween'] .board-avatar { background: #3b2550; }
[data-theme='halloween'] .board-row:nth-child(2) .board-rank { background: #c7621a; }
[data-theme='halloween'] .board-row:nth-child(3) .board-rank { background: #8e44ad; }
[data-theme='halloween'] .scribble::after { filter: hue-rotate(25deg) saturate(1.2); }
[data-theme='halloween'] .hero-logo { filter: drop-shadow(0 0 18px rgba(255, 122, 24, 0.35)); }

[data-theme='halloween'] .deco { display: block; }
.deco-moon { left: 50%; top: 10px; width: 300px; margin-left: 140px; animation: float 7s ease-in-out infinite; }
.deco-web { left: 0; top: 0; width: 170px; opacity: 0.9; }
.deco-pumpkins { right: 150px; bottom: 0; width: 210px; }
.deco-ghost { right: 230px; top: 480px; width: 80px; animation: float 4s ease-in-out infinite; }
/* The cobweb takes the eraser's corner, so the eraser moves down a little. */
[data-theme='halloween'] .doodle-eraser { top: 160px; }
@keyframes float { 50% { transform: translateY(-10px); } }

@media (max-width: 760px) {
  .deco-moon { width: 150px; margin-left: 30px; top: 0; opacity: 0.85; }
  .deco-web { width: 100px; }
  .deco-pumpkins { width: 120px; right: 60px; }
  .deco-ghost { display: none !important; }
  [data-theme='halloween'] .doodle-eraser { top: 100px; }
}
