:root {
  --ink: #2b1d14;
  --hivis: #e2533f;
  --yellow: #ffd23f;
  --board: #1f3a5f;
  --box: #c8955c;
  --sky: #3d8fd6;
  --head: Fredoka, "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --font: Nunito, "Trebuchet MS", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: #142033;
  overflow: hidden;
  overscroll-behavior: none;
  font-family: var(--font);
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#wrap { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); overflow: hidden; }
canvas { display: block; touch-action: none; }
.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 1.2em 0.8em 1.4em;
}

/* --- title ------------------------------------------------------------------ */
.title-top { text-align: center; margin-top: 3.4em; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.95; }
.logo-name {
  font-family: var(--head);
  font-weight: 600;
  font-size: 1.6em;
  color: var(--board);
  transform: rotate(-3deg);
}
.logo-big {
  font-family: var(--head);
  font-weight: 600;
  font-size: 3.3em;
  color: var(--yellow);
  -webkit-text-stroke: 0.035em var(--ink);
  text-shadow: 0.05em 0.07em 0 var(--sky), 0.09em 0.12em 0 var(--ink);
  transform: rotate(-3deg);
  margin-top: 0.05em;
  white-space: nowrap;
}
.logo-sub { margin-top: 0.6em; font-size: 0.95em; font-weight: 800; color: var(--ink); background: rgba(255,255,255,.85); padding: 0.2em 0.8em; border-radius: 999px; }
.best { margin-top: 0.6em; font-size: 0.85em; font-weight: 800; color: var(--ink); }
.best:empty { display: none; }

.title-bottom { display: flex; flex-direction: column; align-items: center; gap: 0.5em; margin-bottom: 0.2em; }

.btn {
  font-family: var(--head);
  font-weight: 600;
  font-size: 1em;
  color: var(--ink);
  background: var(--yellow);
  border: 0.13em solid var(--ink);
  border-radius: 0.5em;
  padding: 0.5em 1.3em 0.45em;
  box-shadow: 0 0.2em 0 var(--ink);
  cursor: pointer;
}
.btn:active { transform: translateY(0.14em); box-shadow: 0 0.06em 0 var(--ink); }
.btn.big { font-size: 1.35em; background: var(--sky); color: #fff; text-shadow: 0 0.08em 0 var(--ink); }
.btn.ghost { background: #fbf6ee; font-size: 0.85em; }

.icon-btn {
  position: absolute;
  top: 0.6em;
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  border: 0.1em solid rgba(255, 255, 255, 0.6);
  background: rgba(15, 18, 30, 0.55);
  color: #fff;
  font-size: 1em;
  line-height: 1;
  cursor: pointer;
}
#btn-quit { left: 0.6em; }
.icon-btn.mute { right: 0.6em; }
.icon-btn.haptics { right: 2.8em; }
.icon-btn.off { opacity: 0.6; }
.skip-btn {
  position: absolute; right: 0.6em; bottom: 0.6em;
  font-family: var(--font); font-weight: 700; font-size: 0.75em; color: #fff;
  background: rgba(15, 18, 30, 0.7); border: 0.12em solid rgba(255, 255, 255, 0.6);
  border-radius: 999px; padding: 0.35em 0.9em; cursor: pointer;
}

.update-note {
  position: absolute; left: 50%; top: 7.6em; transform: translateX(-50%);
  background: var(--yellow); color: var(--ink); font-weight: 700; font-size: 0.6em;
  padding: 0.35em 0.9em; border-radius: 999px; border: 0.12em solid var(--ink); white-space: nowrap;
  pointer-events: none;
}

.family-slot { margin-top: 0.7em; font-size: 1em; min-height: 1.6em; }
.family-line { margin: 0.2em 0 0.5em; font-weight: 800; color: #1f5fa3; font-size: 0.85em; }
.next-line { margin: 0.2em 0 0.6em; font-weight: 700; font-size: 0.72em; color: #4b5a6a; }
.next-line:empty { display: none; }

/* --- modals ------------------------------------------------------------------ */
.modal { justify-content: center; background: rgba(10, 12, 22, 0.6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.card {
  position: relative;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
  background: #fbf6ee;
  color: var(--ink);
  border: 0.14em solid var(--ink);
  border-top: 0.6em solid var(--sky);
  border-radius: 0.7em;
  box-shadow: 0 0.25em 0 var(--ink);
  padding: 0.8em 1em 1em;
  text-align: center;
  animation: pop 0.35s cubic-bezier(.2, 1.6, .5, 1);
}
.card h2 { font-family: var(--head); font-weight: 600; margin: 0.1em 0 0.3em; font-size: 1.45em; color: var(--hivis); line-height: 1.05; }
.how-list { list-style: none; padding: 0; margin: 0 0 0.8em; text-align: left; font-size: 0.78em; font-weight: 500; }
.how-list li { display: flex; gap: 0.6em; align-items: center; padding: 0.4em 0; border-bottom: 1px dashed #cfc8b8; }
.how-list .ic { font-size: 1.5em; width: 1.4em; text-align: center; flex: none; }

#res-sub { margin: 0 0 0.6em; font-size: 0.9em; font-weight: 600; font-style: italic; }
.stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.35em; margin: 0.5em 0; }
.stats div { background: #e6e1d4; border-radius: 0.5em; padding: 0.35em 0.3em; display: flex; flex-direction: column; }
.stats span { font-size: 0.6em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.7; }
.stats b { font-family: var(--head); font-weight: 600; font-size: 1.15em; }
.total { background: repeating-linear-gradient(-45deg, var(--yellow) 0 0.6em, #ffe27a 0.6em 1.2em); border: 0.1em solid var(--ink); border-radius: 0.5em; padding: 0.3em; margin: 0.5em 0; display: flex; flex-direction: column; }
.total span { font-size: 0.65em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.total b { font-family: var(--head); font-weight: 600; font-size: 2.2em; line-height: 1.1; }
.results-card .best { color: var(--hivis); text-shadow: none; font-weight: 700; margin: 0.2em 0 0.4em; }
.row { display: flex; gap: 0.5em; justify-content: center; align-items: center; flex-wrap: wrap; }

.stamp {
  display: inline-block; margin: 0.1em 0 0.2em;
  font-family: var(--head); font-weight: 600; font-size: 0.75em; padding: 0.2em 0.5em;
  border: 0.18em solid currentColor; border-radius: 0.3em; transform: rotate(-4deg);
  animation: stamp 0.4s 0.3s cubic-bezier(.2, 1.6, .5, 1) both;
}
.stamp.ok { color: #1e8a3c; }
.stamp.bad { color: #d0202a; }
.stamp.top { color: #1f5fa3; }
.stamp:empty { display: none; }

.install-how { font-size: 0.95em; font-weight: 500; margin: 0.4em 0 1em; line-height: 1.35; }
.share-ic { display: inline-block; border: 0.1em solid currentColor; border-radius: 0.25em; padding: 0 0.25em; font-size: 0.85em; }

/* --- Christmas gift ------------------------------------------------------------- */
.gift { justify-content: center; background: rgba(10, 12, 22, 0.45); }
.gift-inner { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; }
.gift-box { position: relative; width: 7em; height: 7em; border: 0; background: none; padding: 0; cursor: pointer; font-family: var(--font); animation: wiggle 1.6s ease-in-out infinite; }
.gift-base, .gift-lid { position: absolute; left: 50%; transform: translateX(-50%); border: 0.12em solid var(--ink); }
.gift-base {
  bottom: 0; width: 5.6em; height: 4.4em; border-radius: 0.3em;
  background: linear-gradient(90deg, transparent 42%, var(--hivis) 42% 58%, transparent 58%), linear-gradient(0deg, transparent 40%, var(--sky) 40% 52%, transparent 52%), var(--box);
}
.gift-lid {
  bottom: 4.2em; width: 6.4em; height: 1.4em; border-radius: 0.3em;
  background: linear-gradient(90deg, transparent 42%, var(--hivis) 42% 58%, transparent 58%), #b98448;
  transition: transform 0.6s cubic-bezier(.3, 1.6, .5, 1), opacity 0.6s 0.2s;
}
.gift-lid::before, .gift-lid::after { content: ""; position: absolute; bottom: 100%; width: 1.4em; height: 1.1em; border: 0.2em solid var(--hivis); border-radius: 50% 50% 0 50%; }
.gift-lid::before { left: 1.6em; transform: rotate(-20deg); }
.gift-lid::after { right: 1.6em; transform: scaleX(-1) rotate(-20deg); }
.gift-tag { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 0.5em; white-space: nowrap; font-family: var(--head); font-weight: 600; font-size: 0.85em; color: #fff; text-shadow: 0 0.1em 0 var(--ink); }
.gift-card { display: none; background: #fbf6ee; color: var(--ink); border: 0.14em solid var(--ink); border-top: 0.6em solid var(--sky); border-radius: 0.7em; box-shadow: 0 0.25em 0 var(--ink); padding: 1em 1.1em 1.2em; text-align: center; width: 100%; }
.gift-card h2 { font-family: var(--head); font-weight: 600; margin: 0 0 0.4em; font-size: 1.5em; color: var(--hivis); line-height: 1.1; }
.gift-card p { margin: 0.35em 0; font-size: 1em; font-weight: 500; }
.gift-card .gift-signature { margin-top: 0.7em; font-weight: 800; color: #1f4fa3; }
.gift-card .btn { margin-top: 0.8em; }
.gift.open .gift-box { animation: none; cursor: default; height: 4.6em; margin-bottom: 0.6em; transition: height 0.4s 0.4s; }
.gift.open .gift-lid { transform: translate(-50%, -4em) rotate(-25deg); opacity: 0; }
.gift.open .gift-tag { display: none; }
.gift.open .gift-card { display: block; animation: pop 0.5s 0.35s cubic-bezier(.2, 1.6, .5, 1) both; }

@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 75% { transform: rotate(-6deg); } 85% { transform: rotate(6deg); } 92% { transform: rotate(-3deg); } }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes stamp { from { transform: rotate(-4deg) scale(2.4); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }

/* --- portrait only ---------------------------------------------------------------- */
#rotate { display: none; position: fixed; inset: 0; background: var(--board); color: #fff; font-size: 1.6rem; text-align: center; align-items: center; justify-content: center; z-index: 10; }
@media (orientation: landscape) and (max-height: 520px) { #rotate { display: flex; } }
