/* Doodle Downs: notebook paper, pencils, and highlighters */
:root {
  --paper: #fdfaf1;
  --card: #fffefa;
  --line: #d3e3f1;
  --margin: #f2abab;
  --ink: #2a2a35;
  --pencil: #62626f;
  --red: #d9423a;
  --blue: #2d68c4;
  --green: #2f9a55;
  --yellow: #f6c945;
  --sticky: #fff3a8;
  --orange: #ef8a2c;
  --hl: rgba(255, 216, 40, .55);
  --hand: 'Patrick Hand', 'Comic Sans MS', 'Chalkboard SE', 'Segoe Print', cursive;
  --marker: 'Permanent Marker', 'Patrick Hand', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --note: 'Caveat', 'Patrick Hand', 'Segoe Print', cursive;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --wob: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wob2: 15px 225px 15px 255px / 255px 15px 225px 15px;
  --wob3: 30px 8px 24px 10px / 10px 26px 8px 28px;
}

* { box-sizing: border-box; }

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--hand);
  font-size: 19px;
  line-height: 1.45;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--line) 31px 32px);
  background-position: 0 12px;
}

/* the red margin line on notebook paper */
body::before {
  content: "";
  position: fixed;
  top: 0; bottom: 0;
  left: calc(20px + env(safe-area-inset-left, 0px));
  width: 2px;
  background: var(--margin);
  pointer-events: none;
}

#app {
  position: relative;
  overflow-x: clip;
  max-width: 580px;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    calc(16px + env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 48px)
    calc(34px + env(safe-area-inset-left, 0px));
}
@media (min-width: 680px) { #app { padding-left: 24px; padding-right: 24px; } }

h1, h2, h3 { font-weight: 400; margin: 0; }
h1 { font-family: var(--marker); font-size: 2rem; line-height: 1.1; letter-spacing: .3px; }
h2 { font-family: var(--marker); font-size: 1.32rem; line-height: 1.2; margin: 1.6rem 0 .7rem; }
h3 { font-family: var(--marker); font-size: 1.1rem; }
p { margin: .35em 0 .8em; }
a { color: inherit; }
small { font-size: .88em; }

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button, a, [role="button"], label, .tile { touch-action: manipulation; }
button, [role="button"], .tile, .btn, .opt, .chip, .mode { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

input, textarea, select {
  font-family: var(--hand);
  font-size: max(16px, 1.1rem);
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--wob3);
  padding: .55rem .8rem;
  width: 100%;
}
textarea { min-height: 220px; line-height: 1.5; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
:focus-visible { outline: 3px dashed var(--blue); outline-offset: 3px; }

.hl {
  font-weight: 400;
  background: linear-gradient(100deg, transparent 0 1%, var(--hl) 3% 95%, transparent 98%);
  padding: 0 .18em;
  border-radius: .5em .25em .45em .3em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.muted { color: var(--pencil); }
.center { text-align: center; }
.note-font { font-family: var(--note); font-size: 1.35em; line-height: 1.1; }
.red { color: var(--red); }
.blue { color: var(--blue); }
.green { color: var(--green); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.screen { animation: enter .3s var(--ease-out) both; }
@keyframes enter { from { opacity: 0; transform: translateY(10px); } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 50px;
  padding: .45rem 1.2rem;
  font-family: var(--hand); font-size: 1.22rem; line-height: 1.1;
  color: var(--ink); text-decoration: none;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: 3px 4px 0 var(--ink);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out), background-color .15s;
}
.btn:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--yellow); }
.btn.go { background: #c9efcf; }
.btn.warn { background: #ffd9d4; }
.btn.small { min-height: 42px; font-size: 1.02rem; padding: .3rem .85rem; box-shadow: 2px 3px 0 var(--ink); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { width: 22px; height: 22px; flex: none; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }

.linkish { font-family: var(--hand); font-size: 1.05rem; text-decoration: underline wavy var(--blue) 1.5px; text-underline-offset: 5px; color: var(--ink); padding: 6px 2px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-bottom: 6px; }
.back {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 44px; padding: 4px 10px 4px 4px;
  font-size: 1.1rem; text-decoration: none; color: var(--ink);
  border-radius: var(--wob3);
  transition: background-color .15s;
}
.back:active { background: rgba(42, 42, 53, .07); }
.back svg { width: 30px; height: 22px; }
.crumb { margin-left: auto; font-family: var(--note); font-size: 1.35rem; color: var(--pencil); transform: rotate(-2deg); }

/* ---------- cards & paper bits ---------- */
.card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--ink);
  border-radius: var(--wob2);
  padding: 14px 16px;
  box-shadow: 2px 3px 0 rgba(42, 42, 53, .9);
}
.tape::before {
  content: ""; position: absolute; top: -12px; left: 50%;
  width: 90px; height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(246, 201, 69, .5);
  box-shadow: 0 1px 1px rgba(0, 0, 0, .06);
}
.sticky {
  position: relative;
  background: var(--sticky);
  padding: 16px 16px 14px;
  border-radius: 2px 2px 18px 2px;
  box-shadow: 2px 5px 10px rgba(80, 60, 0, .16);
  transform: rotate(-1deg);
}
.sticky.pink { background: #ffd6e4; transform: rotate(1deg); }
.sticky.blue { background: #d4ebff; }
.sticky.green { background: #d8f5d0; transform: rotate(.6deg); }

/* ---------- home ---------- */
.hero { text-align: center; padding: 10px 0 4px; }
.logo { display: inline-flex; align-items: center; gap: 8px; }
.logo h1 { font-size: clamp(1.6rem, 7.2vw, 2.35rem); white-space: nowrap; transform: rotate(-2deg); }
.logo svg { width: 46px; height: 34px; flex: none; }
.tagline { font-family: var(--note); font-size: 1.45rem; line-height: 1.15; color: var(--pencil); margin: 2px 0 6px; }
.squiggle { display: block; width: 170px; height: 12px; margin: 2px auto 0; }

.hello { display: grid; gap: 6px; margin-top: 14px; }
.hello-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.hello-name { font-family: var(--marker); font-size: 1.4rem; }
.level { font-family: var(--note); font-size: 1.4rem; color: var(--blue); }
.xpbar { position: relative; height: 18px; border: 2px solid var(--ink); border-radius: var(--wob); overflow: hidden; background: #fff; }
.xpbar i {
  position: absolute; inset: 0 auto 0 0;
  background: repeating-linear-gradient(-50deg, var(--blue) 0 3px, transparent 3px 7px);
  border-right: 2px solid var(--blue);
  transition: width .8s var(--ease-out);
}
.xpmeta { display: flex; justify-content: space-between; font-size: .95rem; color: var(--pencil); }

.leagues { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.league-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px;
  padding: 14px 10px 12px;
  text-decoration: none; color: var(--ink);
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: 3px 4px 0 var(--ink);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.league-card:nth-child(1) { transform: rotate(-1.2deg); background: #fff7e0; }
.league-card:nth-child(2) { transform: rotate(1deg); background: #eaf3ff; }
.league-card:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.league-card svg { width: 100%; max-width: 130px; height: 84px; }
.league-card b { font-family: var(--marker); font-weight: 400; font-size: 1.45rem; line-height: 1; }
.league-card small { color: var(--pencil); line-height: 1.2; }
.pct { font-family: var(--note); font-size: 1.3rem; color: var(--green); margin-top: 2px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  min-height: 136px;
  padding: 12px 12px 10px;
  text-align: left; text-decoration: none; color: var(--ink);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--wob2);
  box-shadow: 2px 3px 0 var(--ink);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.tile:nth-child(4n+1) { transform: rotate(-.8deg); }
.tile:nth-child(4n+2) { transform: rotate(.7deg); }
.tile:nth-child(4n+3) { transform: rotate(.5deg); }
.tile:nth-child(4n) { transform: rotate(-.6deg); }
.tile:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--ink); }
.tile .ic { width: 48px; height: 48px; }
.tile b { font-family: var(--marker); font-weight: 400; font-size: 1.06rem; line-height: 1.15; }
.tile small { color: var(--pencil); line-height: 1.2; font-size: .95rem; }
.tile.wide { grid-column: 1 / -1; min-height: 0; flex-direction: row; align-items: center; gap: 12px; }
.tile.wide .ic { flex: none; }
.tile.done::after {
  content: "✓"; position: absolute; top: 4px; right: 10px;
  font-family: var(--marker); font-size: 1.6rem; color: var(--green); transform: rotate(8deg);
}
.ticks { display: flex; flex-wrap: wrap; gap: 4px 9px; margin-top: auto; padding-top: 6px; font-size: .86rem; color: var(--pencil); }
.ticks span { display: inline-flex; align-items: center; gap: 4px; }
.cbox {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px;
  border: 2px solid var(--ink); border-radius: 3px 6px 2px 5px;
  font-family: var(--marker); font-size: 14px; line-height: 1; color: var(--red);
}

/* ---------- topic menu ---------- */
.topic-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 6px; }
.topic-head .ic { width: 64px; height: 64px; flex: none; }
.modes { display: grid; gap: 16px; margin-top: 12px; }
.mode {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 12px;
  padding: 12px 14px;
  text-decoration: none; color: var(--ink);
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: 3px 4px 0 var(--ink);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out);
}
.mode:nth-child(2) { transform: rotate(.6deg); }
.mode:active { transform: translate(2px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.mode svg { width: 58px; height: 50px; }
.mode b { display: block; font-family: var(--marker); font-weight: 400; font-size: 1.25rem; }
.mode small { color: var(--pencil); }
.mode .status { font-family: var(--note); font-size: 1.3rem; color: var(--green); text-align: right; line-height: 1; }
.stars { color: var(--orange); letter-spacing: 1px; font-size: 1.15rem; }

/* ---------- lessons ---------- */
.slide { touch-action: pan-y; }
.slide-title { font-family: var(--marker); font-size: 1.5rem; line-height: 1.15; margin: 6px 0 10px; }
.scene {
  position: relative;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: var(--wob2);
  padding: 6px;
  box-shadow: 2px 3px 0 rgba(42, 42, 53, .85);
}
.scene-svg { display: block; width: 100%; height: auto; overflow: visible; }
.scene-svg text { user-select: none; -webkit-user-select: none; }
.scene [data-tip] { cursor: pointer; }
.scene [data-tip].picked > :first-child { fill: var(--yellow); }
.scene { margin-bottom: 48px; }
.replay {
  position: absolute; right: 6px; bottom: -44px;
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 36px; padding: 2px 12px;
  font-size: .95rem; color: var(--pencil);
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 18px 14px 20px 12px;
}
.replay:active { background: var(--sticky); }
.replay svg { width: 18px; height: 18px; }
.tapinfo { margin-top: 0; }
.slide-title + .scene + .tapinfo:empty + .slide-text { margin-top: -6px; }
.tapinfo:empty { display: none; }
.slide-text { font-size: 1.22rem; line-height: 1.5; margin-top: 14px; }
.pager { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-top: 18px; }
.dots { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.dots i { width: 10px; height: 10px; border: 2px solid var(--ink); border-radius: 50% 40% 55% 45%; }
.dots i.on { background: var(--ink); }
.dots i.seen { background: var(--yellow); }

.donebox { text-align: center; padding: 22px 16px; }
.donebox svg { width: 100%; max-width: 300px; height: auto; }

/* ---------- flashcards ---------- */
.deckinfo { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; color: var(--pencil); margin-bottom: 10px; }
.flip { perspective: 1200px; margin: 8px 0 18px; }
.flip-inner {
  position: relative; display: grid;
  min-height: 300px;
  transition: transform .55s var(--ease-out);
  transform-style: preserve-3d;
}
.flip.on .flip-inner { transform: rotateY(180deg); }
.face {
  grid-area: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 22px;
  text-align: center;
  background: #fff;
  background-image: linear-gradient(to bottom, transparent 0 46px, var(--margin) 46px 48px, transparent 48px), repeating-linear-gradient(to bottom, transparent 0 29px, var(--line) 29px 30px);
  background-position: 0 0, 0 48px;
  border: 2.5px solid var(--ink);
  border-radius: var(--wob2);
  box-shadow: 3px 4px 0 var(--ink);
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  cursor: pointer;
}
.face.back { transform: rotateY(180deg); background-color: #fffbe6; }
.face .term { font-family: var(--marker); font-size: 1.9rem; line-height: 1.15; }
.face .def { font-size: 1.28rem; line-height: 1.45; }
.face .hint { position: absolute; bottom: 10px; font-family: var(--note); font-size: 1.2rem; color: var(--pencil); }
.face .known-badge { position: absolute; top: 10px; right: 14px; font-family: var(--note); font-size: 1.2rem; color: var(--green); }
.cardbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- quiz ---------- */
.qmeta { display: flex; justify-content: space-between; align-items: center; color: var(--pencil); }
.qbar { display: flex; gap: 4px; margin: 6px 0 12px; }
.qbar i { flex: 1; height: 8px; border: 1.5px solid var(--ink); border-radius: 4px 2px 5px 3px; }
.qbar i.ok { background: var(--green); }
.qbar i.no { background: var(--red); }
.qbar i.now { background: var(--yellow); }
.question { font-size: 1.38rem; line-height: 1.35; margin: 10px 0 16px; }
.opts { display: grid; gap: 12px; }
.opt {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; width: 100%;
  padding: 10px 14px;
  font-size: 1.16rem; line-height: 1.25; text-align: left;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: 2px 3px 0 var(--ink);
  transition: transform .12s var(--ease-out), box-shadow .12s var(--ease-out), background-color .2s;
}
.opt:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--ink); }
.opt .letter {
  flex: none; display: grid; place-items: center;
  width: 30px; height: 30px;
  font-family: var(--marker); font-size: 1rem;
  border: 2px solid var(--ink); border-radius: 50% 45% 55% 50%;
}
.opt.right { background: #d5f3d9; border-color: var(--green); }
.opt.right .letter { background: var(--green); color: #fff; border-color: var(--green); }
.opt.wrong { background: #ffe0dc; border-color: var(--red); }
.opt.wrong .letter { background: var(--red); color: #fff; border-color: var(--red); }
.opt.wrong .txt { text-decoration: line-through wavy var(--red) 2px; }
.opts.locked .opt { pointer-events: none; }
.opts.locked .opt:not(.right):not(.wrong) { opacity: .55; }
.verdict { display: flex; gap: 12px; align-items: flex-start; margin-top: 16px; }
.verdict svg { width: 74px; height: 74px; flex: none; }
.verdict b { font-family: var(--marker); font-weight: 400; font-size: 1.35rem; display: block; }
.verdict.ok b { color: var(--green); }
.verdict.no b { color: var(--red); }
.verdict b.hl { display: inline; font-family: var(--hand); font-size: 1.12rem; color: var(--ink); }
.result { text-align: center; }
.bigscore { font-family: var(--marker); font-size: 3.4rem; line-height: 1; margin: 6px 0; }
.bigstars { font-size: 2.2rem; color: var(--orange); letter-spacing: 6px; }
.missed { text-align: left; display: grid; gap: 10px; margin-top: 12px; }
.missed .card { padding: 10px 14px; font-size: 1.05rem; }
.timer { font-family: var(--marker); font-size: 1.3rem; color: var(--red); }

/* ---------- lists / extras ---------- */
.list { display: grid; gap: 12px; }
.term-row { padding: 10px 14px; }
.term-row b { font-family: var(--marker); font-weight: 400; font-size: 1.1rem; }
.term-row p { margin: 2px 0 0; }
.search { margin: 6px 0 14px; }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: var(--wob); overflow: hidden; background: #fff; }
.seg button, .seg a { display: inline-flex; align-items: center; min-height: 44px; padding: 4px 18px; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.seg button.on, .seg a.on { background: var(--ink); color: #fff; }
.lgic { flex: none; }
.lgic svg { display: block; width: 96px; height: 62px; }
.teams { display: grid; gap: 8px; }
.team { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 8px 12px; }
.team svg { width: 40px; height: 40px; }
.team b { font-family: var(--marker); font-weight: 400; font-size: 1.05rem; display: block; line-height: 1.15; }
.team small { color: var(--pencil); }
.signals { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.signal { padding: 6px 8px 10px; text-align: center; }
.signal svg { width: 100%; height: auto; }
.signal b { font-family: var(--marker); font-weight: 400; font-size: 1rem; display: block; line-height: 1.15; }
.signal small { display: block; color: var(--pencil); line-height: 1.2; margin-top: 2px; }
.cheat { display: grid; gap: 16px; }
.cheat h3 { margin-bottom: 4px; }
.cheat ul { margin: 0; padding-left: 1.1em; }
.cheat li { margin: 2px 0; }
.compare { width: 100%; border-collapse: collapse; font-size: 1.02rem; }
.compare th, .compare td { padding: 8px 6px; text-align: left; vertical-align: top; border-bottom: 1.5px dashed rgba(42, 42, 53, .35); }
.compare th { font-family: var(--marker); font-weight: 400; }
.letter-page { padding: 26px 20px 22px; font-size: 1.22rem; line-height: 1.55; white-space: pre-wrap; }
.letter-page .sign { font-family: var(--note); font-size: 1.7rem; text-align: right; margin-top: 10px; }
.profiles { display: grid; gap: 12px; }
.chip {
  display: flex; align-items: center; gap: 12px;
  min-height: 60px; width: 100%;
  padding: 8px 14px;
  font-size: 1.25rem; text-align: left;
  background: #fff;
  border: 2.5px solid var(--ink); border-radius: var(--wob);
  box-shadow: 2px 3px 0 var(--ink);
}
.chip:active { transform: translate(2px, 2px); box-shadow: 0 1px 0 var(--ink); }
.chip svg { width: 40px; height: 40px; flex: none; }
.chip small { display: block; color: var(--pencil); font-size: .95rem; }
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.badge { text-align: center; font-size: .95rem; line-height: 1.15; }
.badge svg { width: 64px; height: 64px; display: block; margin: 0 auto 4px; }
.badge.locked { opacity: .35; filter: grayscale(1); }
.badge b { font-family: var(--marker); font-weight: 400; display: block; font-size: .95rem; }
.statgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; text-align: center; }
.statgrid b { display: block; font-family: var(--marker); font-weight: 400; font-size: 1.6rem; line-height: 1.1; }
.statgrid small { color: var(--pencil); }
.huddle { cursor: pointer; }
.huddle .label { font-family: var(--note); font-size: 1.35rem; color: var(--red); line-height: 1; }
.huddle .q { font-family: var(--marker); font-size: 1.2rem; margin: 4px 0; }
.field-label { display: block; margin: 12px 0 4px; font-size: 1.1rem; }
.checkline { display: flex; gap: 10px; align-items: center; min-height: 44px; font-size: 1.1rem; }
.checkline input { width: 24px; height: 24px; flex: none; accent-color: var(--ink); }
.pass-screen { text-align: center; padding: 30px 10px; }
.pass-screen svg { width: 200px; height: auto; }
.footer-note { text-align: center; color: var(--pencil); font-size: .95rem; margin-top: 30px; }

/* ---------- tip jar ---------- */
.tipjar { display: grid; grid-template-columns: 64px 1fr; gap: 6px 14px; align-items: start; }
.tipjar > svg { width: 64px; height: 64px; grid-row: span 2; }
.tipjar h2, .tipjar h3 { margin: 4px 0 4px; }
.tipjar p { margin: 0 0 12px; font-size: 1.08rem; line-height: 1.45; }
.tipjar .tip-row { grid-column: 1 / -1; }
.btn.tip { background: #d5f3d9; gap: 8px; padding-left: .9rem; }
.btn.tip .coin { width: 26px; height: 26px; transition: transform .22s var(--ease-out); }
.btn.tip .arrow { font-family: var(--marker); transition: transform .22s var(--ease-out); }
.btn.tip:active .coin { transform: translateY(-3px) rotate(-14deg); }
@media (hover: hover) and (pointer: fine) {
  .btn.tip:hover .coin { transform: translateY(-4px) rotate(-14deg); }
  .btn.tip:hover .arrow { transform: translateX(3px); }
}

/* ---------- welcome ---------- */
.welcome { text-align: center; padding-top: 4vh; }
.welcome .scene { margin: 16px 0 52px; }
.welcome form { display: grid; gap: 14px; text-align: left; margin-top: 8px; }

/* ---------- loader ---------- */
#loader {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 24px;
  background-color: var(--paper);
  background-image: repeating-linear-gradient(to bottom, transparent 0 31px, var(--line) 31px 32px);
  opacity: 0; visibility: hidden;
  transition: opacity .28s var(--ease-out), visibility 0s linear .28s;
}
#loader.show { opacity: 1; visibility: visible; transition: opacity .2s var(--ease-out), visibility 0s; }
.loader-inner { width: min(420px, 92vw); text-align: center; }
#loader-svg { width: 100%; height: auto; }
.loading-word { font-family: var(--marker); font-size: 1.6rem; margin: 6px 0 4px; }
.loading-word span { animation: blink 1.2s infinite both; }
.loading-word span:nth-child(2) { animation-delay: .2s; }
.loading-word span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 100% { opacity: .15; } 40% { opacity: 1; } }
.loader-tip { font-family: var(--note); font-size: 1.45rem; line-height: 1.3; color: var(--pencil); min-height: 2.4em; max-width: 340px; margin: 0 auto; }

/* ---------- title screen (the first loading screen when the app opens) ---------- */
#loader:not(.title) .title-only { display: none; }
.title-logo { margin-bottom: 4px; }
.title-name { font-family: var(--marker); font-weight: 400; font-size: clamp(2.6rem, 12vw, 4.2rem); line-height: 1; transform: rotate(-2deg); }
.title-squiggle { display: block; width: min(230px, 60%); height: 14px; margin: 6px auto 0; }
.title-tag { font-family: var(--note); font-size: 1.45rem; line-height: 1.3; color: var(--pencil); margin: 8px auto 0; max-width: 320px; }
#title-svg { display: block; width: 100%; height: auto; margin-top: 4px; }
#loader.title #loader-svg { display: none; }
.title-start { display: none; margin-top: 4px; }
#loader.title.ready .loading-word { display: none; }
#loader.title.ready .title-start { display: block; animation: enter .4s var(--ease-out) both; }
#kickoff { min-height: 58px; padding: .5rem 1.6rem; font-size: 1.4rem; }
.title-hello { font-family: var(--note); font-size: 1.4rem; color: var(--blue); margin: 12px 0 0; min-height: 1.2em; }
#loader.title.ready { cursor: pointer; }
#loader.title .loader-tip { margin-top: 20px; }

/* ---------- toasts ---------- */
#toasts {
  position: fixed; z-index: 70; left: 0; right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  display: grid; justify-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 18px;
  font-size: 1.15rem;
  background: var(--sticky);
  border: 2px solid var(--ink);
  border-radius: var(--wob);
  box-shadow: 2px 3px 0 var(--ink);
  animation: toast-in .35s var(--ease-out) both;
}
.toast.out { animation: toast-out .3s ease-in both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px) rotate(-2deg); } to { opacity: 1; transform: rotate(-1deg); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ---------- confetti footballs ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 55; overflow: hidden; }
.confetti span { position: absolute; top: -40px; width: 28px; height: 18px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- drawing animations ---------- */
.draw { stroke-dasharray: 1 1; stroke-dashoffset: 1; animation: draw var(--d, .8s) var(--ease, ease-out) var(--dl, 0s) both; }
@keyframes draw { 0% { stroke-dashoffset: 1; opacity: 0; } 2% { opacity: 1; } 100% { stroke-dashoffset: 0; opacity: 1; } }
.pop { transform-box: fill-box; transform-origin: center; animation: pop .45s cubic-bezier(.2, 1.5, .4, 1) var(--dl, 0s) both; }
@keyframes pop { 0% { opacity: 0; transform: scale(.3); } 100% { opacity: 1; transform: scale(1); } }
.fade { animation: fade .5s ease-out var(--dl, 0s) both; }
@keyframes fade { from { opacity: 0; } }
.wiggle { transform-box: fill-box; transform-origin: center; animation: wiggle 1.6s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg); } }
.bob { animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

/* ---------- hover only where hover exists ---------- */
@media (hover: hover) and (pointer: fine) {
  .btn:hover, .tile:hover, .mode:hover, .opt:hover, .chip:hover, .league-card:hover { box-shadow: 4px 6px 0 var(--ink); }
  .back:hover { background: rgba(42, 42, 53, .06); }
  .linkish:hover { color: var(--blue); }
  .replay:hover { color: var(--ink); }
}

@media (max-width: 360px) {
  body { font-size: 18px; }
  .tiles { gap: 12px 10px; }
  .tile { padding: 10px 9px 8px; }
  .leagues { gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .draw { stroke-dashoffset: 0 !important; opacity: 1 !important; }
  .pop, .fade { opacity: 1 !important; transform: none !important; }
}
