:root {
  --cream: #f8edda;
  --paper: #fffaf0;
  --ink: #4d4454;
  --ink-soft: #857a86;
  --coral: #ef907a;
  --coral-deep: #d97863;
  --gold: #f3cd7d;
  --mint: #a8d8c5;
  --mint-deep: #79bea7;
  --sky: #a9cce2;
  --lilac: #c9bde3;
  --shadow: 0 18px 50px rgba(112, 80, 66, .13);
  --shadow-soft: 0 8px 24px rgba(112, 80, 66, .1);
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(16px, env(safe-area-inset-bottom));
  --font: "MiSans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #f4e6d2;
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}

body {
  position: fixed;
  inset: 0;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ------------------------------------------------------------------ */
/* Texture & atmosphere                                                */
/* ------------------------------------------------------------------ */

.paper-grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: .11;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.86' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.24'/%3E%3C/svg%3E");
}

.corner-shade {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 40%, transparent 48%, rgba(132, 94, 72, .13) 100%),
    linear-gradient(180deg, rgba(255, 249, 238, .18), transparent 22%);
}

.danger-shade {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(86% 78% at 50% 48%, transparent 52%, rgba(233, 118, 92, .36) 100%);
  transition: opacity .25s ease;
}

/* ------------------------------------------------------------------ */
/* HUD                                                                 */
/* ------------------------------------------------------------------ */

.wave-progress {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 30;
  width: 100%;
  height: 4px;
  background: rgba(255, 250, 240, .36);
  opacity: 0;
  transition: opacity .4s ease;
}

.wave-progress.is-visible {
  opacity: 1;
}

.wave-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 0 99px 99px 0;
  background: linear-gradient(90deg, var(--mint-deep), var(--gold) 55%, var(--coral));
  box-shadow: 0 0 8px rgba(239, 144, 122, .4);
  transition: width .12s linear;
}

.hud {
  position: absolute;
  z-index: 20;
  top: var(--safe-top);
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  transition: opacity .35s ease, transform .35s ease;
}

.hud.is-hidden {
  opacity: 0;
  transform: translateY(-8px);
}

.wave-card,
.best-card {
  position: relative;
  min-width: 104px;
  padding: 10px 17px 11px;
  border: 1.5px solid rgba(255, 255, 255, .82);
  border-radius: 21px;
  background: rgba(255, 250, 240, .76);
  box-shadow: 0 10px 26px rgba(122, 87, 67, .13), inset 0 1px 0 rgba(255, 255, 255, .8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.best-card {
  min-width: 96px;
  padding: 9px 15px 10px;
  background: rgba(255, 250, 240, .62);
}

.hud-label {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
  line-height: 1;
  white-space: nowrap;
}

.hud-value {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 6px;
  line-height: .92;
}

.hud-value strong {
  font-size: clamp(27px, 7vw, 36px);
  font-weight: 900;
  letter-spacing: -.04em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.hud-value em {
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}

.hud-value.small strong {
  font-size: clamp(20px, 5vw, 27px);
}

.tiny-crown {
  width: 9px;
  height: 8px;
  display: inline-block;
  background: var(--gold);
  clip-path: polygon(0 100%, 6% 18%, 34% 58%, 50% 0, 66% 58%, 94% 18%, 100% 100%);
}

.hud-right {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.hud-tools {
  display: flex;
  flex-direction: row;
  gap: 6px;
  padding-top: 3px;
  pointer-events: auto;
}

.round-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1.5px solid rgba(255, 255, 255, .8);
  border-radius: 50%;
  background: rgba(255, 250, 240, .7);
  box-shadow: 0 7px 18px rgba(122, 87, 67, .12);
  color: var(--ink);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: transform .15s ease, background .2s ease;
}

.round-btn:active {
  transform: scale(.9);
}

.round-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.round-btn svg path:first-child {
  fill: currentColor;
  stroke: none;
}

.sound-off {
  display: none !important;
}

body.is-muted .sound-off {
  display: block !important;
}

body.is-muted .sound-on {
  display: none !important;
}

.pause-bars {
  position: relative;
  width: 12px;
  height: 15px;
}

.pause-bars::before,
.pause-bars::after {
  content: "";
  position: absolute;
  top: 0;
  width: 4px;
  height: 15px;
  border-radius: 4px;
  background: currentColor;
}

.pause-bars::before { left: 0; }
.pause-bars::after { right: 0; }

.hud.is-record .wave-card,
.hud.is-record .best-card {
  animation: recordPulse .9s cubic-bezier(.2, .8, .3, 1);
}

@keyframes recordPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.06); box-shadow: 0 12px 32px rgba(239, 144, 122, .28); }
  100% { transform: scale(1); }
}

/* ------------------------------------------------------------------ */
/* Wave & wind messages                                                */
/* ------------------------------------------------------------------ */

.wave-banner {
  position: absolute;
  z-index: 18;
  top: clamp(112px, 17vh, 166px);
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 138px;
  padding: 11px 25px 13px;
  border: 1.5px solid rgba(255, 255, 255, .86);
  border-radius: 24px;
  background: rgba(255, 250, 240, .84);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -12px) scale(.92);
  transition: opacity .25s ease, transform .35s cubic-bezier(.18, .9, .25, 1.2);
}

.wave-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.banner-kicker {
  color: var(--coral);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .32em;
  line-height: 1;
}

.wave-banner strong {
  font-size: clamp(21px, 5.8vw, 28px);
  font-weight: 900;
  letter-spacing: .03em;
  line-height: 1.2;
}

.wave-banner #bannerSub {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}

.wind-alert {
  position: absolute;
  z-index: 19;
  top: clamp(108px, 16.5vh, 160px);
  left: 50%;
  display: grid;
  grid-template-columns: minmax(78px, max-content) 30px;
  grid-template-rows: auto auto;
  align-items: center;
  justify-content: space-between;
  column-gap: 10px;
  row-gap: 1px;
  min-width: 160px;
  max-width: calc(100% - 40px);
  padding: 9px 14px;
  border: 1.5px solid rgba(255, 255, 255, .86);
  border-radius: 22px;
  background: rgba(255, 250, 240, .88);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -9px) scale(.94);
  transition: opacity .2s ease, transform .3s cubic-bezier(.18, .9, .25, 1.18);
}

.wind-alert.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

.wind-alert::after {
  content: "";
  position: absolute;
  left: 15px;
  right: 15px;
  bottom: 4px;
  height: 2px;
  border-radius: 99px;
  background: var(--coral);
  opacity: .55;
  transform: scaleX(var(--p, 0));
  transform-origin: left center;
  transition: transform .1s linear;
}

.wind-alert.is-gust {
  background: rgba(255, 246, 232, .95);
  box-shadow: 0 10px 30px rgba(226, 132, 100, .18);
}

.wind-alert.is-flip {
  animation: alertFlip .45s cubic-bezier(.2, .8, .3, 1);
}

@keyframes alertFlip {
  0% { transform: translate(-50%, 0) scale(1); }
  35% { transform: translate(-50%, -3px) scale(1.08) rotate(-1.5deg); }
  70% { transform: translate(-50%, 0) scale(.98) rotate(.8deg); }
  100% { transform: translate(-50%, 0) scale(1); }
}

.wind-copy {
  display: contents;
}

.wind-copy strong {
  grid-column: 1;
  grid-row: 1;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1.1;
}

.wind-copy span {
  grid-column: 1;
  grid-row: 2;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.wind-lines {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 30px;
  overflow: hidden;
  opacity: .65;
}

.wind-lines i {
  display: block;
  height: 2px;
  border-radius: 99px;
  background: var(--coral);
  animation: windLine 1s linear infinite;
}

.wind-lines i:nth-child(1) { width: 16px; animation-delay: -.2s; }
.wind-lines i:nth-child(2) { width: 26px; animation-delay: -.5s; }
.wind-lines i:nth-child(3) { width: 11px; animation-delay: -.8s; }

.wind-alert.dir-left .wind-lines i {
  animation-direction: reverse;
  margin-left: auto;
}

.wind-alert.is-gust .wind-lines i {
  animation-duration: .55s;
  opacity: .9;
}

@keyframes windLine {
  0% { transform: translateX(-18px); opacity: 0; }
  30% { opacity: .9; }
  100% { transform: translateX(24px); opacity: 0; }
}

.toast {
  position: absolute;
  z-index: 21;
  left: 50%;
  top: clamp(178px, 25vh, 238px);
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(77, 68, 84, .87);
  box-shadow: 0 9px 26px rgba(80, 55, 48, .2);
  color: #fffaf0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .05em;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 6px) scale(.94);
  transition: opacity .22s ease, transform .3s cubic-bezier(.18, .9, .25, 1.2);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

/* ------------------------------------------------------------------ */
/* Swipe hint                                                          */
/* ------------------------------------------------------------------ */

.swipe-hint {
  position: absolute;
  z-index: 15;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 21px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: max-content;
  max-width: calc(100% - 34px);
  padding: 9px 15px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 99px;
  background: rgba(255, 250, 240, .62);
  box-shadow: 0 6px 18px rgba(122, 87, 67, .08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-soft);
  opacity: 1;
  pointer-events: none;
  transform: translateX(-50%);
  transition: opacity .3s ease, transform .3s ease;
}

.swipe-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.hint-text {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  white-space: nowrap;
}

.hint-arrow {
  color: var(--coral);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  animation: nudge 1.3s ease-in-out infinite;
}

.hint-arrow:last-child {
  animation-direction: reverse;
}

.hint-track {
  position: relative;
  width: 35px;
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(77, 68, 84, .11);
}

.hint-track i {
  position: absolute;
  top: 0;
  left: 0;
  width: 12px;
  height: 3px;
  border-radius: 99px;
  background: var(--coral);
  animation: hintSlide 1.3s ease-in-out infinite;
}

.hint-track:last-of-type i {
  animation-direction: reverse;
}

@keyframes hintSlide {
  0%, 100% { transform: translateX(-5px); opacity: .2; }
  50% { transform: translateX(28px); opacity: .9; }
}

/* ------------------------------------------------------------------ */
/* First-wave tutorial                                                 */
/* ------------------------------------------------------------------ */

.tutorial {
  position: absolute;
  z-index: 17;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 78px);
  width: min(calc(100% - 32px), 360px);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity .26s ease, transform .34s cubic-bezier(.18, .9, .25, 1.18);
}

.tutorial.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tutorial-card {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 9px 11px;
  padding: 12px 14px 11px;
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 20px;
  background: rgba(255, 250, 240, .91);
  box-shadow: 0 12px 30px rgba(112, 80, 66, .14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.tutorial-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f7a68e, var(--coral));
  box-shadow: 0 5px 12px rgba(217, 120, 99, .27);
  color: #fff8ef;
  font-size: 21px;
  font-weight: 900;
  line-height: 1;
}

.tutorial-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.tutorial-copy strong {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: 1.25;
}

.tutorial-copy span {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .035em;
  line-height: 1.3;
}

.tutorial-gesture {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 3px;
  color: var(--coral-deep);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.tutorial-track {
  position: relative;
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(77, 68, 84, .09);
}

.tutorial-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 4px rgba(239, 144, 122, .16);
  transform: translate(-50%, -50%);
}

.tutorial.is-both .tutorial-dot {
  animation: tutorialBoth 1.5s ease-in-out infinite;
}

.tutorial.is-left .tutorial-dot {
  animation: tutorialLeft 1.18s ease-in-out infinite;
}

.tutorial.is-right .tutorial-dot {
  animation: tutorialRight 1.18s ease-in-out infinite;
}

@keyframes tutorialBoth {
  0%, 100% { left: 18%; opacity: .45; }
  50% { left: 82%; opacity: 1; }
}

@keyframes tutorialLeft {
  0%, 100% { left: 82%; opacity: .4; }
  50% { left: 18%; opacity: 1; }
}

@keyframes tutorialRight {
  0%, 100% { left: 18%; opacity: .4; }
  50% { left: 82%; opacity: 1; }
}

@keyframes nudge {
  0%, 100% { transform: translateX(0); opacity: .55; }
  50% { transform: translateX(-3px); opacity: 1; }
}

/* ------------------------------------------------------------------ */
/* Overlays                                                            */
/* ------------------------------------------------------------------ */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding:
    calc(var(--safe-top) + 10px)
    max(18px, env(safe-area-inset-left))
    calc(var(--safe-bottom) + 10px)
    max(18px, env(safe-area-inset-right));
  opacity: 1;
  visibility: visible;
  transition: opacity .35s ease, visibility .35s ease;
}

.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay::-webkit-scrollbar {
  display: none;
}

.panel {
  margin-top: auto;
  margin-bottom: auto;
}

/* ---------------- Menu ---------------- */

.menu {
  z-index: 40;
  justify-content: space-between;
  padding-top: calc(var(--safe-top) + 22px);
  padding-bottom: calc(var(--safe-bottom) + 5px);
  background: linear-gradient(180deg, rgba(255, 249, 238, .18) 0%, transparent 28%, transparent 47%, rgba(247, 233, 211, .62) 70%, rgba(247, 233, 211, .95) 100%);
}

.menu-head {
  position: relative;
  text-align: center;
  animation: riseIn .7s cubic-bezier(.16, .84, .3, 1) both;
}

.menu-kicker {
  margin: 0 0 8px;
  color: var(--coral-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .42em;
  text-indent: .42em;
  opacity: .82;
}

.game-title {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .04em;
  margin: 0;
  color: var(--ink);
  font-size: clamp(62px, 18vw, 104px);
  font-weight: 900;
  letter-spacing: -.08em;
  line-height: .98;
  text-indent: -.06em;
  text-shadow: 0 2px 0 rgba(255, 255, 255, .72), 0 10px 26px rgba(105, 76, 64, .14);
}

.title-accent {
  position: relative;
  display: inline-block;
  color: var(--coral);
  transform: rotate(4deg);
}

.title-accent::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 0;
  bottom: 4%;
  height: 11%;
  border-radius: 99px;
  background: var(--gold);
  opacity: .55;
  transform: rotate(-3deg);
  z-index: -1;
}

.menu-tagline {
  margin: 11px 0 0;
  color: var(--ink-soft);
  font-size: clamp(12px, 3.6vw, 14px);
  font-weight: 600;
  letter-spacing: .12em;
}

.menu-card {
  position: relative;
  width: min(100%, 430px);
  padding: 16px 19px 13px;
  border: 1.5px solid rgba(255, 255, 255, .8);
  border-radius: 30px;
  background: rgba(255, 251, 243, .75);
  box-shadow: 0 22px 60px rgba(121, 86, 67, .16), inset 0 1px 0 rgba(255, 255, 255, .9);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  animation: riseIn .75s .08s cubic-bezier(.16, .84, .3, 1) both;
}

.menu-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 5px 11px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
}

.menu-record strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.start-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 15px 24px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, #f7a68e 0%, var(--coral) 55%, #ea8771 100%);
  box-shadow: 0 7px 0 var(--coral-deep), 0 14px 26px rgba(214, 112, 90, .25), inset 0 1px 0 rgba(255, 255, 255, .5);
  color: #fffaf1;
  font-family: inherit;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: .1em;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, filter .2s ease;
}

.start-btn:hover {
  filter: saturate(1.04) brightness(1.02);
}

.start-btn:active {
  transform: translateY(5px);
  box-shadow: 0 2px 0 var(--coral-deep), 0 8px 18px rgba(214, 112, 90, .22), inset 0 1px 0 rgba(255, 255, 255, .5);
}

.start-btn.small {
  min-height: 52px;
  font-size: 15px;
}

.play-dot {
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-left: 11px solid rgba(255, 250, 241, .95);
  filter: drop-shadow(0 1px 0 rgba(163, 77, 62, .2));
}

.howto {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  padding: 15px 3px 11px;
}

.howto-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.howto-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 33px;
  height: 33px;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.swipe-icon {
  background: rgba(168, 216, 197, .42);
  color: #3f8f79;
}

.wind-icon {
  background: rgba(239, 144, 122, .22);
  color: var(--coral-deep);
}

.howto-item p {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  white-space: nowrap;
}

.howto-item small {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0;
}

.howto-sep {
  width: 1px;
  height: 25px;
  background: rgba(77, 68, 84, .1);
}

.menu-foot {
  margin: 0;
  padding-top: 2px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .16em;
  text-align: center;
  opacity: .8;
}

.menu-sound {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, .68);
  border-radius: 99px;
  background: rgba(255, 250, 240, .5);
  box-shadow: 0 5px 14px rgba(122, 87, 67, .06);
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
  opacity: .78;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2;
}

.menu-sound svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.menu-sound svg path:first-child {
  fill: currentColor;
  stroke: none;
}

/* ---------------- Panels ---------------- */

.panel {
  position: relative;
  width: min(100%, 440px);
  padding: 29px 25px 24px;
  border: 1.5px solid rgba(255, 255, 255, .87);
  border-radius: 32px;
  background: rgba(255, 251, 243, .92);
  box-shadow: 0 28px 80px rgba(107, 72, 58, .2), inset 0 1px 0 rgba(255, 255, 255, .9);
  text-align: center;
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  animation: panelIn .4s cubic-bezier(.15, .9, .28, 1.08) both;
}

.panel.compact {
  max-width: 380px;
  padding-top: 28px;
}

.panel-kicker {
  margin: 0 0 7px;
  color: var(--coral-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .38em;
  text-indent: .38em;
  opacity: .8;
}

.panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 7.7vw, 34px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.1;
}

.panel-copy {
  margin: 9px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
}

.panel-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  margin-top: 22px;
}

.text-btn {
  padding: 5px 10px;
  border: 0;
  border-radius: 99px;
  background: transparent;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  transition: color .2s ease, background .2s ease;
}

.text-btn:hover {
  background: rgba(77, 68, 84, .05);
  color: var(--ink);
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid rgba(77, 68, 84, .08);
}

/* ---------------- Game over ---------------- */

.over {
  background: rgba(242, 226, 203, .46);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.result-card {
  overflow: hidden;
  padding-top: 33px;
}

.result-doodle {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.result-doodle i {
  position: absolute;
  display: block;
  opacity: .5;
}

.doodle-circle {
  top: -18px;
  left: -16px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--mint);
  opacity: .35 !important;
}

.doodle-triangle {
  top: 30px;
  right: 18px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-bottom: 23px solid var(--gold);
  transform: rotate(17deg);
}

.doodle-square {
  bottom: 34px;
  right: -13px;
  width: 39px;
  height: 39px;
  border-radius: 11px;
  background: var(--lilac);
  transform: rotate(24deg);
  opacity: .3 !important;
}

.result-wave {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin: 20px 0 12px;
}

.result-wave > span:first-child {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.result-wave strong {
  position: relative;
  color: var(--coral);
  font-size: clamp(36px, 10vw, 47px);
  font-weight: 900;
  letter-spacing: -.04em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.new-record {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--gold);
  color: #7e5d29;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  animation: recordWiggle .8s ease-in-out infinite alternate;
}

.new-record.is-hidden {
  display: none;
}

@keyframes recordWiggle {
  from { transform: rotate(-2deg) scale(1); }
  to { transform: rotate(2deg) scale(1.04); }
}

.result-best {
  padding: 8px 13px;
  border-radius: 12px;
  background: rgba(168, 216, 197, .2);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .05em;
}

.result-best strong {
  color: var(--ink);
  font-weight: 900;
}

.result-card .start-btn {
  min-height: 54px;
  font-size: 16px;
}

.key-tip {
  margin: 15px 0 0;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .06em;
  opacity: .65;
}

/* ---------------- Animations ---------------- */

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes panelIn {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */

@media (max-width: 430px) {
  .hud {
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  .wave-card {
    min-width: 96px;
    padding: 9px 14px 10px;
  }

  .best-card {
    min-width: 83px;
    padding: 8px 12px 9px;
  }

  .hud-tools {
    gap: 6px;
  }

  .round-btn {
    width: 38px;
    height: 38px;
  }

  .menu-card {
    padding: 14px 15px 11px;
  }

  .howto {
    gap: 10px;
  }

  .howto-icon {
    width: 29px;
    height: 29px;
    border-radius: 10px;
    font-size: 15px;
  }

  .howto-item {
    gap: 7px;
  }

  .howto-item p {
    font-size: 10px;
  }

  .howto-item small {
    font-size: 8.5px;
  }

  .howto-sep {
    height: 22px;
  }

  .panel {
    padding: 25px 19px 21px;
    border-radius: 28px;
  }

  .toast {
    top: clamp(170px, 24vh, 218px);
  }
}

@media (max-height: 680px) {
  .menu {
    padding-top: calc(var(--safe-top) + 8px);
  }

  .game-title {
    font-size: clamp(50px, 14vw, 72px);
  }

  .menu-head .menu-tagline {
    margin-top: 7px;
  }

  .menu-card {
    padding-top: 12px;
    padding-bottom: 10px;
  }

  .howto {
    padding-top: 11px;
    padding-bottom: 8px;
  }

  .start-btn {
    min-height: 52px;
  }

  .wave-banner,
  .wind-alert {
    top: 88px;
  }

  .toast {
    top: 156px;
  }

  .swipe-hint {
    bottom: calc(var(--safe-bottom) + 11px);
  }

  .tutorial {
    bottom: calc(var(--safe-bottom) + 56px);
  }

  .tutorial-card {
    padding: 9px 12px;
    gap: 7px 9px;
    border-radius: 17px;
  }

  .tutorial-icon {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }
}

@media (max-height: 640px) {
  .howto {
    display: none;
  }

  .menu-card {
    padding-bottom: 11px;
  }
}

@media (max-height: 560px) {
  .menu {
    justify-content: center;
    gap: 18px;
  }

  .menu-head {
    display: none;
  }

  .menu-card {
    align-self: center;
  }

  .tutorial {
    bottom: calc(var(--safe-bottom) + 42px);
    width: min(calc(100% - 24px), 320px);
  }

  .tutorial-card {
    padding: 8px 11px;
  }

  .tutorial-gesture {
    display: none;
  }

  .game-title {
    font-size: 46px;
  }

  .howto {
    display: none;
  }

  .wave-banner {
    top: 72px;
    padding: 7px 17px 8px;
    border-radius: 17px;
  }

  .wave-banner .banner-kicker {
    display: none;
  }

  .wave-banner strong {
    font-size: 18px;
  }

  .wave-banner #bannerSub {
    font-size: 9px;
  }

  .wind-alert {
    top: 72px;
  }

  .toast {
    top: 136px;
  }

  .result-card {
    padding-top: 16px;
    padding-bottom: 14px;
  }

  .result-card .panel-kicker {
    display: none;
  }

  .result-card h2 {
    font-size: 24px;
  }

  .result-card .panel-copy {
    margin-top: 4px;
    font-size: 10px;
  }

  .result-wave {
    margin: 7px 0 6px;
  }

  .result-wave strong {
    font-size: 31px;
  }

  .result-wave .new-record {
    margin-top: 3px;
    padding: 2px 9px;
    font-size: 9px;
  }

  .result-best {
    padding: 5px 10px;
    font-size: 10px;
  }

  .result-card .panel-actions {
    margin-top: 11px;
    gap: 5px;
  }

  .result-card .start-btn {
    min-height: 46px;
  }

  .result-card .key-tip {
    display: none;
  }

  .result-doodle {
    display: none;
  }
}

@media (max-width: 360px) {
  .wave-card {
    min-width: 84px;
    padding: 8px 12px 9px;
  }

  .best-card {
    min-width: 70px;
    padding: 8px 10px 9px;
  }

  .hud-value strong {
    font-size: 26px;
  }

  .hud-value.small strong {
    font-size: 18px;
  }

  .hud-label {
    font-size: 9px;
    letter-spacing: .06em;
  }

  .hud-right {
    gap: 6px;
  }

  .round-btn {
    width: 34px;
    height: 34px;
  }

  .wind-alert {
    min-width: 178px;
    padding-right: 9px;
  }

  .wind-lines {
    width: 22px;
  }

  .wind-copy strong {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint-arrow,
  .hint-track i,
  .tutorial-dot,
  .wind-lines i,
  .new-record {
    animation: none !important;
  }

  .menu-head,
  .menu-card,
  .panel {
    animation-duration: .01ms !important;
  }
}

/* Keyboard focus */
button:focus-visible {
  outline: 2.5px solid #4d4454;
  outline-offset: 3px;
}

