:root {
  --sky-top: #ff4f97;
  --sky-mid: #ff9cc9;
  --sky-low: #ffd4a8;
  --raspberry: #e8175d;
  --rasp-deep: #9b0a45;
  --bubblegum: #ff8fc3;
  --mint: #2fd3b6;
  --mint-deep: #0f9e8a;
  --honey: #ffb21a;
  --honey-deep: #f07800;
  --grape: #4a0f3d;
  --sugar: #fff4f9;
  --white: #ffffff;
  --accent: var(--raspberry);
  --hard: #e8175d;
  --super: #8a3ad6;
  --display: "Lilita One", "Arial Rounded MT Bold", ui-rounded, system-ui, sans-serif;
  --body: "Baloo 2", ui-rounded, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body[data-tier="hard"] { --sky-top: #e8175d; --sky-mid: #ff6f9f; --sky-low: #ffc2a0; }
body[data-tier="super"] { --accent: var(--super); --sky-top: #7a2fd0; --sky-mid: #c77ff0; --sky-low: #ffc6e6; }

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--sky-top);
  color: var(--grape);
  font-family: var(--body);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: relative;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: calc(6px + var(--safe-top)) 10px calc(10px + var(--safe-bottom));
  background:
    repeating-conic-gradient(from 0deg at 50% -8%, rgba(255, 255, 255, 0.11) 0deg 5.5deg, transparent 5.5deg 11.5deg),
    linear-gradient(var(--sky-top), var(--sky-mid) 50%, var(--sky-low));
}

button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 3px solid var(--white); outline-offset: 2px; }

#top { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; }

.round {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  padding: 0 0 3px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: no-repeat center / contain url("./art/hud/btn-round.png");
  filter: drop-shadow(0 2px 2px rgba(74, 15, 61, 0.25));
}
.round svg { filter: drop-shadow(1.4px 0 0 var(--grape)) drop-shadow(-1.4px 0 0 var(--grape)) drop-shadow(0 1.4px 0 var(--grape)) drop-shadow(0 -1.4px 0 var(--grape)); }
.round svg { width: 22px; height: 22px; }
.round.small { width: 38px; height: 38px; }
.round.small svg { width: 19px; height: 19px; }
#sound .mute { display: none; }
#sound.off .mute { display: inline; }
#sound.off .waves { display: none; }

.title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; line-height: 1; }
.title .who { display: flex; align-items: center; gap: 4px; }
#dot-hud { width: 40px; height: 40px; object-fit: contain; margin: -6px 0 -4px -10px; filter: drop-shadow(0 2px 2px rgba(74, 15, 61, 0.3)); animation: hover 2.4s ease-in-out infinite alternate; }
#dot-hud.away { visibility: hidden; }
.title b {
  font-family: var(--display);
  font-weight: 400;
  font-size: 33px;
  letter-spacing: -0.015em;
  background: linear-gradient(180deg, #fffbd6, #ffd23f 45%, #ff9a00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(1.6px 0 0 var(--grape)) drop-shadow(-1.6px 0 0 var(--grape)) drop-shadow(0 1.6px 0 var(--grape)) drop-shadow(0 -1.6px 0 var(--grape)) drop-shadow(0 3px 0 var(--raspberry));
  white-space: nowrap;
}
#tier {
  margin-top: 4px;
  color: var(--white);
  filter: drop-shadow(1px 0 0 var(--grape)) drop-shadow(-1px 0 0 var(--grape)) drop-shadow(0 1px 0 var(--grape)) drop-shadow(0 -1px 0 var(--grape));
}
.tier-flag { display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-family: var(--body); font-weight: 800; font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; line-height: 1; }
.tier-flag svg { width: 13px; height: 13px; flex: none; }
#tier:empty { display: none; }

.pills { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  min-width: 74px;
  padding: 0 10px 2px 6px;
  border-style: solid;
  border-image: url("./art/hud/pill-white.png") 0 90 fill / 0 15px stretch;
  font-family: var(--display);
  font-size: 18px;
  color: var(--grape);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.pill img { width: 24px; height: 24px; object-fit: contain; margin: -8px -2px 0 -5px; filter: drop-shadow(0 1px 0 rgba(74, 15, 61, 0.3)); }
.pill b { font-weight: 400; flex: 1; text-align: right; }
.pill.small { height: 24px; min-width: 58px; font-size: 14px; border-image-width: 0 12px; }
.pill.small img { width: 19px; height: 19px; margin: -8px -4px 0 -3px; }

#goal-bar { padding: 0 2px 2px; }
#goal-bar .row { display: flex; align-items: center; gap: 22px; }
#goal-bar .row #goal { flex: 1; }

#wing {
  flex: none;
  width: 54px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0 0 3px;
  border-style: solid;
  border-image: url("./art/hud/btn-honey.png") 0 118 fill / 0 17px stretch;
  background: none;
  color: var(--white);
}
#wing svg { width: 24px; height: 24px; overflow: visible; }
#wing svg path { stroke: var(--grape); stroke-width: 3px; stroke-linejoin: round; paint-order: stroke fill; }
#wing.on { filter: brightness(1.08) drop-shadow(0 0 6px rgba(255, 210, 63, 0.9)); animation: pulse 0.6s ease-in-out infinite alternate; }
#wing:disabled { filter: saturate(0.4); opacity: 0.55; }

#goal {
  position: relative;
  height: 32px;
  margin-right: 16px;
  border-style: solid;
  border-image: url("./art/hud/pill-white.png") 0 90 fill / 0 16px stretch;
}
#goal::before {
  content: "";
  position: absolute;
  inset: 7px 11px 10px;
  border-radius: 99px;
  background: linear-gradient(180deg, #5a0a33, #8a0f45);
  box-shadow: inset 0 2px 3px rgba(40, 0, 20, 0.5);
}

#goal::after {
  content: "";
  position: absolute;
  inset: 7px 11px 10px;
  border-radius: 99px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(100% / var(--n, 10) - 2px), rgba(255, 255, 255, 0.55) calc(100% / var(--n, 10) - 2px) calc(100% / var(--n, 10)));
  pointer-events: none;
}
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#goal-fill {
  position: absolute;
  left: 11px;
  top: 7px;
  bottom: 10px;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(180deg, #fff2a6, var(--honey) 45%, var(--honey-deep));
  box-shadow: inset 0 -2px 0 rgba(240, 120, 0, 0.6);
  transition: width 0.3s ease-out;
}
#goal-fill::after {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 2px;
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.75);
}

#goal-tick {
  position: absolute;
  top: -9px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: no-repeat center / contain url("./art/hud/icon-star.png");
  filter: drop-shadow(0 2px 0 rgba(74, 15, 61, 0.35));
  pointer-events: none;
}
#goal-tick::after { content: attr(data-n); position: absolute; left: -9px; bottom: -5px; z-index: 1; font-family: var(--display); font-size: 14px; color: var(--white); -webkit-text-stroke: 3px var(--grape); paint-order: stroke fill; }
#goal.grow { animation: bar-grow 0.6s cubic-bezier(0.2, 1.6, 0.4, 1); }
#goal.grow #goal-tick { animation: pop 0.5s cubic-bezier(0.2, 1.8, 0.4, 1); }
@keyframes bar-grow { 30% { transform: scaleX(0.94) scaleY(1.15); filter: drop-shadow(0 0 8px rgba(255, 210, 63, 0.9)); } }
#sheet-body .passed { font-family: var(--display); font-size: 22px; color: var(--honey-deep); margin-top: 2px; }
@keyframes pop { 50% { transform: scale(1.5); } }

#goal .pot {
  position: absolute;
  right: -20px;
  top: 50%;
  width: 34px;
  height: 40px;
  margin-top: -22px;
  background: no-repeat center / contain url("./art/pot-empty.png");
  filter: drop-shadow(0 2px 0 rgba(155, 10, 69, 0.35));
}

#goal span {
  position: relative;
  display: block;
  text-align: left;
  padding-left: 20px;
  line-height: 29px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--white);
  -webkit-text-stroke: 3px var(--grape);
  paint-order: stroke fill;
}

#status { margin: 4px 0 0; min-height: 18px; text-align: center; font-size: 14px; font-weight: 700; color: var(--grape); opacity: 0.8; }
#status.urgent { color: var(--raspberry); opacity: 1; animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }

#stage { position: relative; flex: 1; min-height: 0; }
#board { position: absolute; inset: 0; display: block; touch-action: none; }

#sheet-body p.tier-flag { display: flex; margin: -4px 0 8px; color: var(--accent); font-size: 14px; }
#sheet-body p.tier-flag svg { width: 16px; height: 16px; }
#sheet-body .tips { list-style: none; margin: 6px 0 4px; padding: 0; display: grid; gap: 6px; text-align: left; }
#sheet-body .tips li { display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 6px; border-radius: 16px; font-size: 16px; font-weight: 800; line-height: 1.2; }
#sheet-body .tips li.good { background: #d9fbf2; color: #0b6b5c; }
#sheet-body .tips li.bad { background: #ffe0ea; color: var(--rasp-deep); }
#sheet-body .tips img, #sheet-body .tips canvas, #sheet-body .tips .hole { flex: none; width: 32px; height: 32px; object-fit: contain; }
#sheet-body .tips .hole { display: block; border-radius: 50%; background: radial-gradient(circle, #ff9cc9 0 45%, #fff 46% 60%, transparent 61%); }
#sheet.intro { cursor: pointer; }
#banner .tips .hole { display: block; border-radius: 50%; background: radial-gradient(circle, #ff9cc9 0 45%, #fff 46% 60%, transparent 61%); }

#toast {
  position: absolute;
  left: 50%;
  bottom: 8px;
  padding: 7px 20px 10px;
  border-style: solid;
  border-image: url("./art/hud/pill-white.png") 0 90 fill / 0 19px stretch;
  filter: drop-shadow(0 6px 10px rgba(74, 15, 61, 0.3));
  color: var(--grape);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#dock { padding-top: 6px; }

#tray {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  height: 70px;
  padding: 0 14px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75), 0 6px 16px rgba(74, 15, 61, 0.1);
}

#now { position: relative; width: 96px; height: 70px; }
#now .ground { position: absolute; left: 50%; bottom: 6px; width: 70px; height: 14px; margin-left: -35px; border-radius: 50%; background: rgba(74, 15, 61, 0.22); filter: blur(5px); animation: piece-shadow 3.2s ease-in-out infinite; }
#now .lift { position: absolute; left: 50%; bottom: 12px; margin-left: -42px; display: block; animation: piece-float 3.2s ease-in-out infinite; }
#now canvas { display: block; filter: drop-shadow(0 8px 6px rgba(74, 15, 61, 0.28)); }
#now.nope .lift { animation: nope 0.32s ease-in-out; }
#next { display: flex; align-items: center; gap: 8px; justify-self: start; }
#next canvas { display: block; opacity: 0.75; }
#next canvas:nth-child(2) { opacity: 0.55; }
#next canvas:nth-child(3) { opacity: 0.4; }
#next canvas:nth-child(4) { opacity: 0.3; }
#now.shift .lift { animation: settle 0.22s ease-out; }
#next.shift canvas { animation: slide 0.16s ease-out; }
@keyframes slide { from { transform: translateX(22px); } to { transform: none; } }
@keyframes settle { from { transform: translateX(46px) scale(0.5); opacity: 0.6; } to { transform: none; } }
@keyframes piece-float { 0%, 100% { transform: translateY(0) rotate(-2.5deg); } 50% { transform: translateY(-4px) rotate(2.5deg); } }
@keyframes piece-shadow { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.85); opacity: 0.7; } }
@keyframes nope { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-12deg); } 45% { transform: rotate(10deg); } 70% { transform: rotate(-6deg); } 85% { transform: rotate(3deg); } }

#hint {
  position: relative;
  justify-self: start;
  width: 64px;
  height: 58px;
  padding: 4px 0 6px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #fff0f6);
  box-shadow: inset 0 0 0 2.5px var(--raspberry), inset 0 3px 0 rgba(255, 255, 255, 0.9), 0 3px 0 var(--rasp-deep), 0 6px 10px rgba(74, 15, 61, 0.18);
  color: var(--raspberry);
}
#hint .row { display: flex; align-items: center; gap: 2px; }
#hint img { width: 24px; height: 26px; object-fit: contain; }
#hint b { font-family: var(--display); font-weight: 400; font-size: 21px; line-height: 1; color: var(--grape); }
#hint small { font-family: var(--display); font-size: 13px; line-height: 1; letter-spacing: 0.02em; }
#hint:disabled { filter: saturate(0.3); opacity: 0.6; }
#hint.pulse { animation: hint-pulse 0.9s ease-in-out infinite alternate; }
@keyframes hint-pulse { to { transform: scale(1.08); filter: drop-shadow(0 0 6px rgba(255, 111, 166, 0.8)); } }

#sheet {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(74, 15, 61, 0.45);
  backdrop-filter: blur(4px);
  animation: fade 0.2s ease-out;
}
#sheet[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } }

#sheet-body {
  width: 100%;
  max-width: 350px;
  max-height: 100%;
  overflow: auto;
  padding: 24px 20px 18px;
  border-radius: 32px;
  text-align: center;
  color: var(--grape);
  background: linear-gradient(180deg, var(--white), #ffe0ee);
  box-shadow: 0 0 0 4px var(--white), 0 0 0 7px var(--raspberry), 0 16px 40px rgba(74, 15, 61, 0.45);
  animation: rise 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
}
@keyframes rise { from { transform: translateY(24px) scale(0.94); opacity: 0; } }

#sheet-body h2 {
  margin: 0 0 6px;
  font-family: var(--display);
  font-weight: 400;
  font-size: 33px;
  letter-spacing: -0.015em;
  background: linear-gradient(180deg, #fffbd6, #ffd23f 45%, #ff9a00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(1.6px 0 0 var(--grape)) drop-shadow(-1.6px 0 0 var(--grape)) drop-shadow(0 1.6px 0 var(--grape)) drop-shadow(0 -1.6px 0 var(--grape)) drop-shadow(0 3px 0 var(--raspberry));
}
#sheet.lose #sheet-body h2 { font-size: 34px; letter-spacing: 0; background: none; color: var(--raspberry); filter: none; text-shadow: 0 3px 0 rgba(155, 10, 69, 0.25); }
#sheet-body p { margin: 6px 0; }
#sheet-body .sub { font-weight: 600; opacity: 0.8; }
#sheet-body ul { text-align: left; padding-left: 20px; margin: 14px 0 0; line-height: 1.45; font-size: 15px; font-weight: 600; }
#sheet-body .big { font-family: var(--display); font-size: 42px; color: var(--honey-deep); text-shadow: 0 3px 0 rgba(240, 120, 0, 0.25); }
#sheet-body .badge { display: inline-block; margin: 4px; padding: 3px 12px; border-radius: 12px; background: #ffe0ee; color: var(--raspberry); font-weight: 800; }
#sheet-body .kicker { margin: -2px 0 0; font-size: 14px; font-weight: 800; color: var(--raspberry); opacity: 0.8; text-transform: uppercase; letter-spacing: 0.08em; }
#sheet-body .more { font-weight: 700; color: var(--honey-deep); }

#sheet-body button {
  margin-top: 12px;
  width: 100%;
  min-height: 60px;
  padding: 6px 18px 10px;
  font-family: var(--display);
  font-size: 26px;
  color: var(--white);
  -webkit-text-stroke: 4px var(--grape);
  paint-order: stroke fill;
  background: none;
  border-style: solid;
  border-image: url("./art/hud/btn-honey.png") 0 118 fill / 0 30px stretch;
}
#sheet-body button:active { transform: translateY(3px); }
#sheet-body button.ghost {
  min-height: 50px;
  font-size: 20px;
  color: var(--raspberry);
  -webkit-text-stroke: 0;
  border-image: url("./art/hud/pill-white.png") 0 90 fill / 0 25px stretch;
}
#sheet-body button.link { border: 0; border-image: none; min-height: 0; background: none; -webkit-text-stroke: 0; color: var(--raspberry); font-family: var(--body); font-weight: 800; font-size: 16px; text-decoration: underline; padding: 8px; margin-top: 4px; }
#sheet-body button small { display: block; font-family: var(--body); font-weight: 800; font-size: 13px; -webkit-text-stroke: 0; opacity: 0.9; }
#sheet-body button:not(.ghost) small { margin-top: -6px; color: #fff2a6; -webkit-text-stroke: 2px #000; paint-order: stroke fill; }
#sheet-body button.ghost small { margin-top: -6px; color: #ff8fc3; -webkit-text-stroke: 2px var(--rasp-deep); paint-order: stroke fill; }
#sheet-body button.share { flex: 0 0 62px; width: 62px; height: 62px; padding: 0 0 4px; display: grid; place-items: center; border: 0; border-image: none; background: no-repeat center / contain url("./art/hud/btn-round.png"); }
#sheet-body button.share svg { width: 27px; height: 34px; margin: 2px 0 0 1px; }
#sheet-body .row { display: flex; gap: 10px; }

.stars { margin: 4px 0 8px; display: flex; justify-content: center; gap: 4px; }
.stars i { width: 60px; height: 60px; font-size: 0; display: inline-block; background: no-repeat center / contain url("./art/hud/icon-star.png"); filter: grayscale(1) opacity(0.25); }
.stars i:nth-child(2) { transform: translateY(-8px); }
.stars.many i { width: 46px; height: 46px; }
.stars.many i:nth-child(2) { transform: none; }
.stars i.on { filter: drop-shadow(0 3px 2px rgba(240, 120, 0, 0.4)); animation: star 0.45s cubic-bezier(0.2, 1.8, 0.4, 1) both; }
@keyframes star { from { transform: scale(0) rotate(-40deg); opacity: 0; } }

#sheet.lose #sheet-body { background: linear-gradient(180deg, var(--white), #ffd6d6); }

.logo { display: flex; flex-direction: column; align-items: center; margin-bottom: 4px; }
.logo .wordmark { width: 230px; height: auto; display: block; filter: drop-shadow(0 4px 0 rgba(155, 10, 69, 0.25)); }
.logo .dot { width: 120px; height: auto; margin-top: -6px; animation: hover 2.4s ease-in-out infinite alternate; }
@keyframes hover { to { transform: translateY(-6px) rotate(-3deg); } }
#sheet-body .mascot { display: block; width: 96px; height: auto; margin: 0 auto -4px; filter: drop-shadow(0 6px 8px rgba(74, 15, 61, 0.25)); }

.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin: 8px 0; }
#sheet-body .grid button.lv {
  position: relative;
  margin: 0;
  min-height: 0;
  aspect-ratio: 1;
  padding: 12px 0;
  border: 0;
  border-image: none;
  font-size: 32px;
  line-height: 1;
  border-radius: 18px;
  --lv: linear-gradient(180deg, #9ff7e4, var(--mint) 55%, var(--mint-deep));
  background: var(--lv);
}
#sheet-body .grid button.lv .cell-stars { position: absolute; left: 0; right: 0; bottom: -2px; display: flex; justify-content: center; height: 15px; font-size: 11px; line-height: 15px; }
#sheet-body .grid button.lv .cell-stars img { width: 15px; height: 15px; margin: 0 -1.34px; filter: drop-shadow(0 3px 2px rgba(240, 120, 0, 0.4)); }
#sheet-body .grid button.lv .cell-stars img.off { filter: grayscale(1) opacity(0.45); }
#sheet-body .grid button.lv .cell-stars.many img { width: 12px; height: 12px; margin: 0 -1.5px; }
.star-run { display: inline-flex; gap: 0.1em; vertical-align: -0.12em; }
.star-run img { width: 1em; height: 1em; object-fit: contain; filter: drop-shadow(0 0.12em 0.08em rgba(240, 120, 0, 0.4)); }
#sheet-body .grid button.lv.hard { --lv: linear-gradient(180deg, #ff86b6, var(--raspberry) 55%, #b3003f); }
#sheet-body .grid button.lv.super { --lv: linear-gradient(180deg, #c9a6ff, var(--super) 55%, #4a1a80); }
#sheet-body .grid button.lv:disabled { display: grid; place-items: center; padding: 0; background: linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)), var(--lv); box-shadow: inset 0 0 0 3px rgba(74, 15, 61, 0.5); }
#sheet-body .grid button.lv .lock { font-size: 32px; line-height: 1; -webkit-text-stroke: 0; filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 4px #fff); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
