:root {
  color-scheme: light;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #4d2c2a;
  --paper: #fffaf7;
  --peach: #ff7f91;
  --peach-dark: #e95e77;
  --mint: #69c7a4;
}

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

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #fff7f3;
  color: var(--ink);
  overscroll-behavior: none;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: none;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #dff4f0;
  isolation: isolate;
}

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

.hud {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.hud-group,
.score,
.badge-score,
.hud-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.hearts,
.score,
.badge-score {
  height: 38px;
  padding: 0 13px;
  border: 2px solid rgba(77, 44, 42, 0.16);
  border-radius: 19px;
  background: rgba(255, 250, 247, 0.9);
  box-shadow: 0 4px 0 rgba(77, 44, 42, 0.08);
  backdrop-filter: blur(8px);
  font-size: 17px;
}

.hearts {
  color: var(--peach-dark);
  letter-spacing: 2px;
}

.score b {
  min-width: 18px;
  text-align: right;
  font-size: 18px;
}

.badge-score {
  color: #7b66aa;
}

.badge-score b {
  min-width: 12px;
  color: var(--ink);
  text-align: right;
  font-size: 18px;
}

.badge-score > span:last-child {
  color: #8f716b;
  font-size: 13px;
}

.score > span:last-child {
  color: #8f716b;
  font-size: 13px;
}

.peach-icon {
  color: var(--peach);
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 2px solid rgba(77, 44, 42, 0.16);
  border-radius: 50%;
  background: rgba(255, 250, 247, 0.9);
  box-shadow: 0 4px 0 rgba(77, 44, 42, 0.09);
  font-weight: 800;
  pointer-events: auto;
}

.icon-button:active,
.control-button:active,
.control-button.pressed {
  transform: translateY(2px) scale(0.96);
  box-shadow: 0 2px 0 rgba(77, 44, 42, 0.12);
}

.touch-controls {
  position: absolute;
  z-index: 6;
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.move-controls {
  display: flex;
  gap: 12px;
}

.control-button {
  width: clamp(58px, 15vw, 76px);
  height: clamp(58px, 15vw, 76px);
  border: 2px solid rgba(77, 44, 42, 0.19);
  border-radius: 50%;
  background: rgba(255, 250, 247, 0.82);
  box-shadow: 0 6px 0 rgba(77, 44, 42, 0.12);
  color: var(--ink);
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  user-select: none;
}

.jump-button {
  background: rgba(255, 226, 226, 0.9);
  color: #c84160;
}

.toast {
  position: absolute;
  z-index: 7;
  top: 70px;
  left: 50%;
  min-width: 130px;
  padding: 9px 15px;
  border-radius: 20px;
  background: rgba(77, 44, 42, 0.84);
  color: white;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -8px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  display: none;
}

.overlay.visible {
  display: flex;
}

#start-screen {
  align-items: stretch;
  overflow: hidden;
  background: #fff8f5;
}

.start-visual {
  position: relative;
  width: 58%;
  overflow: hidden;
  background: #fff;
}

.start-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 68%, #fff8f5 100%);
}

.start-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 48% 50%;
}

.start-content {
  width: 42%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 5vw;
}

.eyebrow {
  margin: 0 0 8px;
  color: #aa756c;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 6vw, 78px);
  line-height: 1;
  white-space: nowrap;
}

h2 {
  margin: 0 0 22px;
  font-size: clamp(30px, 5vw, 48px);
}

.subtitle {
  margin: 16px 0 22px;
  color: #7b5a55;
  font-size: clamp(15px, 2vw, 20px);
}

.goal-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  padding: 8px 13px;
  border-radius: 20px;
  background: #ffe4e7;
  color: #b74760;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  width: min(240px, 100%);
  min-height: 48px;
  padding: 0 22px;
  border-radius: 7px;
  font-weight: 800;
}

.primary-button {
  background: var(--ink);
  color: white;
  box-shadow: 0 5px 0 #2e1716;
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #2e1716;
}

.secondary-button {
  margin-top: 12px;
  background: #f1e9e5;
}

.dialog-overlay {
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(77, 44, 42, 0.2);
  backdrop-filter: blur(10px);
}

.dialog {
  width: min(360px, 92vw);
  padding: 34px;
  border: 2px solid rgba(77, 44, 42, 0.1);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 14px 40px rgba(77, 44, 42, 0.2);
  text-align: center;
}

.dialog .primary-button,
.dialog .secondary-button {
  width: 100%;
}

.finish-badge {
  width: 70px;
  height: 70px;
  margin: -68px auto 18px;
  border: 6px solid var(--paper);
  border-radius: 50%;
  background: var(--peach);
  color: white;
  font-size: 38px;
  line-height: 58px;
  box-shadow: 0 6px 14px rgba(233, 94, 119, 0.3);
}

.result-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  align-items: baseline;
  margin: 0 0 14px;
  padding: 13px;
  border-radius: 6px;
  background: #f6efeb;
  color: #8c6b65;
  font-size: 13px;
  text-align: center;
}

.result-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.result-item small {
  color: #8c6b65;
  font-size: 12px;
}

.result-item strong {
  color: var(--ink);
  font-size: 18px;
}

.best-time {
  min-height: 20px;
  margin: 0 0 18px;
  color: #b74760;
  font-size: 13px;
  font-weight: 700;
}

@media (pointer: fine) and (min-width: 900px) {
  .touch-controls {
    opacity: 0.58;
  }
}

@media (orientation: portrait) {
  .hud {
    top: max(10px, env(safe-area-inset-top));
  }

  .hearts,
  .score,
  .badge-score {
    height: 34px;
    padding: 0 8px;
    font-size: 14px;
  }

  .hud-group {
    gap: 5px;
  }

  .hud-actions {
    gap: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  #start-screen {
    flex-direction: column;
  }

  .start-visual {
    width: 100%;
    height: 58%;
  }

  .start-visual::after {
    background: linear-gradient(180deg, transparent 65%, #fff8f5 100%);
  }

  .start-content {
    width: 100%;
    height: 42%;
    align-items: center;
    justify-content: flex-start;
    padding: 0 24px max(18px, env(safe-area-inset-bottom));
    text-align: center;
  }

  h1 {
    font-size: clamp(38px, 13vw, 58px);
  }

  .subtitle {
    margin: 10px 0 13px;
  }

  .goal-pill {
    margin-bottom: 14px;
  }

  .touch-controls {
    bottom: max(14px, env(safe-area-inset-bottom));
  }
}

@media (max-height: 430px) {
  .touch-controls {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  .control-button {
    width: 58px;
    height: 58px;
  }

  .start-content {
    padding: 3vw;
  }

  .subtitle {
    margin: 8px 0 12px;
  }

  .goal-pill {
    margin-bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
