:root {
  --theme: #FF8A3D;
  --theme-deep: #1AE2A4;
  --ink: #183A31;
  --muted: #508A77;
  --card: #FFF8F1;
  --paper: #FFFFFF;
  --line: #C0F0E3;
  --tint: #FFF3E8;
  --glow: rgba(255, 138, 61, 0.28);
  --gold: #12C4BC;
  --handle: #BEEBDE;
  --page: #5AE8CE;
  --app: #FFE3B8;
  --radius: 24px;
  --pill: 999px;
  --btn: 14px;
  --card-r: 16px;
  --shadow: 0 10px 28px rgba(90, 40, 10, 0.16);
}

* { box-sizing: border-box; }
button, input { font-family: inherit; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--page, #5AE8CE);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#app {
  position: relative;
  max-width: 480px;
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--app, #FFE3B8);
  box-shadow: 0 0 0 1px rgba(120, 60, 10, 0.08);
}
#cv {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: var(--app, #FFE3B8);
}

.hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--pill);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 4px 14px rgba(80, 40, 10, 0.12);
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill .mp-icon { width: 16px; height: 16px; }
.pill b { font-size: 15px; }
#livesPill { color: #4CE88E; }
#livesPill.danger { animation: shake 0.4s linear; }
#goldPill { color: var(--gold); }
.pill.wave {
  flex: 1;
  justify-content: center;
  color: var(--theme);
  font-size: 13px;
  font-weight: 700;
}
.iconbtn {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border: 0;
  border-radius: var(--btn);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(80, 40, 10, 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
}
.iconbtn .mp-icon { width: 20px; height: 20px; }
#btnPause .ic-play { display: none; }
#btnPause.on .ic-pause { display: none; }
#btnPause.on .ic-play { display: inline-block; }
.iconbtn:active, .tcard:active, .go:active, .diff:active { transform: scale(0.97); }
.mus .ic-off { display: none; }
.mus.off .ic-on { display: none; }
.mus.off .ic-off { display: inline-block; }
.mus:not(.off) .ic-on { animation: noteBob 1.15s ease-in-out infinite; }

.toast {
  position: absolute;
  left: 50%;
  top: calc(58px + env(safe-area-inset-top));
  transform: translateX(-50%) translateY(-6px);
  z-index: 7;
  max-width: 80%;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(58, 38, 24, 0.9);
  color: #FFF8F1;
  font-size: 13px;
  font-weight: 650;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.dock {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 4;
  padding: 8px 10px 10px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 3px 0 var(--theme);
}
.dock::before {
  content: "";
  display: block;
  width: 42px;
  height: 4px;
  margin: 0 auto 8px;
  border-radius: 4px;
  background: var(--handle);
}
.hintrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.hintrow .mus {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 12px;
}
.hint {
  flex: 1;
  margin: 0 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.tcards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tcard {
  position: relative;
  overflow: hidden;
  min-height: 84px;
  padding: 10px 4px 7px;
  border-radius: var(--card-r);
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 2px 0 var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.tcard::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  top: 0;
  height: 3px;
  border-radius: 0 0 4px 4px;
  background: #FF8A3D;
}
.tcard[data-type="ice"]::before { background: #E03A6B; }
.tcard[data-type="bloom"]::before { background: #4BE24E; }
.tcard.on {
  border-color: var(--theme);
  background: linear-gradient(#FFF8F2, #FFE7D4);
  box-shadow: 0 0 0 3px var(--glow);
}
.tcard[data-type="ice"].on {
  border-color: #E03A6B;
  background: linear-gradient(#F4FBFF, #D9F1FF);
  box-shadow: 0 0 0 3px rgba(58, 160, 224, 0.22);
}
.tcard[data-type="bloom"].on {
  border-color: #4BE24E;
  background: linear-gradient(#FFF7F9, #FFE0EA);
  box-shadow: 0 0 0 3px rgba(226, 75, 120, 0.2);
}
.tcard.hinting { animation: glow 1.3s ease-in-out infinite; }
.tcard.poor { opacity: 0.55; }
.tname { font-size: 13px; font-weight: 800; line-height: 1.2; }
.trole { font-size: 11px; color: var(--muted); }
.tcost {
  margin-top: 2px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}
.tcost .mp-icon { width: 13px; height: 13px; }
.ticon {
  width: 32px;
  height: 32px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ticon .mp-icon { width: 18px; height: 18px; }
.t-flame { background: #FFE1CC; color: #1AE2A4; }
.t-ice { background: #D9F1FF; color: #D61C53; }
.t-bloom { background: #FFE0EA; color: #4BE24E; }

.go {
  width: 100%;
  margin-top: 10px;
  min-height: 48px;
  border: 0;
  border-radius: var(--btn);
  background: var(--theme);
  color: #fff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 6px 0 var(--theme-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.go .mp-icon { width: 18px; height: 18px; color: #fff; }
.go:active { box-shadow: 0 2px 0 var(--theme-deep); }
.go.busy {
  background: var(--line);
  color: var(--muted);
  box-shadow: none;
}
.go.busy .mp-icon { color: var(--muted); }
.go.busy .go-play { display: none; }
.go.slim { margin-top: 8px; min-height: 42px; font-size: 15px; }
.go.poor { opacity: 0.55; }
.go.ghost {
  background: var(--paper);
  color: var(--theme);
  box-shadow: none;
  border: 1.5px solid var(--line);
}
.go.ghost .mp-icon { color: var(--theme); }
.go.ghost.hot {
  border-color: var(--theme);
  background: var(--tint);
  animation: glow 1.6s ease-in-out infinite;
}
.actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
}
.actions > .go {
  width: auto;
  flex: 1;
}
.actions > .adside {
  flex: 0 0 68px;
  width: 68px;
  flex-direction: column;
  gap: 1px;
  padding: 4px 2px;
  font-size: 12px;
  letter-spacing: 0;
  line-height: 1.1;
}
.adside .mp-icon { width: 18px; height: 18px; }
.textbtn {
  width: 100%;
  margin-top: 4px;
  min-height: 40px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}
.textbtn:active { opacity: 0.6; }
.go.ghost.busy,
.go:disabled {
  opacity: 0.72;
}
.diffs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.diff {
  min-height: 52px;
  border-radius: var(--btn);
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}
.diff b { font-size: 15px; line-height: 1.15; }
.diff small { font-size: 11px; font-weight: 700; color: var(--muted); }
.diff.on {
  border-color: var(--theme);
  background: var(--tint);
  color: var(--theme);
  box-shadow: 0 0 0 3px var(--glow);
}
.diff.on small { color: var(--theme); }
.diff-note {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.up {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(var(--dock-space, 160px) + 8px);
  z-index: 5;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.up-row { display: flex; align-items: center; gap: 10px; }
.up-txt { flex: 1; min-width: 0; }
.up-name { font-size: 16px; font-weight: 800; }
.up-sub { margin-top: 2px; color: var(--muted); font-size: 12px; }

.mask {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(16, 12, 20, 0.04) 0%, rgba(16, 12, 20, 0.34) 48%, rgba(16, 12, 20, 0.52) 100%);
  backdrop-filter: blur(2px);
}
.sheet {
  width: 100%;
  max-height: calc(100dvh - 24px - env(safe-area-inset-bottom));
  overflow: auto;
  padding: 14px 14px 14px;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.hero {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border-radius: 18px;
  background: linear-gradient(120deg, #FFE7C4 0%, #FFD3A8 48%, #B4C4F0 100%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}
.hero .ticon {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  box-shadow: 0 3px 0 rgba(120, 60, 10, 0.08);
}
.hero .ticon .mp-icon { width: 22px; height: 22px; }
.hero-copy { min-width: 0; margin-left: 2px; }
.hero-copy b { display: block; font-size: 15px; }
.hero-copy small { color: #388A74; font-size: 12px; font-weight: 700; }
.sheet-top {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sheet-top .badge { margin-right: auto; }
.sheet-top .mus { width: 40px; height: 40px; flex: 0 0 40px; }
.sheet-top-txt { flex: 1; min-width: 0; }
.sheet-top-txt b { display: block; font-size: 14px; }
.sheet-top-txt small { color: var(--muted); font-size: 12px; font-weight: 700; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--pill);
  background: var(--tint);
  color: var(--theme);
  font-size: 12px;
  font-weight: 800;
}
.badge .mp-icon { width: 14px; height: 14px; }
.sheet h1 {
  margin: 8px 0 0;
  font-size: 28px;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.lead {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.steps div {
  padding: 10px 4px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}
.steps .mp-icon {
  display: block;
  margin: 0 auto 4px;
  width: 20px;
  height: 20px;
  color: var(--theme);
}
.nick {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
}
.nick .mp-icon { width: 18px; height: 18px; color: var(--muted); }
.nick img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}
.nick input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  user-select: text;
}
.best {
  margin: 8px 2px 0;
  color: var(--muted);
  font-size: 12px;
}
.sheet .go { margin-top: 12px; }
.result-ico {
  width: 52px;
  height: 52px;
  border-radius: var(--btn);
  background: var(--tint);
  color: var(--theme);
  display: flex;
  align-items: center;
  justify-content: center;
}
.result-ico .mp-icon { width: 28px; height: 28px; }
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}
.stats div {
  padding: 10px 4px 8px;
  border-radius: 14px;
  background: var(--paper);
  border: 1px solid var(--line);
  text-align: center;
}
.stats b {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}
.stats span { color: var(--muted); font-size: 12px; }

@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 transparent; }
  50% { box-shadow: 0 0 0 5px var(--glow); }
}
@keyframes shake {
  25% { transform: translateX(-2px); }
  75% { transform: translateX(2px); }
}
@keyframes noteBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}
