:root {
  --bg: #070b16;
  --surface: #10182b;
  --surface-hi: #15203a;
  --line: rgba(148, 163, 184, 0.2);
  --line-hi: rgba(125, 211, 252, 0.4);
  --ink: #f3f7ff;
  --muted: #93a4bf;
  --cyan: #5ee7ff;
  --violet: #8b7cff;
  --violet-hi: #a99dff;
  --board: #090f20;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -20%, rgba(92, 86, 218, 0.28), transparent 36rem),
    radial-gradient(circle at 4% 72%, rgba(16, 145, 203, 0.12), transparent 25rem),
    var(--bg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: '';
  opacity: 0.34;
  background-image: radial-gradient(rgba(148, 163, 184, 0.16) 0.7px, transparent 0.7px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, black, transparent 82%);
  pointer-events: none;
}

button {
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

/* ---------- 头部 ---------- */
.app {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 2.15rem 1.25rem 2rem;
}

.top {
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: 1.8rem;
  text-align: center;
}

.top::before,
.top::after {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 1px;
  content: '';
  background: linear-gradient(90deg, transparent, var(--cyan));
}

.top::before {
  right: calc(50% + 142px);
}

.top::after {
  left: calc(50% + 142px);
  transform: scaleX(-1);
}

.top h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 2.45rem);
  font-weight: 900;
  letter-spacing: 0.13em;
  line-height: 1.15;
  color: #f9fbff;
  text-shadow: 0 0 26px rgba(124, 114, 255, 0.4);
}

.sub {
  margin: 0.38rem 0 0;
  color: var(--cyan);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ---------- 主布局 ---------- */
.layout {
  display: grid;
  grid-template-columns: 316px 226px;
  justify-content: center;
  align-items: start;
  gap: 1.35rem;
}

.board-col {
  width: 316px;
}

.board-wrap {
  position: relative;
  width: 100%;
  padding: 7px;
  border: 1px solid var(--line-hi);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(43, 59, 91, 0.95), rgba(16, 23, 41, 0.95));
  box-shadow:
    0 0 0 1px rgba(94, 231, 255, 0.08) inset,
    0 0 24px rgba(94, 231, 255, 0.1),
    0 24px 55px rgba(0, 0, 0, 0.42);
}

#board {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 11px;
  background: var(--board);
}

/* ---------- 游戏遮罩 ---------- */
.overlay {
  position: absolute;
  inset: 7px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: rgba(5, 10, 24, 0.75);
  backdrop-filter: blur(5px);
}

.hidden {
  display: none !important;
}

.ovl-card {
  width: min(224px, calc(100% - 2rem));
  padding: 1.55rem 1.25rem 1.3rem;
  text-align: center;
  border: 1px solid rgba(94, 231, 255, 0.38);
  border-radius: 14px;
  background: linear-gradient(145deg, #172441, #0e1629);
  box-shadow: 0 0 30px rgba(94, 231, 255, 0.13);
}

.ovl-title {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.ovl-hint,
.ovl-score {
  margin: 0 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.ovl-score b {
  margin-left: 0.2rem;
  color: var(--cyan);
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- 信息面板 ---------- */
.side {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 226px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(22, 33, 59, 0.94), rgba(13, 20, 37, 0.94));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.lbl {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.score-card {
  position: relative;
  overflow: hidden;
  padding: 0.8rem 1rem 0.7rem;
  border-color: rgba(139, 124, 255, 0.4);
  background: linear-gradient(135deg, rgba(75, 61, 163, 0.68), rgba(19, 27, 52, 0.96));
  text-align: right;
}

.score-card::before {
  position: absolute;
  top: -42px;
  left: -38px;
  width: 86px;
  height: 86px;
  content: '';
  border: 1px solid rgba(94, 231, 255, 0.35);
  border-radius: 20px;
  transform: rotate(26deg);
}

.score-val {
  position: relative;
  display: block;
  color: #fff;
  font-size: 2.1rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
  line-height: 1.05;
  text-shadow: 0 0 16px rgba(169, 157, 255, 0.48);
}

.next-card {
  display: flex;
  min-height: 116px;
  padding: 0.72rem 1rem 0.55rem;
  flex-direction: column;
  align-items: center;
}

.next-card .lbl {
  align-self: stretch;
}

#next {
  display: block;
  width: 78px;
  height: 78px;
  filter: drop-shadow(0 0 9px rgba(94, 231, 255, 0.15));
}

.stats-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding: 0.8rem 0.85rem;
}

.stat {
  min-width: 0;
}

.stat + .stat {
  padding-left: 0.5rem;
  border-left: 1px solid var(--line);
}

.stat .lbl {
  margin-bottom: 0.16rem;
  font-size: 0.55rem;
  letter-spacing: 0.09em;
}

.stat b {
  display: block;
  color: #eaf4ff;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* ---------- 控制区 ---------- */
.ctrl-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.58rem;
  padding: 0.8rem;
}

.btn {
  min-height: 40px;
  padding: 0.52rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: #07101c;
  border-color: rgba(142, 240, 255, 0.8);
  background: linear-gradient(135deg, #79edff, #72bdfd);
  box-shadow: 0 5px 16px rgba(66, 202, 255, 0.2);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #a2f4ff, #8ecbff);
  box-shadow: 0 8px 20px rgba(66, 202, 255, 0.3);
}

.btn.ghost {
  color: #dce7ff;
  border-color: rgba(148, 163, 184, 0.34);
  background: rgba(255, 255, 255, 0.025);
}

.btn.ghost:hover {
  border-color: var(--violet-hi);
  background: rgba(139, 124, 255, 0.14);
}

.btn.big {
  min-height: 44px;
  padding-inline: 1.1rem;
}

.keys {
  display: grid;
  grid-column: 1 / -1;
  gap: 0.22rem;
  margin: 0.1rem 0 0;
  padding: 0.72rem 0 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.74rem;
  list-style: none;
}

.keys li {
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  min-width: 1.55em;
  padding: 0.08em 0.35em;
  place-items: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-bottom-color: rgba(148, 163, 184, 0.46);
  border-radius: 4px;
  color: #e4efff;
  background: rgba(148, 163, 184, 0.1);
  font-family: inherit;
  font-size: 0.9em;
  line-height: 1.15;
}

/* ---------- 触屏按键 ---------- */
.pad {
  display: none;
  margin-top: 0.85rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.pad-row {
  display: flex;
  justify-content: center;
  gap: 0.52rem;
  margin-bottom: 0.52rem;
}

.pad-btn {
  height: 48px;
  max-width: 94px;
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: #e8f4ff;
  background: linear-gradient(145deg, #172440, #101829);
  box-shadow: 0 5px 14px rgba(0, 0, 0, 0.22);
  font-family: inherit;
  font-size: 1.12rem;
}

.pad-btn.wide {
  max-width: 190px;
  color: var(--cyan);
  font-size: 0.92rem;
  font-weight: 800;
}

.pad-btn:active {
  border-color: var(--cyan);
  background: #1c3154;
  box-shadow: 0 0 13px rgba(94, 231, 255, 0.22);
}

.foot {
  margin-top: 1.5rem;
  color: rgba(147, 164, 191, 0.7);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  text-align: center;
}

/* ---------- 响应式 ---------- */
@media (max-width: 620px) {
  .app {
    padding: 1.35rem 0.9rem 1.75rem;
  }

  .top {
    margin-bottom: 1.3rem;
  }

  .top::before,
  .top::after {
    display: none;
  }

  .layout {
    grid-template-columns: minmax(0, 316px);
    gap: 1rem;
  }

  .board-col,
  .side {
    width: min(316px, 100%);
  }

  .side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.65rem;
  }

  .score-card,
  .next-card,
  .stats-card {
    min-height: 0;
  }

  .next-card {
    padding-inline: 0.75rem;
  }

  .ctrl-card {
    grid-column: 1 / -1;
  }

  .pad {
    display: block;
  }
}

@media (max-width: 350px) {
  .app {
    padding-inline: 0.55rem;
  }

  .top h1 {
    font-size: 1.65rem;
  }
}
