@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@400;600;700&display=swap");

:root {
  --bg-a: #0b0c10;
  --bg-b: #1c0b2b;
  --ink: #e0f0ff;
  --panel: rgba(18, 20, 38, 0.7);
  --panel-stroke: rgba(100, 150, 255, 0.4);
  --orange: #f28c35;
  --green: #43cf61;
  --move-ms: 380ms;
  --key-glow: rgba(255, 183, 95, 0.58);
  --key-tint-strength: 1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Lexend", "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(85, 45, 230, 0.4), transparent 46%),
    radial-gradient(circle at 84% 82%, rgba(45, 140, 230, 0.35), transparent 44%),
    linear-gradient(135deg, var(--bg-a), var(--bg-b));
  display: grid;
  place-items: center;
  overflow: hidden;
}

.scene {
  position: relative;
  width: min(92vw, 760px);
  min-height: min(88vh, 860px);
  border-radius: 30px;
  border: 1px solid var(--panel-stroke);
  background: var(--panel);
  backdrop-filter: blur(16px);
  box-shadow:
    0 0 40px rgba(75, 45, 230, 0.2),
    inset 0 0 20px rgba(100, 150, 255, 0.1);
  padding: clamp(18px, 3.4vw, 30px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  isolation: isolate;
}

.scene::before,
.scene::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 999px;
  filter: blur(6px);
  opacity: 0.8;
  animation: floatBlob 7.6s ease-in-out infinite;
}

.scene::before {
  width: 200px;
  height: 200px;
  top: -42px;
  right: 8%;
  background: rgba(140, 60, 255, 0.4);
}

.scene::after {
  width: 240px;
  height: 240px;
  bottom: -58px;
  left: -38px;
  background: rgba(40, 160, 255, 0.3);
  animation-delay: -2.9s;
}

h1 {
  margin: 6px 0 2px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  letter-spacing: 0.12em;
  font-weight: 700;
  text-transform: uppercase;
  color: #c0d0ff;
  text-shadow: 0 0 12px rgba(100, 150, 255, 0.4);
}

.subtitle {
  margin: 0;
  text-align: center;
  font-size: clamp(0.88rem, 2vw, 1rem);
  opacity: 0.8;
  max-width: 32ch;
  line-height: 1.45;
  min-height: 2.9em;
  transition: opacity 380ms ease;
}

.start-btn {
  margin-top: 8px;
  border: 1px solid rgba(130, 180, 255, 0.4);
  border-radius: 999px;
  padding: 14px 34px;
  font-size: clamp(1rem, 2.3vw, 1.12rem);
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #324edc, #6c32dc 60%, #4a28d2);
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(78, 50, 220, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transition: transform 260ms ease, opacity 260ms ease, filter 260ms ease, box-shadow 260ms ease;
  letter-spacing: 0.1em;
}

.start-btn:hover {
  transform: translateY(-2px) scale(1.02);
  filter: brightness(1.15);
  box-shadow:
    0 12px 30px rgba(100, 80, 255, 0.5),
    0 0 16px rgba(120, 160, 255, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.start-btn:active {
  transform: translateY(0) scale(0.98);
}

.start-btn.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.95);
}

.board {
  position: relative;
  width: min(88vw, 560px);
  height: min(62vh, 620px);
  border-radius: 24px;
  border: 1px solid rgba(80, 140, 255, 0.3);
  background: linear-gradient(165deg, rgba(20, 22, 40, 0.8), rgba(12, 10, 24, 0.9));
  box-shadow:
    inset 0 0 0 1px rgba(100, 160, 255, 0.15),
    inset 0 -18px 40px rgba(50, 40, 120, 0.4),
    0 0 20px rgba(60, 100, 255, 0.15);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 420ms ease, transform 420ms ease, box-shadow 420ms ease;
  overflow: hidden;
}

.board::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 16px;
  border: 1px dashed rgba(100, 180, 255, 0.25);
  background: radial-gradient(circle at center, rgba(60, 100, 200, 0.04) 0%, transparent 60%);
  pointer-events: none;
}

.board.is-visible {
  opacity: 1;
  transform: translateY(0);
  box-shadow:
    inset 0 0 0 1px rgba(100, 160, 255, 0.2),
    inset 0 -18px 40px rgba(50, 40, 120, 0.5),
    0 0 30px rgba(80, 120, 255, 0.25);
  pointer-events: auto;
}

.board.is-selectable .key {
  cursor: pointer;
}

.key {
  position: absolute;
  width: clamp(72px, 16vw, 110px);
  aspect-ratio: 1 / 1;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(var(--key-rotation, 0deg));
  border: none;
  padding: 0;
  background: transparent;
  isolation: isolate;
  transition:
    left var(--move-ms) cubic-bezier(0.33, 1, 0.68, 1),
    top var(--move-ms) cubic-bezier(0.33, 1, 0.68, 1),
    transform var(--move-ms) cubic-bezier(0.33, 1, 0.68, 1),
    filter 460ms ease;
  filter: drop-shadow(0 7px 9px rgba(27, 34, 50, 0.24));
}

.key-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  transition: filter 460ms ease;
  user-select: none;
  -webkit-user-drag: none;
}

.key::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--key-color, var(--orange));
  -webkit-mask-image: url("key.png");
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-image: url("key.png");
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  mix-blend-mode: color;
  opacity: var(--key-tint-strength);
  transition: background-color 460ms ease, box-shadow 460ms ease, opacity 460ms ease;
  box-shadow: 0 0 16px 2px var(--key-glow);
  pointer-events: none;
}

@supports not (mix-blend-mode: color) {
  .key::after {
    mix-blend-mode: normal;
    opacity: 0.48;
  }
}

.key:disabled {
  cursor: default;
}

.key:focus-visible {
  outline: 3px solid rgba(80, 200, 255, 0.7);
  outline-offset: 2px;
  border-radius: 12px;
  box-shadow: 0 0 16px rgba(80, 200, 255, 0.5);
}

@keyframes floatBlob {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-12px) scale(1.04);
  }
}

@media (max-width: 640px) {
  .scene {
    min-height: 96vh;
    border-radius: 22px;
  }

  .board {
    height: min(62vh, 540px);
  }

  .key {
    width: clamp(66px, 18vw, 92px);
  }
}