:root {
  --orange: #FF8A3D;
  --orange-deep: #E96719;
  --orange-light: #FFB36B;
  --ink: #3D2A20;
  --ink-soft: #6E584A;
  --muted: #978173;
  --cream: #FFF9EE;
  --cream-deep: #FFF1DA;
  --line: rgba(112, 74, 43, .12);
  --shadow-soft: 0 10px 28px rgba(75, 47, 25, .14);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #79cfe8;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid rgba(255, 255, 255, .9); outline-offset: 3px; }

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

.game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
.game-canvas:active { cursor: grabbing; }

.scene-tint {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    radial-gradient(120% 58% at 50% -12%, rgba(255, 250, 226, .36), transparent 60%),
    radial-gradient(100% 50% at 50% 110%, rgba(104, 68, 43, .18), transparent 66%),
    linear-gradient(180deg, rgba(23, 85, 120, .10) 0%, transparent 24%, transparent 78%, rgba(62, 40, 26, .10) 100%);
}

.scene-grain {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: soft-light;
  background-image: radial-gradient(rgba(255, 255, 255, .7) .7px, transparent .8px);
  background-size: 4px 4px;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  z-index: 8;
  top: calc(var(--safe-top) + 12px);
  left: 16px;
  right: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity .34s ease, transform .34s ease;
  pointer-events: none;
}
.hud.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

.hud-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }

.alt-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 7px 18px 7px 8px;
  border-radius: 21px;
  border: 1px solid rgba(255, 255, 255, .88);
  background: linear-gradient(180deg, rgba(255, 252, 243, .94), rgba(255, 244, 226, .88));
  box-shadow: 0 9px 26px rgba(67, 43, 23, .16), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.alt-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(150deg, #FFB76F 0%, #FF8A3D 52%, #F17321 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 4px 10px rgba(233, 103, 25, .28);
}
.alt-icon .mp-icon { width: 24px; height: 24px; filter: drop-shadow(0 1px 1px rgba(137, 65, 15, .2)); }

.alt-copy { display: flex; flex-direction: column; line-height: 1; }
.alt-label { font-size: 10px; font-weight: 700; letter-spacing: .16em; color: var(--muted); margin: 0 0 4px 1px; }
.alt-number { display: flex; align-items: baseline; gap: 3px; font-variant-numeric: tabular-nums; }
.alt-number b { font-size: 27px; font-weight: 900; letter-spacing: -.03em; color: var(--ink); line-height: .9; }
.alt-number em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--orange-deep); }

.best-mini {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 11px;
  margin-left: 2px;
  border-radius: 999px;
  background: rgba(255, 250, 239, .7);
  border: 1px solid rgba(255, 255, 255, .8);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(67, 43, 23, .10);
}
.best-mini .mp-icon { width: 14px; height: 14px; color: var(--orange-deep); }
.best-mini b { font-weight: 900; color: var(--ink); font-variant-numeric: tabular-nums; }

.hud-actions { display: flex; gap: 8px; }
.round-btn {
  width: 47px;
  height: 47px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 17px;
  border: 1px solid rgba(255, 255, 255, .88);
  background: linear-gradient(180deg, rgba(255, 252, 243, .95), rgba(255, 241, 220, .9));
  color: #8A5D3D;
  box-shadow: 0 8px 20px rgba(67, 43, 23, .15), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: transform .12s ease, box-shadow .12s ease;
}
.round-btn .mp-icon { width: 21px; height: 21px; }
.round-btn:active { transform: translateY(2px) scale(.96); box-shadow: 0 3px 8px rgba(67, 43, 23, .14); }

/* ---------- control hint ---------- */
.hint {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 15px 8px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .85);
  background: rgba(255, 249, 238, .9);
  box-shadow: 0 10px 26px rgba(48, 33, 21, .18), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: opacity .35s ease, transform .35s ease;
  pointer-events: none;
  white-space: nowrap;
}
.hint.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.hint.is-fading { opacity: 0; transform: translateX(-50%) translateY(8px); }
.hint-gesture {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  border-radius: 13px;
  color: var(--orange-deep);
  background: linear-gradient(180deg, #FFE9CE, #FFD9AF);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
.hint-gesture .mp-icon { width: 20px; height: 20px; }
.hint-copy { display: flex; flex-direction: column; line-height: 1.15; }
.hint-copy b { font-size: 12px; font-weight: 800; color: var(--ink); }
.hint-copy span { font-size: 10px; font-weight: 600; color: var(--muted); margin-top: 1px; }

/* ---------- screen shells ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.screen--start {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  transition: opacity .42s ease, visibility 0s linear;
  background:
    radial-gradient(90% 42% at 50% 10%, rgba(255, 249, 226, .18), transparent 70%),
    linear-gradient(180deg, rgba(13, 62, 91, .04) 0%, transparent 38%, rgba(232, 155, 94, .08) 100%);
}
.screen--start.is-hidden { opacity: 0; visibility: hidden; transition: opacity .38s ease, visibility 0s linear .38s; }

.start-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: calc(var(--safe-top) + 6.2vh) 24px 0;
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .08em;
  background: rgba(255, 250, 240, .18);
  border: 1px solid rgba(255, 255, 255, .46);
  box-shadow: 0 5px 18px rgba(36, 77, 100, .14), inset 0 1px 0 rgba(255, 255, 255, .32);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  text-shadow: 0 1px 2px rgba(50, 59, 47, .14);
}
.brand-chip .mp-icon { width: 16px; height: 16px; opacity: .95; }

.game-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0 0;
  font-size: clamp(52px, 15.6vw, 76px);
  font-weight: 900;
  line-height: .9;
  letter-spacing: .035em;
  color: #FFF9E9;
  text-shadow:
    0 2px 0 #F7A15A,
    0 5px 0 #D9661E,
    0 9px 0 rgba(171, 78, 22, .34),
    0 17px 34px rgba(71, 48, 34, .28);
  transform: rotate(-1.5deg);
}
.title-cloud { position: relative; z-index: 2; }
.title-jump {
  position: relative;
  z-index: 1;
  margin-top: 2px;
  color: #FFD08A;
  font-size: .96em;
  text-shadow:
    0 2px 0 #F08A36,
    0 5px 0 #CC5B16,
    0 9px 0 rgba(145, 63, 13, .35),
    0 18px 36px rgba(71, 48, 34, .3);
}

.game-sub {
  margin: 26px 0 0;
  padding: 7px 15px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .04em;
  color: rgba(255, 255, 255, .96);
  background: rgba(23, 82, 111, .18);
  text-shadow: 0 1px 3px rgba(25, 60, 80, .25);
  border: 1px solid rgba(255, 255, 255, .18);
}

.start-sheet {
  position: relative;
  width: 100%;
  padding: 14px 18px calc(var(--safe-bottom) + 16px);
  border-radius: 34px 34px 0 0;
  background:
    radial-gradient(120% 90% at 12% 0%, rgba(255, 255, 255, .72), transparent 46%),
    linear-gradient(180deg, #FFFBF2 0%, #FFF3DD 100%);
  border: 1px solid rgba(255, 255, 255, .92);
  border-bottom: 0;
  box-shadow: 0 -16px 46px rgba(77, 48, 27, .18), inset 0 1px 0 #fff;
  pointer-events: auto;
}

.sheet-grip {
  display: block;
  width: 42px;
  height: 4px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: rgba(226, 126, 55, .2);
}

.how-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.how-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .66);
  border: 1px solid rgba(166, 114, 71, .10);
  box-shadow: inset 0 1px 0 #fff;
}
.how-icon {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  color: var(--orange-deep);
  background: linear-gradient(180deg, #FFEBD3, #FFDDB8);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8);
}
.how-icon .mp-icon { width: 20px; height: 20px; }
.how-copy { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.how-copy b { font-size: 12px; font-weight: 800; color: var(--ink); white-space: nowrap; }
.how-copy span { margin-top: 3px; font-size: 9.5px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.start-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 13px;
}
.best-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 3px;
  height: 58px;
  padding: 0 13px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .72);
  border: 1px solid rgba(166, 114, 71, .12);
  box-shadow: inset 0 1px 0 #fff;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}
.best-chip .mp-icon { align-self: center; width: 17px; height: 17px; margin-right: 2px; color: var(--orange-deep); }
.best-chip b { font-size: 20px; font-weight: 900; color: var(--ink); letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

.primary-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 58px;
  padding: 0 17px 0 22px;
  border: 0;
  border-radius: 20px;
  color: #fff;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #FFB266 0%, #FF8A3D 46%, #F5761D 100%);
  box-shadow:
    0 5px 0 #CF5B13,
    0 15px 28px rgba(234, 108, 28, .34),
    inset 0 1px 0 rgba(255, 255, 255, .55);
  text-shadow: 0 1px 1px rgba(159, 67, 13, .25);
  transition: transform .09s ease, box-shadow .09s ease;
  touch-action: manipulation;
}
.primary-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #CF5B13, 0 6px 14px rgba(234, 108, 28, .25), inset 0 1px 0 rgba(255, 255, 255, .45);
}
.start-btn { flex: 1 1 auto; min-width: 0; }
.btn-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .24);
}
.btn-icon .mp-icon { width: 19px; height: 19px; }
.start-tip {
  margin: 11px 0 0;
  text-align: center;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .06em;
  color: #A68D7A;
}

/* ---------- dialogs ---------- */
.screen--dialog {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(23, 57, 78, .32);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .28s ease, visibility 0s linear .28s;
}
.screen--dialog.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity .28s ease, visibility 0s linear;
}

.panel {
  position: relative;
  width: min(100%, 356px);
  padding: 24px 22px 20px;
  border-radius: 30px;
  background:
    radial-gradient(120% 70% at 8% 0%, rgba(255, 255, 255, .8), transparent 48%),
    linear-gradient(180deg, #FFFBF3 0%, #FFF1DA 100%);
  border: 1px solid rgba(255, 255, 255, .92);
  box-shadow: 0 28px 68px rgba(37, 28, 20, .34), inset 0 1px 0 #fff;
  transform: translateY(14px) scale(.97);
  transition: transform .3s cubic-bezier(.2, .8, .3, 1.08);
  text-align: center;
}
.screen--dialog.is-open .panel { transform: translateY(0) scale(1); }

.panel-kicker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  color: var(--orange-deep);
}
.panel-kicker .mp-icon { width: 15px; height: 15px; }
.panel-title {
  margin: 9px 0 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -.02em;
  color: var(--ink);
}
.panel-sub {
  margin: 8px 0 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1.5;
}

.panel-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .66);
  border: 1px solid rgba(166, 114, 71, .1);
  box-shadow: inset 0 1px 0 #fff;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.panel-score strong { display: flex; align-items: baseline; gap: 3px; color: var(--ink); }
.panel-score b { font-size: 30px; font-weight: 900; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.panel-score em { font-style: normal; font-size: 12px; font-weight: 800; color: var(--orange-deep); }

.ghost-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  padding: 0 16px;
  border: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, .48);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  transition: transform .1s ease, background .1s ease;
}
.ghost-btn .mp-icon { width: 17px; height: 17px; }
.ghost-btn:active { transform: scale(.98); background: rgba(255, 255, 255, .75); }

.panel--over { padding-top: 30px; overflow: hidden; }
.record-badge {
  position: absolute;
  top: 0;
  left: 50%;
  display: none;
  align-items: center;
  gap: 4px;
  height: 27px;
  padding: 0 13px;
  border-radius: 0 0 13px 13px;
  transform: translateX(-50%);
  color: #fff;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  background: linear-gradient(180deg, #FFB05F, #F57A22);
  box-shadow: 0 5px 12px rgba(238, 108, 28, .28);
  white-space: nowrap;
}
.record-badge .mp-icon { width: 14px; height: 14px; }
.panel--over.is-record .record-badge { display: inline-flex; }

.over-scores {
  display: grid;
  grid-template-columns: 1.18fr 1fr;
  gap: 9px;
  margin: 18px 0;
}
.over-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 13px 8px 11px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .58);
  border: 1px solid rgba(166, 114, 71, .1);
  box-shadow: inset 0 1px 0 #fff;
}
.over-score--main {
  background: linear-gradient(180deg, #FFF0DA, #FFE3BE);
  border-color: rgba(238, 125, 48, .16);
}
.over-score span { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.over-score strong { display: flex; align-items: baseline; gap: 2px; color: var(--ink); }
.over-score b { font-size: 31px; font-weight: 900; line-height: 1; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.over-score em { font-style: normal; font-size: 11px; font-weight: 800; color: var(--orange-deep); }

/* ---------- responsive ---------- */
@media (max-height: 720px) {
  .start-hero { padding-top: calc(var(--safe-top) + 3.6vh); }
  .game-title { margin-top: 13px; font-size: clamp(43px, 13.6vw, 60px); }
  .game-sub { margin-top: 17px; font-size: 11.5px; }
  .start-sheet { padding-top: 11px; }
  .sheet-grip { margin-bottom: 9px; }
  .how-item { padding: 8px; }
  .how-icon { width: 32px; height: 32px; border-radius: 11px; }
  .start-actions { margin-top: 10px; }
  .best-chip, .primary-btn { min-height: 52px; height: 52px; }
  .start-tip { margin-top: 8px; }
  .panel { padding: 20px 20px 17px; }
  .panel-title { font-size: 25px; }
  .panel-score { margin: 14px 0; padding: 11px 14px; }
  .over-scores { margin: 14px 0; }
}

@media (min-width: 720px) {
  .hud {
    left: 50%;
    right: auto;
    width: min(520px, calc(100vw - 32px));
    transform: translateX(-50%) translateY(-10px);
  }
  .hud.is-visible { transform: translateX(-50%) translateY(0); }
  .start-hero { padding-top: calc(var(--safe-top) + 7vh); }
  .start-sheet {
    width: min(520px, calc(100vw - 48px));
    margin: 0 auto 28px;
    border-radius: 32px;
    border-bottom: 1px solid rgba(255, 255, 255, .92);
  }
  .hint { bottom: 26px; }
  .screen--dialog { padding-bottom: 7vh; }
}

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