:root {
  --ink: #1c1a1f;
  --hivis: #7b1e3a;
  --yellow: #d4a64a;
  --board: #14213d;
  --cream: #f6efe2;
  --head: "DM Serif Display", Georgia, serif;
  --font: Rubik, "Trebuchet MS", Arial, sans-serif;
}

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

html, body {
  margin: 0;
  height: 100%;
  background: #0b1124;
  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: 2.6em; }
.logo { display: flex; flex-direction: column; align-items: center; line-height: 0.95; }
.logo-tag {
  font-weight: 700; font-size: 0.7em; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--yellow); border-top: 0.08em solid var(--yellow); border-bottom: 0.08em solid var(--yellow);
  padding: 0.3em 0.6em; margin-bottom: 0.4em;
}
.logo-big {
  font-family: var(--head);
  font-size: 4em;
  color: #fff;
  text-shadow: 0.04em 0.06em 0 var(--hivis), 0.08em 0.11em 0 #000;
  line-height: 1;
}
.logo-sub { margin-top: 0.45em; font-size: 0.85em; font-weight: 600; color: #f1e6cf; text-shadow: 0 0.1em 0 #000; line-height: 1.3; }
.best { margin-top: 0.6em; font-size: 0.9em; font-weight: 600; color: #fff; text-shadow: 0 0.1em 0 var(--ink); }

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

.btn {
  font-family: var(--head);
  font-weight: 400;
  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(--yellow); color: var(--ink); }
.btn.ghost { background: var(--cream); font-size: 0.85em; font-family: var(--font); font-weight: 700; }

.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: 6.8em; top: 0.75em;
  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: 700; color: var(--hivis); font-size: 0.85em; }

/* --- 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: #f6efe2;
  color: var(--ink);
  border: 0.14em solid var(--ink);
  border-top: 0.6em solid var(--yellow);
  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: 400; margin: 0.1em 0 0.3em; font-size: 1.45em; color: var(--hivis); line-height: 1.05; }
.res-jobs { list-style: none; padding: 0; margin: 0 0 0.4em; font-size: 0.72em; font-weight: 600; text-align: left; }
.res-jobs li { padding: 0.25em 0; border-bottom: 1px dashed #cfc8b8; }
.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: 400; font-size: 1.15em; }
.total { background: linear-gradient(135deg, #f0d593, var(--yellow)); 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: 400; 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-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: #a8801f; }
.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(--yellow) 42% 58%, transparent 58%), repeating-linear-gradient(-45deg, var(--hivis) 0 0.8em, #93304d 0.8em 1.6em);
}
.gift-lid {
  bottom: 4.2em; width: 6.4em; height: 1.4em; border-radius: 0.3em;
  background: linear-gradient(90deg, transparent 42%, var(--yellow) 42% 58%, transparent 58%), var(--hivis);
  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(--yellow); 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-size: 0.85em; color: #fff; text-shadow: 0 0.1em 0 var(--ink); }
.gift-card { display: none; background: #f6efe2; color: var(--ink); border: 0.14em solid var(--ink); border-top: 0.6em solid var(--yellow); 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: 400; 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: 700; color: var(--hivis); }
.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; } }
