:root {
  /* evening palette */
  --night: #15123a; --night-2: #1f1b4d; --edge: rgba(255, 255, 255, .16);
  --text: #f4efff; --dim: #a9a3d6; --glow: #ff6fa5; --gold: #ffd23f; --mint: #7cf2c4;
  --hot: #ff3d7f; --red: #ff4d5e; --ink: #1d2150;
  /* Lilita for the title, big numbers and moments; Outfit for the interface */
  --display: 'Lilita One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --ui: 'Outfit', system-ui, sans-serif;
  /* the open area of the landscape (set from JS) */
  --vl: 0px; --vt: 0px; --vr: 100vw; --vb: 100vh;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  -webkit-font-smoothing: antialiased; overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
  font-family: var(--ui); font-weight: 400; background: var(--night); color: var(--text);
}
button { font: inherit; color: inherit; cursor: pointer; font-family: var(--ui); }
svg { display: block; }

.world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; }
.app { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.app > * { pointer-events: auto; }
.hud, .banner, .floaters, .booster { pointer-events: none !important; }

/* ---------- top bar ---------- */
.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 12px 16px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand { font-family: var(--display); font-size: 26px; letter-spacing: .5px; display: flex; align-items: center; gap: 4px; color: var(--text); }
.brand em { font-style: normal; color: var(--hot); }
.brand-mark { width: 34px; height: 34px; display: block; }
.puzzle-no {
  font-size: 13px; padding: 2px 10px; font-family: var(--ui); font-weight: 700; color: var(--text);
  background: rgba(21, 18, 58, .85); border: 2px solid var(--edge); border-radius: 99px;
}
.puzzle-no:empty { display: none; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; display: grid; place-items: center; padding: 0; transition: transform .1s;
  border: 2px solid var(--edge); border-radius: 12px; background: rgba(21, 18, 58, .85); color: var(--text);
}
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .q { line-height: 1; font-family: var(--display); font-weight: 400; font-size: 21px; }
.icon-btn:active { transform: scale(.92); }
#muteBtn .snd-off { display: none; }
#muteBtn.muted .snd-on { display: none; }
#muteBtn.muted .snd-off { display: inline; }

/* ---------- HUD on the landscape ---------- */
.hud {
  position: absolute; top: calc(var(--vt) + 4px); right: calc(100vw - var(--vr) + 18px); text-align: right;
  transition: right .5s cubic-bezier(.3, 1.2, .5, 1), top .5s;
}
.hud-label { text-transform: uppercase; font-family: var(--ui); font-weight: 700; letter-spacing: 1.5px; font-size: 11px; color: var(--text); }
.hud-value {
  line-height: 1; paint-order: stroke fill; font-variant-numeric: tabular-nums; font-family: var(--display);
  font-weight: 400; font-size: 48px; color: #fff; -webkit-text-stroke: 0; letter-spacing: .5px;
}
.hud-value small { margin-left: 4px; font-family: var(--ui); font-weight: 600; font-size: 16px; color: rgba(255,255,255,.75); }
.rank-chip {
  display: inline-block; margin-top: 6px; border: 0; border-radius: 99px; background: var(--gold); color: var(--night);
  font-weight: 700; font-size: 12px; padding: 3px 11px;
}
.rank-chip:empty { display: none; }

.booster {
  position: absolute; right: calc(100vw - var(--vr) + 14px); top: calc(var(--vb) - 46px); display: flex;
  align-items: center; gap: 8px; padding: 5px 10px 5px 14px; white-space: nowrap;
  transition: opacity .3s, top .5s, right .5s; border: 2px solid var(--edge); border-radius: 99px;
  background: rgba(21, 18, 58, .88); color: var(--text); font-weight: 600; font-size: 12px;
}
.booster[hidden] { display: none; }
.flying .booster { opacity: 0; }
.pips { display: flex; gap: 4px; }
.pip {
  transition: background .2s, transform .2s; border-radius: 50%; border: 2px solid var(--dim); background: transparent;
  width: 10px; height: 10px;
}
.pip.on { background: var(--mint); border-color: var(--mint); transform: none; }

.banner {
  position: absolute; left: calc((var(--vl) + var(--vr)) / 2); top: calc(var(--vt) + (var(--vb) - var(--vt)) * .42);
  transform: translate(-50%, -50%) scale(0); text-align: center; z-index: 5; line-height: 1; paint-order: stroke fill;
  white-space: nowrap; font-family: var(--display); font-weight: 400; color: #fff; -webkit-text-stroke: 0;
  letter-spacing: .5px; font-size: clamp(28px, 5vw, 52px);
}
.banner small {
  display: block; margin-top: 6px; font-family: var(--ui); font-weight: 700; color: var(--gold);
  -webkit-text-stroke: 0; font-size: 14px; letter-spacing: 1.2px;
}
.banner.show { animation: banner 1.7s cubic-bezier(.3, 1.6, .5, 1) forwards; }
.banner.hold { animation: bannerHold .6s cubic-bezier(.3, 1.6, .5, 1) forwards; }

.floaters { position: absolute; inset: 0; }
.floater {
  position: absolute; paint-order: stroke fill; animation: floatUp 1s ease-out forwards; white-space: nowrap;
  font-family: var(--display); font-weight: 400; color: #fff; -webkit-text-stroke: 0; font-size: 24px;
}
.floater.gold { color: var(--gold); }

/* ---------- floating panel ---------- */
.panel {
  position: absolute; display: flex; flex-direction: column; gap: 10px; padding: 14px; backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px); transition: transform .55s cubic-bezier(.5, 0, .2, 1);
  background: rgba(21, 18, 58, .92); border: 2px solid var(--glow); color: var(--text);
}
@media (min-width: 900px) {
  .panel { top: 72px; right: 16px; bottom: 16px; width: min(460px, 42vw); border-radius: 22px; }
  .flying .panel { transform: translateX(calc(100% + 32px)); }
}
@media (max-width: 899px) {
  .panel { left: 0; right: 0; bottom: 0; height: min(58dvh, 600px); padding: 12px 12px 0; border-bottom: 0; border-radius: 22px 22px 0 0; }
  .flying .panel { transform: translateY(105%); }
  .brand { font-size: 22px; }
  .brand-mark { width: 30px; height: 30px; }
}

.play-bar { display: flex; gap: 10px; align-items: stretch; }
.letter-tile {
  flex: 0 0 auto; width: 54px; height: 54px; display: grid; place-items: center; border: 0; border-radius: 14px;
  transform: rotate(-3deg); background: var(--gold); color: var(--night); font-family: var(--display); font-weight: 400;
  font-size: 34px;
}
/* the letter spin at the start of a run */
.letter-tile.spinning { color: rgba(21, 18, 58, .55); }
.letter-tile.landed { animation: tileLand .55s cubic-bezier(.3, 1.7, .5, 1); }
.timer {
  flex: 1; min-width: 0; padding: 6px 12px; display: flex; flex-direction: column; justify-content: center; gap: 5px;
  border: 2px solid var(--edge); border-radius: 14px; background: var(--night-2);
}
.timer-top {
  display: flex; justify-content: space-between; align-items: baseline; text-transform: uppercase; color: var(--dim);
  font-weight: 700; letter-spacing: 1.2px; font-size: 11px;
}
.timer-top b {
  line-height: 1; font-variant-numeric: tabular-nums; font-family: var(--ui); font-weight: 700; font-size: 18px;
  color: var(--text); letter-spacing: 1px;
}
.timer-bar { overflow: hidden; border: 0; border-radius: 99px; height: 6px; background: rgba(255, 255, 255, .08); }
.timer-fill { height: 100%; width: 100%; transition: width .2s linear; background: var(--mint); }
.timer.low .timer-fill { background: var(--glow); }
.launch-btn {
  flex: 0 0 auto; min-width: 96px; padding: 0 16px; transition: transform .1s; border: 2px solid var(--glow); border-radius: 14px;
  background: transparent; color: var(--glow); font-family: var(--ui); font-weight: 700; font-size: 16px;
}
.launch-btn:active:not(:disabled) { transform: scale(.95); }
.launch-btn.armed { background: var(--glow); color: var(--night); }
.launch-btn:disabled { border-color: var(--edge); color: var(--dim); background: transparent; }

/* ---------- inputs, chips and messages ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chips:empty { display: none; }
.chip {
  border: 0; border-radius: 99px; background: rgba(255, 255, 255, .1); color: var(--text); font-weight: 600;
  font-size: 13px; padding: 3px 10px; animation: fadeIn .25s ease-out;
}

.card-input {
  flex: 1; min-width: 0; width: 100%; height: 42px; padding: 0 10px; outline: none; background: var(--night);
  border: 2px solid var(--edge); border-radius: 10px; color: var(--text); font: 500 16px var(--ui);
  caret-color: var(--glow);
}
.card-input::placeholder { color: rgba(169, 163, 214, .6); }
.card-input:focus { border-color: var(--glow); }
.card-input:disabled { background: rgba(255, 255, 255, .03); }
.card-input.shake-x { animation: shakeX .35s; border-color: var(--red); }
.card-add {
  flex: 0 0 auto; width: 42px; line-height: 1; padding: 0; transition: transform .1s; border: 2px solid var(--glow);
  border-radius: 10px; background: transparent; color: var(--glow); font-family: var(--ui); font-weight: 500;
  font-size: 22px;
}
.card-add:disabled { border-color: var(--edge); color: var(--dim); background: transparent; }
.card-add:active:not(:disabled) { transform: scale(.92); }
.card-msg { min-height: 16px; margin-top: 4px; font-size: 12px; font-weight: 600; }
.card-msg.good { color: var(--mint); }
.card-msg.bad { color: var(--glow); }

/* ---------- codewords ---------- */
.cw { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 2px 14px; }
.cw-track { display: grid; grid-template-columns: repeat(var(--cols, 10), minmax(0, 1fr)); gap: 5px; }
.cw-tile {
  display: grid; place-items: center; aspect-ratio: 1; max-height: 40px; border-radius: 9px; border: 2px solid var(--edge);
  font-family: var(--display); font-size: 17px; color: var(--dim); background: var(--night-2); transition: background .2s, border-color .2s, color .2s;
}
.cw-tile.cur { border-color: var(--gold); color: var(--gold); }
.cw-tile.done { background: var(--mint); border-color: var(--mint); color: var(--night); }
.cw-tile.skipped { border-style: dashed; color: var(--text); }
.cw-card { background: var(--night-2); border: 2px solid var(--edge); border-radius: 16px; padding: 14px; }
.cw-card:focus-within { border-color: var(--glow); }
.cw-kicker { font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.cw-clue { font-family: var(--display); font-size: 34px; line-height: 1.1; margin: 2px 0 12px; color: var(--text); overflow-wrap: anywhere; }
.cw-clue.in { animation: fadeUp .3s ease-out; }
.cw-form { display: flex; gap: 6px; }
.cw-form .card-input { text-transform: uppercase; letter-spacing: 1px; }
.cw-form .card-input::placeholder { text-transform: none; letter-spacing: 0; }
.cw-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.cw-row .card-msg { margin-top: 0; }
.cw-skip {
  flex: 0 0 auto; border: 2px solid var(--edge); border-radius: 10px; background: transparent; color: var(--text);
  font-weight: 700; font-size: 13px; padding: 5px 14px;
}
.cw-skip:disabled { color: var(--dim); }
.cw-skip:active:not(:disabled) { transform: scale(.95); }
.card-msg.close { color: var(--gold); }
.cw-solved { margin-top: 0; }
.cw-bd { display: grid; grid-template-columns: 30px 1fr auto; align-items: center; gap: 10px; }
.cw-bd .cw-tile { width: 30px; max-height: none; font-size: 15px; }
.cw-bd-clue { color: var(--dim); font-size: 14px; }
.cw-bd-answer { font-weight: 700; font-size: 14px; }
.cw-bd.missed .cw-bd-answer { color: var(--dim); font-weight: 600; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; padding: 16px; backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px); background: rgba(10, 8, 34, .55);
}
.overlay.show { display: grid; }
.sheet {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto;
  padding: 24px 22px; background: var(--night); border: 2px solid var(--glow); border-radius: 24px; color: var(--text);
  animation: fadeUp .35s ease-out;
}
.sheet h2 { font-size: 30px; margin: 0 0 8px; font-family: var(--display); font-weight: 400; letter-spacing: .5px; }
.sheet p { line-height: 1.45; }
.muted { font-size: 14px; color: var(--dim); }
.close-btn {
  position: absolute; right: 14px; top: 14px; width: 36px; height: 36px; display: grid; place-items: center; padding: 0;
  z-index: 2; border: 2px solid var(--edge); border-radius: 50%; background: var(--night); color: var(--text);
}
.close-btn svg { width: 16px; height: 16px; }

.intro-sheet { padding-top: 16px; text-align: center; background: linear-gradient(#2c2163, var(--night) 45%); }
.intro-sheet .site-foot { margin-top: 12px; }
.intro-pig { width: clamp(96px, 17dvh, 140px); margin: 0 auto; animation: bob 2.2s ease-in-out infinite; }
.pig { display: block; width: 100%; height: auto; overflow: visible; }
.wing { transform-box: view-box; transform-origin: 112px 76px; animation: flap .32s ease-in-out infinite alternate; }
.wing-back { animation-delay: -.08s; }
.scarf-tail { transform-box: view-box; transform-origin: 150px 70px; animation: scarf .5s ease-in-out infinite alternate; }
.logo {
  font-family: var(--display); font-weight: 400; font-size: 58px; line-height: 1; margin: 4px 0 0; color: #fff; letter-spacing: 1px;
  -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill;
}
.logo span { color: var(--hot); }
.tagline { margin: 8px 0 2px; font-weight: 600; font-size: 16px; }
.intro-date { font-weight: 800; color: var(--dim); letter-spacing: 1px; text-transform: uppercase; font-size: 11px; }
.steps { list-style: none; padding: 0; margin: 14px 0; text-align: left; display: grid; gap: 6px; }
.steps li {
  display: flex; gap: 10px; align-items: center; padding: 7px 10px; line-height: 1.3; background: var(--night-2);
  border: 0; border-radius: 14px; font-size: 14px; font-weight: 400;
}
.steps b {
  flex: 0 0 auto; width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 50%;
  background: var(--glow); color: var(--night); font-family: var(--ui); font-weight: 800; font-size: 13px;
}
.steps em { font-style: normal; font-weight: 900; color: var(--gold); }
.big-btn {
  width: 100%; padding: 14px; letter-spacing: .5px; transition: transform .1s; border: 0; border-radius: 14px;
  background: var(--glow); color: var(--night); font-family: var(--ui); font-weight: 700; font-size: 17px;
}
.big-btn:active { transform: scale(.97); }

.results-sheet { padding-top: 0; }
.res-hero {
  margin: 0 -22px 14px; padding: 26px 20px 20px; text-align: center; border-radius: 25px 25px 0 0;
  background: linear-gradient(#2c2163, #6b3a86 75%, #c4588f); border-bottom: 0; color: #fff;
}
.res-pig { width: 130px; margin: -12px auto 0; animation: bob 2.2s ease-in-out infinite; }
.res-title {
  paint-order: stroke fill; font-family: var(--ui); font-weight: 600; font-size: 14px; -webkit-text-stroke: 0;
  color: rgba(255,255,255,.8);
}
.res-alt {
  line-height: 1.05; paint-order: stroke fill; font-variant-numeric: tabular-nums; font-family: var(--display);
  font-weight: 400; font-size: 66px; -webkit-text-stroke: 0;
}
.res-alt small { margin-left: 4px; font-family: var(--ui); font-weight: 600; font-size: 20px; }
.res-rank {
  display: inline-block; margin-top: 8px; padding: 3px 14px; border: 0; border-radius: 99px; background: var(--gold);
  color: var(--night); font-weight: 700; font-size: 13px;
}
.res-stats, .record { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; text-align: center; }
.record { grid-template-columns: repeat(4, 1fr); }
.res-stats div, .record div { padding: 8px 4px; background: var(--night-2); border: 0; border-radius: 14px; }
.res-stats b, .record b { display: block; font-family: var(--ui); font-weight: 700; font-size: 20px; }
.res-stats span, .record span { font-weight: 900; text-transform: uppercase; color: var(--dim); font-size: 9px; letter-spacing: 1px; }
.today { margin: -4px 0 14px; padding: 12px; border-radius: 14px; background: var(--night-2); }
.today-line { text-align: center; font-size: 14px; color: var(--dim); margin-bottom: 10px; }
.today-line b { color: var(--text); }
.sty { display: block; width: 100%; height: 190px; border-radius: 10px; }
.res-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; }
.res-actions .big-btn { padding: 12px 8px; font-size: 16px; }
.share-btn { background: var(--glow); }
.replay-btn { background: transparent; color: var(--glow); border: 2px solid var(--glow); }
.res-section-title {
  margin: 18px 0 8px; font-family: var(--ui); font-weight: 700; font-size: 12px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--dim);
}
.breakdown { display: grid; gap: 8px; }
.bd-row { padding: 8px 10px; border: 2px solid var(--edge); border-radius: 14px; background: var(--night-2); }

.next { text-align: center; margin-top: 4px; color: var(--dim); font-size: 13px; font-weight: 500; }
.next b { font-weight: 400; font-variant-numeric: tabular-nums; font-family: var(--ui); color: var(--text); font-size: 16px; }

.score-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.score-table td { padding: 8px 6px; border-bottom: 2px dashed var(--edge); }
.score-table td:last-child { text-align: right; font-weight: 900; white-space: nowrap; }
.gold { font-weight: 900; color: var(--gold); }

/* ---------- footer links (intro, help, end card, about page) ---------- */
.site-foot { display: flex; justify-content: center; align-items: center; gap: 8px; margin-top: 16px; font-size: 12px; color: var(--dim); }
.site-foot a { color: var(--dim); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(169, 163, 214, .4); }
.site-foot a:hover { color: var(--text); }

/* ---------- how to play + about sheet ---------- */
.info-sheet { line-height: 1.5; }
.info-sheet p { margin: 0 0 10px; font-size: 15px; }
.info-sheet em { font-style: normal; font-weight: 600; }
.info-sheet h3 { font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: .3px; margin: 20px 0 6px; color: var(--gold); scroll-margin-top: 12px; }
.tips { margin: 0 0 6px; padding-left: 18px; font-size: 14px; color: var(--dim); }
.tips li { margin-bottom: 6px; }
.tips b { color: var(--text); }
.info-sheet .big-btn { margin-top: 8px; }

/* ---------- keyframes ---------- */
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-8px) rotate(-8deg); } }
@keyframes flap { from { transform: rotate(-24deg); } to { transform: rotate(14deg); } }
@keyframes scarf { from { transform: skewY(-6deg); } to { transform: skewY(6deg) scaleX(1.06); } }
@keyframes shakeX { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
@keyframes floatUp { 0% { transform: translate(-50%, 0) scale(.6); opacity: 0; } 20% { transform: translate(-50%, -14px) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -80px) scale(1); opacity: 0; } }
@keyframes banner {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-8deg); opacity: 1; }
  18% { transform: translate(-50%, -50%) scale(1.15) rotate(-3deg); }
  28% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  80% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); opacity: 1; }
  100% { transform: translate(-50%, -90%) scale(.9) rotate(-3deg); opacity: 0; }
}
@keyframes bannerHold {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-8deg); }
  60% { transform: translate(-50%, -50%) scale(1.15) rotate(-3deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes tileLand {
  0% { transform: rotate(-3deg) scale(1.45); outline: 0 solid rgba(255, 210, 63, .6); }
  40% { outline: 10px solid rgba(255, 210, 63, 0); }
  100% { transform: rotate(-3deg) scale(1); outline: 10px solid rgba(255, 210, 63, 0); }
}
@keyframes sheetIn { from { transform: translateY(30px) scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
