:root {
  color-scheme: dark;
  --bg-top: #08111e;
  --bg-bottom: #0f2940;
  --panel: rgba(7, 16, 28, 0.76);
  --panel-border: rgba(180, 225, 255, 0.22);
  --text: #eef7ff;
  --muted: #aac3d9;
  --accent: #8de3ff;
  --accent-strong: #34c5ff;
  --danger: #ff6b7f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background:
    radial-gradient(circle at top, rgba(89, 186, 255, 0.18), transparent 28%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
}

body {
  min-height: 100vh;
}

button {
  font: inherit;
}

.page-shell {
  width: min(1200px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 14px 0 18px;
}

.topbar,
.game-layout,
.hud,
.button-row,
.hud-actions,
.header-actions {
  display: flex;
}

.topbar,
.hud {
  align-items: center;
  justify-content: space-between;
}

.topbar {
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--accent);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
}

.game-layout {
  gap: 18px;
  align-items: flex-start;
}

.board-panel,
.side-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.board-panel {
  flex: 1 1 760px;
  padding: 14px;
}

.side-panel {
  width: min(320px, 100%);
  display: grid;
  gap: 16px;
}

.side-card {
  padding: 18px;
}

.side-card h2 {
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.side-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.hud {
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.hud-pill {
  min-width: 92px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(149, 220, 255, 0.08);
  border: 1px solid rgba(149, 220, 255, 0.18);
}

.hud-pill span {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

.hud-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 1.18rem;
}

.hud-actions,
.button-row,
.header-actions {
  gap: 10px;
}

.canvas-frame {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid rgba(149, 220, 255, 0.16);
  background: #050b15;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  height: auto;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, rgba(3, 8, 15, 0.24), rgba(3, 8, 15, 0.72));
}

.overlay.visible {
  display: flex;
}

.overlay-card {
  width: min(520px, 100%);
  padding: 28px;
  border-radius: 26px;
  background: rgba(4, 12, 21, 0.85);
  border: 1px solid rgba(149, 220, 255, 0.24);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  text-align: center;
}

.hero-card {
  width: min(620px, 100%);
}

.lead {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.7;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
  text-align: left;
}

.info-grid div {
  padding: 14px;
  border-radius: 18px;
  background: rgba(141, 227, 255, 0.06);
  border: 1px solid rgba(141, 227, 255, 0.12);
}

.info-grid h3 {
  margin-bottom: 8px;
}

.info-grid p + p {
  margin-top: 6px;
}

.primary-button,
.ghost-button {
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #062033;
  font-weight: 700;
}

.ghost-button {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.ghost-button.danger {
  border-color: rgba(255, 107, 127, 0.28);
  color: #ffd6dc;
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.button-row {
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 22px;
}

.result-score {
  margin-top: 14px;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  font-weight: 800;
  color: var(--accent);
}

@media (max-width: 980px) {
  .game-layout {
    flex-direction: column;
  }

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

@media (min-width: 981px) {
  .page-shell {
    width: min(1380px, calc(100vw - 24px));
  }

  .topbar {
    margin-bottom: 10px;
  }

  .game-layout {
    align-items: stretch;
  }

  .board-panel {
    min-width: 0;
  }

  .canvas-frame {
    height: min(calc(100vh - 170px), 820px);
    min-height: 560px;
  }

  #gameCanvas {
    width: auto;
    height: 100%;
    max-width: 100%;
    aspect-ratio: auto;
  }

  .side-panel {
    width: 300px;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 14px, 100%);
    padding-top: 8px;
  }

  .board-panel {
    padding: 10px;
    border-radius: 18px;
  }

  .side-panel {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
  }

  .overlay-card {
    padding: 22px 18px;
  }

  .hud-pill {
    min-width: 78px;
  }

  .topbar {
    margin-bottom: 10px;
  }

  h1 {
    font-size: clamp(1.45rem, 6vw, 2rem);
  }

  .lead {
    line-height: 1.5;
  }

  #gameCanvas {
    width: 100%;
    height: auto;
    aspect-ratio: 2 / 3;
  }
}
