:root {
  color-scheme: dark;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #10101c;
  color: #f7f3ff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background:
    radial-gradient(ellipse at 50% 100%, #29204c 0, transparent 48%),
    radial-gradient(ellipse at 15% 5%, #242044 0, transparent 35%),
    #10101c;
}

button { font: inherit; }

.game {
  width: min(100% - 32px, 760px);
  padding: 28px 0 24px;
}

.topline {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #b6a8e8;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(25px, 6vw, 38px);
  letter-spacing: -.04em;
  line-height: 1;
}

.stats { display: flex; gap: 10px; }

.stat {
  min-width: 78px;
  padding: 9px 13px 8px;
  border: 1px solid #ffffff16;
  border-radius: 14px;
  background: #ffffff09;
  text-align: right;
}

.stat-label {
  display: block;
  margin-bottom: 2px;
  color: #a9a2c2;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
}

.stat-value { font-size: 18px; font-weight: 800; }

.stage {
  position: relative;
  overflow: hidden;
  border: 1px solid #ffffff20;
  border-radius: 22px;
  background: #111222;
  box-shadow: 0 25px 80px #0007, 0 0 55px #8667ff12;
}

canvas {
  display: block;
  width: 100%;
  height: min(62vh, 480px);
  min-height: 340px;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(#1112226e, #111222d9);
  text-align: center;
}

.overlay[hidden] { display: none; }

.card { max-width: 370px; }

.mascot {
  margin-bottom: 8px;
  font-size: 58px;
  filter: drop-shadow(0 0 22px #a48aff70);
}

.overlay h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 5vw, 32px);
  letter-spacing: -.03em;
}

.overlay p {
  margin: 0 auto 18px;
  color: #c1bdd5;
  font-size: 14px;
  line-height: 1.7;
}

.result {
  display: grid;
  gap: 7px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid #ffffff1f;
  border-radius: 16px;
  background: #ffffff0a;
  text-align: left;
}

.result[hidden] { display: none; }

.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
}

.result-row dt {
  color: #a9a2c2;
  font-size: 12px;
  font-weight: 700;
}

.result-row dd {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.record {
  margin: -4px 0 16px;
  color: #ffd479;
  font-size: 14px;
  font-weight: 800;
}

.record[hidden] { display: none; }

.primary {
  min-height: 46px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #b9a2ff, #8f76ff);
  color: #171126;
  font-weight: 850;
  box-shadow: 0 6px 24px #8f76ff50;
  cursor: pointer;
  transition: transform .15s ease, filter .15s ease;
}

.primary:hover { filter: brightness(1.08); transform: translateY(-2px); }
.primary:focus-visible, .touch-button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.legend {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 12px 8px 0;
  color: #aaa5bf;
  font-size: 12px;
}

.legend span { white-space: nowrap; }
.legend b { color: #f1eaff; }

.sound-toggle {
  padding: 5px 12px;
  border: 1px solid #ffffff1f;
  border-radius: 999px;
  background: #ffffff0d;
  color: #d9d3f2;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease;
}

.sound-toggle:hover { background: #ffffff1a; }
.sound-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

.touch-controls {
  display: none;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.touch-button {
  width: 58px;
  height: 48px;
  border: 1px solid #ffffff24;
  border-radius: 15px;
  background: #ffffff0d;
  color: #f7f3ff;
  font-size: 20px;
  touch-action: none;
}

@media (pointer: coarse) {
  .touch-controls { display: flex; }
  .legend { padding-top: 9px; }
}

@media (max-width: 480px) {
  .game { width: min(100% - 22px, 760px); padding-top: 18px; }
  .topline { align-items: center; }
  .stats { gap: 6px; }
  .stat { min-width: 64px; padding: 8px 9px; }
  .stat-value { font-size: 16px; }
  canvas { height: 58vh; min-height: 320px; }
  .legend { gap: 11px; font-size: 11px; }
}
