:root {
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --ink: #5a3d66;
  --rose: #ff4f86;
  --rose-deep: #e1366c;
  --card: rgba(255, 252, 255, 0.86);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #f6e9ff;
  color: var(--ink);
  font-family: Nunito, "Trebuchet MS", "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body {
  position: fixed;
  inset: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.topbar, .subbar {
  position: fixed;
  z-index: 6;
  left: 50%;
  transform: translateX(-50%);
  width: min(760px, calc(100% - 16px));
  display: flex;
  align-items: center;
  pointer-events: none;
}

.topbar {
  top: calc(10px + var(--sat));
  justify-content: space-between;
  gap: 8px;
}

.subbar {
  top: calc(58px + var(--sat));
  justify-content: center;
  gap: 8px;
}

body[data-state="menu"] .topbar,
body[data-state="menu"] .subbar,
body[data-state="load"] .topbar,
body[data-state="load"] .subbar,
body[data-state="over"] .topbar,
body[data-state="over"] .subbar {
  visibility: hidden;
}

.pill {
  pointer-events: none;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 8px 20px rgba(120, 70, 150, 0.12);
  font-weight: 800;
  letter-spacing: 0.01em;
}

.pill.score {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  padding-inline: 18px;
}

.pill.score span {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
}

.pill.score b {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 22px;
  color: var(--rose);
}

.pill.round b { color: #1c7c96; }

#status {
  font-size: 12px;
  font-weight: 800;
  color: rgba(90, 61, 102, 0.8);
}

#status.is-hot { color: #e23b6a; }

.texty[hidden] { display: none; }

.texty {
  display: block;
  margin: 8px auto 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.hud-actions button, .card .go {
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.hud-actions button {
  pointer-events: auto;
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(120, 70, 150, 0.12);
}

.hud-actions button[aria-pressed="false"] {
  opacity: 0.45;
}

.sub-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(90, 61, 102, 0.72);
}

#pips { display: flex; gap: 5px; }

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(120, 70, 150, 0.15);
}

.pip.on {
  background: #ff6b9a;
  box-shadow: 0 0 0 3px rgba(255, 107, 154, 0.18);
}

.card {
  position: fixed;
  z-index: 3;
  left: 50%;
  bottom: calc(286px + var(--sab));
  transform: translateX(-50%);
  width: min(420px, calc(100% - 28px));
  padding: 22px 22px 18px;
  border-radius: 28px;
  background: var(--card);
  backdrop-filter: blur(14px);
  box-shadow:
    0 18px 50px rgba(120, 70, 150, 0.18),
    inset 0 0 0 2px rgba(255, 255, 255, 0.95);
  text-align: center;
}

.card.slim { padding-top: 18px; }

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #b06bd4;
}

h1, h2 {
  font-family: Fredoka, Nunito, sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: #ff4f86;
}

h1 { font-size: 52px; line-height: 0.95; margin: 2px 0 8px; }
h2 { font-size: 34px; margin: 2px 0 8px; }

.lead {
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 14px;
}

.go {
  min-height: 52px;
  padding: 0 28px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff9cba 0%, #ff4f86 100%);
  color: white;
  font-size: 20px;
  box-shadow: 0 6px 0 var(--rose-deep);
}

.go:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 var(--rose-deep);
}

.ghost {
  display: block;
  width: 100%;
  min-height: 46px;
  margin-top: 8px;
  border: 0;
  border-radius: 999px;
  background: #f3eaf8;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  font-size: 18px;
  cursor: pointer;
}

#paused .go { width: 100%; }

.hint, .meta {
  margin-top: 10px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(90, 61, 102, 0.75);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 7px;
  background: white;
  box-shadow: inset 0 0 0 1px rgba(120, 70, 150, 0.15);
}

.scoreline {
  display: flex;
  justify-content: center;
  gap: 22px;
  margin-bottom: 14px;
}

.scoreline b {
  display: block;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 32px;
  color: var(--rose);
  line-height: 1;
}

.scoreline span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

@media (max-height: 680px) {
  h1 { font-size: 40px; }
  .card { bottom: calc(210px + var(--sab)); padding: 16px; }
  .lead { margin-bottom: 10px; }
}

@media (max-width: 380px) {
  h1 { font-size: 40px; }
  .pill.score b { font-size: 18px; }
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: linear-gradient(180deg, #fff4d8 0%, #f6e4ff 46%, #ffe3f0 100%);
  transition: opacity 0.45s ease;
}

.splash.gone { opacity: 0; pointer-events: none; }

.splash canvas {
  width: 100%;
  height: 100%;
}

.splash-name {
  position: absolute;
  left: 50%;
  top: 43%;
  transform: translate(-50%, -50%);
  width: min(92vw, 460px);
  font-family: Fredoka, Nunito, sans-serif;
  font-size: clamp(32px, 8vw, 52px);
  text-align: center;
  white-space: nowrap;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, #ff4f86, #7b5cff 55%, #1493a8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 10px 18px rgba(90, 60, 130, 0.16));
  animation: splash-in 0.7s ease both;
}

.splash-tag {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(88vw, 360px);
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  color: #5a3d66;
  animation: splash-in 0.8s 0.12s ease both;
}

@keyframes splash-in {
  from { opacity: 0; transform: translate(-50%, -40%); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

.install {
  position: absolute;
  top: calc(78px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: #1f8a72;
  color: #fff;
  font: inherit;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(31, 138, 114, 0.25);
  cursor: pointer;
}

.install[hidden] { display: none; }

.install-note {
  position: absolute;
  top: calc(118px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, calc(100% - 32px));
  text-align: center;
  pointer-events: none;
}

.install-note[hidden] { display: none; }

.loadbar {
  position: absolute;
  left: 50%;
  top: 57%;
  transform: translateX(-50%);
  width: min(240px, 62vw);
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow:
    0 10px 24px rgba(90, 60, 130, 0.14),
    inset 0 0 0 2px #fff;
  overflow: hidden;
}

.loadbar i {
  display: block;
  position: relative;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe08a, #ff4f86 42%, #7b5cff 78%, #2ad4e2);
}

.loadbar i::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), transparent 55%);
}

.hub {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.hub button { pointer-events: auto; }

.coin {
  position: absolute;
  top: calc(16px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 92px;
  padding: 6px 16px 8px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(90, 60, 130, 0.12);
  pointer-events: none;
}

.coin span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.6;
}

.coin b {
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 26px;
  line-height: 1;
  color: #ff4f86;
}

.hub-side {
  position: absolute;
  top: 30%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.hub-side.left { left: max(14px, calc(50% - 360px)); }
.hub-side.right { right: max(14px, calc(50% - 360px)); }

.sidebtn {
  width: 118px;
  min-height: 92px;
  padding: 12px 10px 10px;
  border: 0;
  border-radius: 26px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  box-shadow:
    0 12px 28px rgba(90, 60, 130, 0.14),
    inset 0 0 0 2px #fff;
  cursor: pointer;
}

.sidebtn small {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.55;
}

.sidebtn.locked {
  background: #f4f1f6;
  color: #9a90a4;
  box-shadow: inset 0 0 0 2px #e6e0ea;
  cursor: default;
}

.mark {
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 6px;
  border-radius: 50%;
}

.mark.spark {
  background:
    radial-gradient(circle at 50% 50%, #fff 0 3px, transparent 4px),
    conic-gradient(from 20deg, #ffb4cc, #7ad4e6, #ffe08a, #ffb4cc);
}

.mark.lock {
  background:
    linear-gradient(#c9c1d2, #c9c1d2) 8px 12px / 12px 10px no-repeat,
    radial-gradient(circle at 50% 11px, transparent 5px, #c9c1d2 6px, #c9c1d2 8px, transparent 9px);
}

.hub-play {
  position: absolute;
  left: 50%;
  bottom: calc(268px + var(--sab));
  transform: translateX(-50%);
  width: min(280px, calc(100% - 180px));
  text-align: center;
}

.playbig {
  width: 100%;
  min-height: 64px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #6ee7bf 0%, #14a37a 58%, #0c8a66 100%);
  color: #fff;
  font-family: Fredoka, Nunito, sans-serif;
  font-size: 28px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 0 rgba(8, 70, 50, 0.18);
  box-shadow:
    0 8px 0 #0b6d52,
    0 16px 28px rgba(20, 120, 90, 0.28);
  cursor: pointer;
}

.playbig:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #0b6d52;
}

.mapbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(90, 60, 130, 0.12);
  cursor: pointer;
}

.starline {
  margin: 2px 0 8px;
  font-size: 28px;
  letter-spacing: 0.14em;
  min-height: 1em;
}

.starline i, .maplvl small i { font-style: normal; }
.starline i.got, .maplvl small i.got { color: #e0a000; }
.starline i.no, .maplvl small i.no { color: #e4dced; }

.lead.extra {
  font-size: 14px;
  color: #8a7898;
}

.mapgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.maplvl {
  min-height: 74px;
  padding: 8px 8px 6px;
  border: 0;
  border-radius: 18px;
  background: #fbf9fd;
  box-shadow: inset 0 0 0 2px #f0e8f6;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.maplvl b {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.maplvl small {
  display: block;
  margin-top: 4px;
  color: #9a90a4;
  letter-spacing: 0.08em;
  font-size: 14px;
}

.maplvl.lock {
  opacity: 0.42;
  cursor: default;
}

.maplvl.lock small { color: #9a90a4; letter-spacing: 0; font-size: 12px; }

.hub-play .meta { margin: 0 0 8px; }
.hub-play .texty { margin: 0 0 8px; }

.note {
  min-height: 1.2em;
  font-size: 13px;
  font-weight: 800;
  color: #8a7898;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  background: rgba(90, 60, 110, 0.28);
  padding: 16px;
}

.sheet[hidden] { display: none; }

.sheet-card {
  width: min(560px, 100%);
  max-height: min(78vh, 720px);
  overflow: auto;
  padding: 18px 18px 14px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(70, 40, 100, 0.22);
}

.sheet-card header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sheet-card h2 { margin: 0; }

.coin.mini {
  position: static;
  transform: none;
  margin-left: auto;
  min-width: 72px;
  padding: 4px 10px;
}

.coin.mini b { font-size: 20px; }

.x {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f6f1fb;
  color: var(--ink);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
}

.tab {
  flex: 1;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: #f6f1fb;
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.tab.on { background: #1f8a72; color: #fff; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
}

.skin {
  padding: 10px;
  border: 0;
  border-radius: 20px;
  background: #fbf9fd;
  box-shadow: inset 0 0 0 2px #f0e8f6;
  text-align: center;
  font: inherit;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
}

.skin.on { box-shadow: inset 0 0 0 2px #1f8a72; }

.skin .face {
  width: 100%;
  height: 108px;
  margin: 0 auto 6px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 58%, #fff 0 36px, transparent 37px),
    linear-gradient(#fff, #f6f0fb);
  display: block;
}

.skin small {
  display: block;
  margin-top: 2px;
  color: #1f8a72;
}


@media (max-width: 720px) {
  .topbar {
    top: calc(12px + var(--sat));
    gap: 4px;
    width: calc(100% - 20px);
  }
  .subbar {
    top: calc(46px + var(--sat));
    gap: 5px;
  }
  .pill {
    min-height: 28px;
    padding: 2px 7px;
    font-size: 12px;
    min-width: 0;
  }
  #levelPill {
    max-width: 32vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .pill.score { padding-inline: 7px; }
  .pill.score span {
    font-size: 8px;
    letter-spacing: 0.04em;
  }
  .pill.score b { font-size: 14px; }
  .hud-actions { gap: 4px; }
  .hud-actions button {
    height: 28px;
    min-width: 28px;
    padding: 0 7px;
    font-size: 12px;
  }
  .sub-label { font-size: 9px; letter-spacing: 0.04em; }
  .pip { width: 7px; height: 7px; }
  .card {
    top: 46%;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: min(320px, calc(100% - 28px));
    padding: 14px 14px 12px;
  }
  .card h2 { font-size: 28px; }
  .ghost { min-height: 42px; font-size: 16px; }
  .hub-side { top: 18%; }
  .sidebtn { width: 96px; min-height: 78px; border-radius: 22px; }
  .hub-play { width: min(220px, calc(100% - 210px)); bottom: calc(230px + var(--sab)); }
  .playbig { min-height: 54px; font-size: 22px; }
  .splash-name { font-size: 34px; }
  .splash-tag { font-size: 12px; }
  .mapbtn { height: 32px; }
}
