:root {
  color-scheme: light;
  --cream: #fff7eb;
  --paper: rgba(255, 250, 242, 0.76);
  --paper-strong: rgba(255, 250, 242, 0.92);
  --brown: #5f3c2d;
  --muted: #9b7767;
  --pink: #f7b8bc;
  --pink-strong: #ec7886;
  --mint: #9ed5c3;
  --gold: #e5ae48;
  --red: #dd5656;
  --shadow: 0 18px 48px rgba(72, 42, 26, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #1f1714;
  color: var(--brown);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button {
  border: 0;
  font: inherit;
  cursor: pointer;
  color: inherit;
}

.app {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.home-screen,
.game-screen {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  touch-action: none;
}

.home-bg {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(72, 44, 33, 0.18), rgba(32, 20, 16, 0.54)),
    url("assets/boy-pov.png") center / cover no-repeat;
  filter: blur(1px);
  transform: scale(1.02);
}

.home-content {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: 100vh;
  width: min(900px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
}

.kicker {
  margin: 0 0 12px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.68);
  color: var(--muted);
  letter-spacing: 0;
}

.visit-stats {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 16px;
  border: 1px solid rgba(255, 255, 255, 0.52);
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.72);
  box-shadow: 0 10px 28px rgba(62, 38, 28, 0.16);
  backdrop-filter: blur(12px);
  color: var(--brown);
  font-size: 15px;
  font-weight: 700;
}

.visit-stats span {
  white-space: nowrap;
}

.visit-stats b {
  color: #7b4b32;
  font-variant-numeric: tabular-nums;
}

h1 {
  margin: 0 0 28px;
  color: #fffaf2;
  font-size: clamp(42px, 8vw, 88px);
  line-height: 1.05;
  text-shadow: 0 12px 34px rgba(43, 24, 17, 0.42);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.mode-card {
  min-height: 176px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease, background 0.18s ease;
}

.mode-card:hover {
  transform: translateY(-3px);
  background: var(--paper-strong);
}

.mode-icon,
.mode-title,
.mode-desc {
  display: block;
}

.mode-icon {
  font-size: 36px;
}

.mode-title {
  margin-top: 10px;
  font-size: 26px;
  font-weight: 700;
}

.mode-desc {
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.55;
}

.scene-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.25s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.scene-tint {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(40, 24, 17, 0.08), rgba(30, 18, 14, 0.16));
  pointer-events: none;
}

.red-flash {
  position: absolute;
  inset: 0;
  background: rgba(210, 46, 46, 0);
  pointer-events: none;
  transition: background 0.15s ease;
}

.red-flash.active {
  background: rgba(210, 46, 46, 0.2);
}

.top-hud,
.bottom-status,
.pressure-panel,
.pay-button,
.speech-bubble {
  position: absolute;
  z-index: 2;
}

.top-hud {
  top: 18px;
  left: 50%;
  width: min(640px, calc(100% - 28px));
  transform: translateX(-50%);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(62, 38, 28, 0.18);
  backdrop-filter: blur(14px);
}

.hud-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.hud-line.small {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.bar {
  overflow: hidden;
  height: 10px;
  margin-top: 10px;
  border-radius: 999px;
  background: rgba(99, 64, 45, 0.16);
}

.bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.18s linear;
}

.timer-bar span {
  background: linear-gradient(90deg, var(--mint), #f4cc7c);
}

.nail-bar span {
  background: linear-gradient(90deg, var(--pink), var(--gold));
}

.speech-bubble {
  top: 24%;
  left: 50%;
  max-width: min(420px, calc(100% - 42px));
  padding: 16px 20px;
  border-radius: 22px 22px 22px 8px;
  background: rgba(255, 251, 246, 0.92);
  box-shadow: 0 12px 36px rgba(50, 28, 20, 0.18);
  color: var(--brown);
  font-size: clamp(18px, 3vw, 24px);
  font-weight: 700;
  transform: translateX(-50%);
  animation: bubbleIn 0.18s ease-out;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 28px;
  bottom: -10px;
  border-width: 11px 10px 0 0;
  border-style: solid;
  border-color: rgba(255, 251, 246, 0.92) transparent transparent transparent;
}

.bottom-status {
  left: 18px;
  bottom: 18px;
  display: flex;
  max-width: calc(100% - 170px);
  flex-wrap: wrap;
  gap: 10px;
}

.glass-pill {
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  background: var(--paper);
  box-shadow: 0 10px 28px rgba(62, 38, 28, 0.14);
  backdrop-filter: blur(12px);
  font-weight: 700;
}

.pressure-panel {
  right: 18px;
  top: 148px;
  width: min(260px, calc(100% - 36px));
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 20px;
  background: var(--paper);
  backdrop-filter: blur(12px);
  box-shadow: 0 12px 32px rgba(62, 38, 28, 0.16);
}

.pressure-text {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.pressure-track {
  position: relative;
  height: 12px;
  margin-top: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #b7d8cf, #f3cf83, #efa2a8);
}

.pressure-zone.good {
  position: absolute;
  left: 38%;
  width: 24%;
  top: -4px;
  bottom: -4px;
  border: 2px solid rgba(255, 255, 255, 0.86);
  border-radius: 999px;
}

#pressureNeedle {
  position: absolute;
  left: 8%;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 3px solid #fffaf2;
  border-radius: 50%;
  background: var(--brown);
  box-shadow: 0 4px 12px rgba(61, 38, 29, 0.3);
  transform: translate(-50%, -50%);
  transition: left 0.12s ease;
}

.pay-button {
  right: clamp(130px, 18vw, 360px);
  bottom: 18px;
  min-width: 172px;
  padding: 20px 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fff0ad, #f3b760);
  box-shadow: 0 18px 36px rgba(128, 78, 28, 0.34);
  color: #5a321a;
  font-size: 24px;
  font-weight: 900;
  transition: transform 0.1s ease;
}

.pay-button:active {
  transform: translateY(2px) scale(0.98);
}

.file-tool {
  position: absolute;
  z-index: 3;
  left: 54%;
  top: 55%;
  width: min(240px, 36vw);
  height: 34px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 50%, rgba(255,255,255,0.45) 0 1px, transparent 2px),
    linear-gradient(180deg, #d8d0c7, #a99f95);
  box-shadow: inset 0 1px 5px rgba(255, 255, 255, 0.6), 0 10px 22px rgba(48, 31, 25, 0.26);
  transform: translate(-50%, -50%) rotate(-10deg);
  pointer-events: none;
}

.file-tool::after {
  content: "";
  position: absolute;
  inset: 7px 16px;
  border-radius: inherit;
  background: repeating-linear-gradient(90deg, rgba(80, 70, 62, 0.18) 0 2px, transparent 2px 6px);
}

.nail-target {
  position: absolute;
  z-index: 2;
  left: 51%;
  top: 57%;
  width: 104px;
  height: 58px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 248, 240, 0.8);
  background: rgba(255, 169, 178, 0.1);
  pointer-events: none;
}

.nail-target.hurt {
  background: rgba(222, 62, 62, 0.22);
  border-color: rgba(222, 62, 62, 0.62);
}

.float-layer,
.spark-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  overflow: hidden;
}

.float-text {
  position: absolute;
  color: #fff3ad;
  text-shadow: 0 3px 12px rgba(66, 42, 20, 0.36);
  font-size: 24px;
  font-weight: 900;
  animation: floatUp 1s ease-out forwards;
}

.float-text.down {
  color: #ff9999;
  animation: floatDown 0.9s ease-in forwards;
}

.float-text.perfect {
  color: #fffaf2;
  font-size: 32px;
  letter-spacing: 0;
}

.spark {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff3ad;
  box-shadow: 0 0 18px #fff3ad;
  animation: sparkle 0.75s ease-out forwards;
}

.result-modal {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(37, 22, 17, 0.42);
  backdrop-filter: blur(3px);
}

.game-screen.finished .scene-image {
  filter: brightness(0.72) blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100% - 34px));
  padding: 26px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 28px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
  text-align: center;
  transform: translateY(132px);
  animation: modalPop 0.22s ease-out;
}

.result-icon {
  font-size: 46px;
}

.modal-card h2 {
  margin: 8px 0 8px;
  font-size: 32px;
  line-height: 1.15;
}

.modal-card p {
  margin: 0 0 18px;
  color: var(--muted);
}

.score-panel {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  text-align: left;
}

.score-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  font-weight: 700;
}

.modal-card button {
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), #f4cc7c);
  color: #5a321a;
  font-weight: 900;
}

.modal-card button.secondary {
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
}

.shake {
  animation: shake 0.24s linear;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translate(-50%, 8px) scale(0.96); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

@keyframes floatUp {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  20% { opacity: 1; }
  to { opacity: 0; transform: translateY(-74px) scale(1.08); }
}

@keyframes floatDown {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  20% { opacity: 1; }
  to { opacity: 0; transform: translateY(62px) scale(0.98); }
}

@keyframes sparkle {
  from { opacity: 1; transform: translate(0, 0) scale(0.4); }
  to { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(1.2); }
}

@keyframes modalPop {
  from { opacity: 0; transform: translateY(132px) scale(0.9); }
  to { opacity: 1; transform: translateY(132px) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -3px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(4px, 2px); }
}

@media (max-width: 720px) {
  .mode-grid {
    grid-template-columns: 1fr;
  }

  .home-content {
    justify-content: flex-end;
    padding-bottom: 34px;
  }

  h1 {
    font-size: clamp(42px, 13vw, 68px);
  }

  .visit-stats {
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 13px;
  }

  .mode-card {
    min-height: 136px;
    padding: 18px;
    border-radius: 22px;
  }

  .speech-bubble {
    top: 30%;
  }

  .pressure-panel {
    top: auto;
    right: 14px;
    bottom: 94px;
  }

  .bottom-status {
    right: 14px;
    left: 14px;
    bottom: 14px;
    max-width: none;
  }

  .pay-button {
    right: 50%;
    bottom: 92px;
    min-width: min(240px, calc(100% - 40px));
    transform: translateX(50%);
  }

  .pay-button:active {
    transform: translateX(50%) translateY(2px) scale(0.98);
  }

  .glass-pill {
    padding: 9px 12px;
    font-size: 13px;
  }
}
