* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  background: radial-gradient(1200px 800px at 50% -10%, #1b2450 0%, #0a0e1f 55%, #05070f 100%);
  color: #e8ecff;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  display: flex;
  justify-content: center;
  min-height: 100%;
  -webkit-user-select: none;
  user-select: none;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  gap: 10px;
  width: 100%;
  max-width: 660px;
}

#title {
  font-size: clamp(20px, 4vw, 30px);
  letter-spacing: 8px;
  background: linear-gradient(90deg, #00e5ff, #c04dff, #ffd60a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 24px rgba(0, 229, 255, .15);
}

#stats-bar {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 540px;
  justify-content: center;
}

.stat {
  flex: 1;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(120, 140, 255, .25);
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  font-size: 14px;
  white-space: nowrap;
}
.stat .label { color: #8b96c9; margin-right: 6px; font-size: 11px; }
.stat span:last-child { font-weight: 700; font-variant-numeric: tabular-nums; }

#game-area {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  justify-content: center;
}

.side { display: flex; flex-direction: column; gap: 10px; width: 132px; }

.panel {
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(120, 140, 255, .25);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}
.panel-title { font-size: 12px; color: #8b96c9; margin-bottom: 6px; letter-spacing: 2px; }

kbd {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px;
  font-family: inherit;
}

#hold-cv { width: 116px; height: auto; }
#next-cv { width: 116px; height: auto; }

#board-wrap { position: relative; }

#board {
  display: block;
  width: min(300px, 56vw);
  height: auto;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(120, 140, 255, .35), 0 0 32px rgba(0, 229, 255, .12);
  background: #0c1124;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(5, 8, 18, .88);
  backdrop-filter: blur(3px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: 10px;
  z-index: 5;
  text-align: center;
  padding: 16px;
}
.overlay.hidden { display: none; }
.overlay h2 { font-size: 26px; letter-spacing: 6px; text-shadow: 0 0 18px rgba(0, 229, 255, .4); }
.best-line { color: #aab4e8; font-size: 14px; }
.help { color: #8b96c9; font-size: 12px; line-height: 1.9; }

.ui-btn {
  cursor: pointer;
  border: 1px solid rgba(0, 229, 255, .5);
  background: rgba(0, 229, 255, .08);
  color: #bff3ff;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  letter-spacing: 2px;
  transition: .15s;
  font-family: inherit;
}
.ui-btn:hover { background: rgba(0, 229, 255, .2); box-shadow: 0 0 14px rgba(0, 229, 255, .35); }
.ui-btn.big { font-size: 17px; padding: 12px 28px; }

#levelup-banner {
  position: absolute;
  left: 0; right: 0; top: 38%;
  text-align: center;
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 6px;
  color: #ffd60a;
  text-shadow: 0 0 20px rgba(255, 214, 10, .8);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}
#levelup-banner.show { animation: levelup 1.3s ease-out; }
@keyframes levelup {
  0%   { opacity: 0; transform: scale(.5); }
  20%  { opacity: 1; transform: scale(1.15); }
  45%  { transform: scale(1); }
  75%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.05) translateY(-14px); }
}

#touch-controls {
  display: none;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-top: 4px;
}
@media (pointer: coarse) { #touch-controls { display: grid; } }

.tbtn {
  height: 58px;
  font-size: 20px;
  border-radius: 12px;
  border: 1px solid rgba(120, 140, 255, .4);
  background: rgba(255, 255, 255, .06);
  color: #e8ecff;
  touch-action: none;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.tbtn:active { background: rgba(0, 229, 255, .25); }

@media (max-width: 560px) {
  .side { width: 86px; }
  #hold-cv, #next-cv { width: 70px; }
  #btn-pause { font-size: 12px; padding: 6px 8px; letter-spacing: 1px; }
  #title { letter-spacing: 4px; }
  kbd { display: none; }
  .stat { font-size: 12px; }
}
