:root {
  color-scheme: dark;
  --panel: rgba(19, 25, 23, 0.9);
  --panel-strong: rgba(29, 38, 34, 0.96);
  --ink: #f4f0df;
  --muted: #adb4a6;
  --line: rgba(244, 240, 223, 0.18);
  --gold: #e2b84e;
  --red: #dc5448;
  --blue: #4d9cdc;
  --green: #5dbb72;
  --yellow: #e2c94e;
  --white: #eae8dd;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 20%, rgba(226, 184, 78, 0.14), transparent 24rem),
    radial-gradient(circle at 82% 70%, rgba(77, 156, 220, 0.13), transparent 22rem),
    linear-gradient(145deg, #111716, #232920 58%, #151817);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(244, 240, 223, 0.08);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 500;
}

button:hover,
button:focus-visible {
  background: rgba(244, 240, 223, 0.16);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.game-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(14px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
  font-weight: 500;
}

.brand p,
span,
.rules {
  color: var(--muted);
}

.brand-orb {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 33% 28%, #fff3ba 0 13%, transparent 14%),
    conic-gradient(var(--red), var(--yellow), var(--blue), var(--green), var(--white), var(--red));
  box-shadow: 0 0 24px rgba(226, 184, 78, 0.22);
}

.stats {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
}

.stats div {
  display: grid;
  gap: 2px;
}

.stats strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(520px, 1fr) 240px;
  gap: 14px;
  margin-top: 14px;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #19231f;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.next-box,
.level-picker,
.meter-block,
.rules {
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.next-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 54px;
  padding: 10px;
}

.next-box i {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: inset -5px -6px 10px rgba(0, 0, 0, 0.28), 0 0 16px currentColor;
}

.level-picker {
  display: grid;
  gap: 7px;
  padding: 10px;
}

.level-picker select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(244, 240, 223, 0.08);
  color: var(--ink);
  font: inherit;
}

.meter-block {
  display: grid;
  gap: 6px;
  padding: 10px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(244, 240, 223, 0.14);
}

.meter i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), #f4df82);
}

.slow-meter i {
  background: linear-gradient(90deg, var(--blue), #99d8ff);
}

.rules {
  display: grid;
  gap: 6px;
  padding: 10px;
  font-size: 14px;
  line-height: 1.6;
}

.rules b {
  color: var(--ink);
}

#bombButton,
#slowButton {
  width: 100%;
  border-color: rgba(226, 184, 78, 0.68);
  background: rgba(226, 184, 78, 0.2);
}

#slowButton {
  border-color: rgba(77, 156, 220, 0.72);
  background: rgba(77, 156, 220, 0.16);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7, 10, 9, 0.74);
}

.overlay.hidden {
  display: none;
}

.dialog {
  width: min(430px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

.dialog h2,
.dialog p {
  margin: 0;
}

.dialog h2 {
  font-size: 26px;
  font-weight: 500;
}

.dialog p {
  margin: 10px 0 18px;
  color: var(--muted);
}

.dialog button {
  width: 100%;
  border-color: rgba(226, 184, 78, 0.68);
  background: rgba(226, 184, 78, 0.2);
}

@media (max-width: 900px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .play-area {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rules,
  .meter-block {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .game-shell {
    padding: 10px;
  }

  .stats,
  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats strong {
    font-size: 18px;
  }
}
