* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #FF8A3D;
  color: #6A3A22;
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
button:focus { outline: none; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #FF8A3D;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#safeTop { position: absolute; top: 0; left: 0; width: 0; height: env(safe-area-inset-top); }
#safeBot { position: absolute; bottom: 0; left: 0; width: 0; height: env(safe-area-inset-bottom); }
#view { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.is-hidden { display: none !important; }

.hud {
  position: absolute;
  z-index: 3;
  left: 16px;
  right: 16px;
  top: calc(env(safe-area-inset-top) + 10px);
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-pill {
  background: rgba(255, 248, 241, 0.95);
  border-radius: 18px;
  box-shadow: 0 6px 16px rgba(180, 70, 10, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.7);
  min-height: 52px;
  display: flex;
  align-items: center;
}
.score-pill { flex: 1; padding: 6px 14px; justify-content: space-between; gap: 8px; }
.next-pill { padding: 4px 8px 4px 12px; gap: 4px; }
.hud-k { font-size: 11px; color: #A56A45; font-weight: 800; letter-spacing: 0.04em; }
.hud-sub { font-size: 11px; color: #C48A62; font-weight: 700; margin-top: 2px; }
.hud-sub.fresh { color: #E25B12; }
.score-pill strong {
  font-size: 26px;
  color: #E25B12;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.score-pill strong.bump { animation: bump 0.18s ease-out; }
#nextFruit { width: 40px; height: 40px; display: block; }

.round-btn {
  width: 52px;
  height: 52px;
  flex: none;
  border: none;
  border-radius: 50%;
  background: rgba(255, 248, 241, 0.92);
  color: #E07A22;
  box-shadow: 0 6px 16px rgba(180, 70, 10, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
}
.round-btn:active { transform: scale(0.94); }
.round-btn .mp-icon { width: 26px; height: 26px; }

.layer { position: absolute; inset: 0; z-index: 4; }
.abs-left, .abs-right {
  position: absolute;
  top: calc(env(safe-area-inset-top) + 12px);
  z-index: 2;
}
.abs-left { left: 16px; }
.abs-right { right: 16px; }

.start-mid {
  height: 64%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 0;
}
#logoFruit {
  width: 150px;
  height: 72px;
  display: block;
  margin-bottom: -4px;
  animation: bob 2.6s ease-in-out infinite;
}
.logo {
  margin: 0;
  font-size: clamp(40px, 12.5vw, 58px);
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 0.02em;
}
.logo .w {
  color: #FFF8EE;
  text-shadow:
    0 3px 0 #C25512,
    2px 2px 0 #E07A22, -2px 2px 0 #E07A22,
    2px -1px 0 #E07A22, -2px -1px 0 #E07A22,
    0 -2px 0 #E07A22, 3px 0 0 #E07A22, -3px 0 0 #E07A22;
}
.logo .g {
  color: #8BE356;
  text-shadow:
    0 3px 0 #1B5C2A,
    2px 2px 0 #2E8B3A, -2px 2px 0 #2E8B3A,
    2px -1px 0 #2E8B3A, -2px -1px 0 #2E8B3A,
    0 -2px 0 #2E8B3A, 3px 0 0 #2E8B3A, -3px 0 0 #2E8B3A;
}

.best-card {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 248, 241, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 22px;
  padding: 10px 22px 10px 10px;
  box-shadow: 0 8px 20px rgba(190, 80, 10, 0.14);
  color: #6A3A22;
  min-width: 176px;
}
.best-card:active { transform: scale(0.98); }
.trophy-bg {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: #FFF1D6;
  color: #F0A020;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.trophy-bg .mp-icon { width: 28px; height: 28px; }
.best-text { display: flex; flex-direction: column; align-items: flex-start; }
.best-k { font-size: 13px; color: #A56A45; font-weight: 800; }
.best-v {
  font-size: 28px;
  font-weight: 900;
  line-height: 1.05;
  color: #6A3A22;
  font-variant-numeric: tabular-nums;
}

.play-wrap {
  position: relative;
  width: min(78vw, 280px);
  height: 112px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spark {
  position: absolute;
  width: 16px;
  height: 5px;
  border-radius: 4px;
  background: #FFE38A;
  animation: tw 1.6s ease-in-out infinite;
}
.s1 { left: 6px; top: 34px; transform: rotate(-22deg); }
.s2 { left: 22px; bottom: 22px; transform: rotate(18deg); animation-delay: 0.3s; }
.s3 { right: 6px; top: 32px; transform: rotate(20deg); }
.s4 { right: 24px; bottom: 20px; transform: rotate(-16deg); animation-delay: 0.45s; }
.s5 { left: 52px; top: 10px; width: 10px; animation-delay: 0.15s; }
.s6 { right: 54px; top: 8px; width: 10px; animation-delay: 0.5s; }

.play-btn {
  position: relative;
  z-index: 1;
  width: min(62vw, 210px);
  height: 76px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, #FFE56A 0%, #FFB428 46%, #FF8A1E 100%);
  box-shadow: 0 8px 0 #E36A10, 0 16px 24px rgba(200, 80, 10, 0.25), inset 0 2px 0 rgba(255, 255, 255, 0.75);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.play-btn:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #E36A10, 0 8px 16px rgba(200, 80, 10, 0.22), inset 0 2px 0 rgba(255, 255, 255, 0.75);
}
.play-btn .mp-icon { width: 42px; height: 42px; margin-left: 4px; }
.end-btn { width: 100%; height: 56px; font-size: 18px; font-weight: 900; margin-top: 4px; }
.end-btn .mp-icon { width: 22px; height: 22px; margin-left: 0; }

.start-tip {
  margin: 4px 0 0;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 248, 241, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.coach {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: rgba(255, 248, 241, 0.96);
  color: #8A4E2C;
  font-size: 13px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  box-shadow: 0 6px 16px rgba(160, 70, 10, 0.14);
  pointer-events: none;
  white-space: nowrap;
}

.end-layer {
  z-index: 5;
  background: rgba(90, 36, 8, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  overflow: auto;
}
.end-card {
  width: min(100%, 340px);
  background: linear-gradient(180deg, #FFF9F3, #FFF1E4);
  border-radius: 28px;
  padding: 22px 20px 16px;
  box-shadow: 0 16px 40px rgba(90, 30, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.85);
  text-align: center;
  animation: pop 0.28s ease-out;
}
.end-ribbon {
  display: inline-block;
  background: #FF8A3D;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border-radius: 999px;
  padding: 6px 14px;
}
.end-ribbon.gold {
  background: linear-gradient(180deg, #FFE08A, #F5A524);
  color: #7A4A10;
}
#endFruit { width: 150px; height: 120px; margin: 2px auto 0; display: block; }
.end-extra { color: #C46A32; font-size: 14px; font-weight: 800; min-height: 20px; }
.end-k { color: #A56A45; font-size: 13px; font-weight: 800; margin-top: 2px; }
.end-v {
  font-size: clamp(42px, 14vw, 56px);
  font-weight: 900;
  color: #6A3A22;
  line-height: 1;
  margin: 2px 0 4px;
  font-variant-numeric: tabular-nums;
}
.end-sub { color: #C48A62; font-size: 14px; font-weight: 700; margin-bottom: 14px; }
.ghost-btn {
  margin-top: 4px;
  width: 100%;
  height: 48px;
  border: none;
  background: transparent;
  color: #C46A32;
  font-weight: 800;
  font-size: 16px;
  border-radius: 14px;
}
.ghost-btn:active { background: rgba(255, 138, 61, 0.12); }

.sheet {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-mask { position: absolute; inset: 0; background: rgba(80, 32, 8, 0.4); }
.sheet-card {
  position: relative;
  width: min(100%, 480px);
  background: #FFF8F1;
  border-radius: 24px 24px 0 0;
  padding: 16px 18px calc(16px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(120, 40, 0, 0.18);
}
.sheet-card::before {
  content: "";
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 4px;
  background: #F0D7C4;
  margin: 0 auto 12px;
}
.sheet-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: #FFF1E6;
  color: #C46A32;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sheet-x .mp-icon { width: 20px; height: 20px; }
.sheet-h { margin: 0 0 12px; text-align: center; font-size: 18px; font-weight: 900; color: #6A3A22; }
.sheet-score {
  text-align: center;
  font-size: 40px;
  font-weight: 900;
  color: #E36C12;
  line-height: 1;
  margin-bottom: 8px;
}
.set-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  border: 1px solid #F0E2D4;
  border-radius: 16px;
  padding: 14px;
  font-weight: 800;
  font-size: 16px;
  color: #6A3A22;
}
.set-row:active { background: #FFF6EE; }
.sound-side { display: flex; align-items: center; gap: 8px; color: #C46A32; font-size: 14px; }
.switch {
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: #E7D9CC;
  position: relative;
  display: inline-block;
}
.switch.on { background: #FF8A3D; }
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease;
}
.switch.on::after { transform: translateX(20px); }
.sheet-note { color: #A56A45; font-size: 13px; line-height: 1.65; margin: 12px 4px 0; }
.hist-list { max-height: 240px; overflow: auto; }
.hist-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 4px;
  border-bottom: 1px solid #F3E4D6;
  font-weight: 800;
  color: #6A3A22;
}
.hist-i { color: #C48A62; font-size: 13px; }
.hist-s { font-variant-numeric: tabular-nums; font-size: 18px; }
.empty { text-align: center; color: #C48A62; font-size: 14px; font-weight: 700; padding: 18px 8px; }

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}
@keyframes tw { 50% { opacity: 0.35; } }
@keyframes bump { 50% { transform: scale(1.14); } }
@keyframes pop {
  from { transform: translateY(16px) scale(0.96); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@media (max-height: 680px) {
  .start-mid { height: 68%; }
  .logo { font-size: 36px; }
  #logoFruit { width: 110px; height: 54px; }
  .best-card { margin-top: 10px; padding-top: 6px; padding-bottom: 6px; }
  .best-v { font-size: 24px; }
  .play-wrap { height: 92px; margin-top: 0; }
  .play-btn { height: 64px; }
  .start-tip { font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .spark, #logoFruit, .end-card, .score-pill strong.bump { animation: none; }
}
