:root {
  color-scheme: dark;
  --bg: #080b10;
  --panel: #111722;
  --panel-2: #182130;
  --text: #f2f7ff;
  --muted: #9fb0c7;
  --accent: #42e8c7;
  --danger: #ff5f72;
  --gold: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 12%, rgba(66, 232, 199, 0.13), transparent 26rem),
    linear-gradient(135deg, #0a0c0a 0%, #171711 48%, #071312 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  display: grid;
  place-items: center;
  padding: 24px;
}

.shell {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 18px;
  align-items: start;
}

.game-panel {
  grid-row: 1;
  grid-column: 1;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #05070b;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.hud {
  grid-row: 1;
  grid-column: 2;
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  background: #11150f;
}

.hud {
  display: grid;
  gap: 10px;
}

.hud div {
  min-height: 78px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud strong {
  display: block;
  margin-top: 6px;
  font-size: 1.7rem;
  line-height: 1;
}

.hud-action button {
  width: 100%;
  min-width: 0;
  margin-top: 8px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  align-content: center;
  gap: 18px;
  padding: 28px;
  text-align: center;
  background: rgba(5, 7, 11, 0.78);
  backdrop-filter: blur(4px);
}

.overlay.visible {
  display: grid;
}

.overlay h1 {
  margin: 0;
  font-size: clamp(3rem, 8vw, 6.6rem);
  line-height: 0.92;
  color: var(--accent);
  text-shadow: 0 0 28px rgba(66, 232, 199, 0.4);
}

.overlay p {
  max-width: 520px;
  margin: 0;
  color: var(--text);
  font-size: clamp(1rem, 2vw, 1.25rem);
}

button {
  min-width: 150px;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 18px;
  background: var(--accent);
  color: #06100e;
  cursor: pointer;
  font: 700 0.95rem "Segoe UI", system-ui, sans-serif;
}

button:hover,
button:focus-visible {
  background: #7bf7dc;
  outline: 3px solid rgba(66, 232, 199, 0.28);
}

.below-playfield {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 4px 2px;
}

.credits-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.credits-link:hover,
.credits-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

.attribution {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.attribution a {
  color: var(--muted);
  text-decoration: underline;
}

.attribution a:hover,
.attribution a:focus-visible {
  color: var(--accent);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 7, 11, 0.72);
  backdrop-filter: blur(4px);
  z-index: 10;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(520px, 100%);
  max-height: min(70vh, 600px);
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--accent);
}

.modal-close {
  min-width: 0;
  min-height: 0;
  width: 32px;
  height: 32px;
  padding: 0;
  line-height: 1;
  font-size: 1.3rem;
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  outline: none;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  color: var(--text);
  line-height: 1.5;
}

.modal-body h1,
.modal-body h2,
.modal-body h3 {
  color: var(--accent);
  margin: 1em 0 0.4em;
}

.modal-body h1:first-child,
.modal-body h2:first-child,
.modal-body h3:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin: 0.3em 0 1em;
  padding-left: 1.2em;
}

.modal-body a {
  color: var(--accent);
}

.modal-body p.credits-error {
  color: var(--danger);
}

@media (max-width: 820px) {
  body {
    padding: 12px;
  }

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

  .game-panel {
    grid-column: 1;
  }

  .below-playfield {
    grid-row: 2;
    grid-column: 1;
  }

  .hud {
    grid-row: 3;
    grid-column: 1;
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .hud div {
    min-height: 64px;
    padding: 10px;
  }

  .hud strong {
    font-size: 1.2rem;
  }
}
