:root {
  --w: 390px;
  --h: 844px;
  --s: 1;
  --green: #07c160;
  --green-d: #06ad56;
  --ink: #1a1a1f;
  --muted: #6b7280;
  --card: rgba(255, 255, 255, 0.94);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #12121a;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  user-select: none;
  touch-action: none;
}

#frame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--w);
  height: var(--h);
  transform: translate(-50%, -50%) scale(var(--s));
  transform-origin: center center;
  overflow: hidden;
  border-radius: 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  background: #0b3d4a;
}

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

#hud {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 18px;
  z-index: 2;
  pointer-events: none;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

.hud-bar {
  margin-top: 8px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}

.hud-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, #ffd36a, #ff7a45);
}

#toast {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 3;
  color: #fff;
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 4px;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

#overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px 22px;
  background: linear-gradient(180deg, rgba(8, 16, 28, 0.28), rgba(8, 16, 28, 0.55));
}

#overlay[hidden] {
  display: none;
}

.card {
  width: 100%;
  max-width: 330px;
  background: var(--card);
  border-radius: 22px;
  padding: 26px 22px 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.kicker {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 99px;
  background: #fff3e6;
  color: #e8590c;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

h1 {
  margin: 10px 0 6px;
  font-size: 34px;
  line-height: 1.15;
  color: var(--ink);
}

.sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 18px;
}

.stat {
  background: #f4f6f8;
  border-radius: 14px;
  padding: 10px 8px;
}

.stat b {
  display: block;
  font-size: 20px;
  color: var(--ink);
}

.stat span {
  font-size: 11px;
  color: var(--muted);
}

.stages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
}

.stage-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 12px 14px;
  background: #f4f6f8;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.stage-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stage-btn em {
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.btn-main {
  background: var(--green);
  color: #fff;
  box-shadow: 0 8px 0 var(--green-d);
}

.btn-main:active {
  transform: translateY(2px);
  box-shadow: 0 6px 0 var(--green-d);
}

.btn-ghost {
  margin-top: 10px;
  background: transparent;
  color: var(--muted);
}

.result {
  font-size: 40px;
  margin: 4px 0 8px;
  color: var(--ink);
}

.hint {
  margin-top: 14px;
  font-size: 12px;
  color: #9aa3ad;
}
