:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #0d0d10;
  touch-action: none;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 15%, #2b2c34 0, #111217 46%, #090a0d 100%);
}

#app {
  position: relative;
  width: min(100vw, 56.25vh);
  height: min(100vh, 177.777vw);
  max-width: 540px;
  max-height: 960px;
  overflow: hidden;
  isolation: isolate;
  background: #c7c9df;
  box-shadow: 0 0 70px rgb(0 0 0 / 45%);
}

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

#hud {
  position: absolute;
  top: max(34px, env(safe-area-inset-top));
  left: 42px;
  color: #454550;
  pointer-events: none;
}

#score {
  font-family: Consolas, "Courier New", monospace;
  font-size: clamp(38px, 10vw, 58px);
  font-weight: 700;
  letter-spacing: -5px;
  line-height: 1;
}

#combo {
  min-height: 24px;
  margin-top: 7px;
  color: #797b8f;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
}

.top-actions {
  position: absolute;
  top: max(25px, env(safe-area-inset-top));
  right: 22px;
  display: flex;
  gap: 8px;
}

.top-actions button, .close {
  width: 38px;
  height: 38px;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: 999px;
  color: #f8f8fb;
  background: rgb(87 88 108 / 45%);
  font: 700 18px/1 inherit;
  backdrop-filter: blur(8px);
  cursor: pointer;
}

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 52px;
  text-align: center;
  color: #3f404b;
  background: linear-gradient(180deg, rgb(232 233 245 / 88%), rgb(198 201 225 / 92%));
  backdrop-filter: blur(12px);
  opacity: 0;
  visibility: hidden;
  transform: scale(1.02);
  transition: opacity 240ms ease, transform 240ms ease, visibility 240ms;
  z-index: 3;
}

.panel.show { opacity: 1; visibility: visible; transform: scale(1); }
.panel.compact { inset: auto 28px 25%; 28px; border-radius: 28px; padding: 46px 34px 34px; box-shadow: 0 24px 70px rgb(55 57 80 / 22%); }
.panel .close { position: absolute; top: 16px; right: 16px; }
.panel h1 { margin: 10px 0 8px; font-size: clamp(56px, 16vw, 84px); letter-spacing: 12px; }
.panel h2 { margin: 10px 0 14px; font-size: 42px; }
#gameover-panel h2 { font: 700 clamp(76px, 22vw, 112px)/1 Consolas, monospace; letter-spacing: -7px; }
.panel p { max-width: 340px; line-height: 1.7; }
.eyebrow { margin: 0; color: #85879b; font-size: 12px; font-weight: 800; letter-spacing: 5px; }
.subtitle { margin: 0 0 32px; color: #686a7c; }
.best, .result-line { color: #77798c; }

.panel > button:not(.close) {
  min-width: 178px;
  padding: 15px 30px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #56576d;
  box-shadow: 0 12px 30px rgb(73 74 94 / 25%);
  font: 700 17px/1 inherit;
  letter-spacing: 3px;
  cursor: pointer;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 9%;
  min-width: 140px;
  padding: 10px 18px;
  border-radius: 999px;
  color: #fff;
  background: rgb(55 56 73 / 72%);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: 180ms ease;
}

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

@media (max-aspect-ratio: 9 / 16) {
  #app { width: 100vw; height: 100vh; max-width: none; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .panel, #toast { transition: none; }
}
