:root {
  color-scheme: dark;
  --bg: #0b0e1a;
  --panel: #141a2e;
  --panel-border: #263050;
  --text: #e8ecf8;
  --muted: #9aa6c8;
  --accent: #5b83e8;
  --accent-strong: #7ba0ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2242 0%, var(--bg) 60%);
  color: var(--text);
  font-family:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.app-header {
  text-align: center;
  margin-bottom: 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.04em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  aspect-ratio: 4 / 5;
  max-height: 78vh;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  background: #0e1222;
}

#gl {
  display: block;
  width: 100%;
  height: 100%;
}

.panel {
  flex: 0 0 250px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat,
.next {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stat strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.next canvas {
  display: block;
  margin-top: 6px;
  image-rendering: pixelated;
}

.controls {
  display: flex;
  gap: 8px;
}

button {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.overlay button {
  flex: none;
  min-width: 160px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.overlay button:hover,
.overlay button:focus-visible {
  background: var(--accent-strong);
}

.message {
  min-height: 1.2em;
  margin: 0;
  color: var(--accent-strong);
  font-size: 0.9rem;
  text-align: center;
}

.rules {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--muted);
}

.rules summary {
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
}

.rules ul {
  margin: 8px 0 2px;
  padding-left: 18px;
  line-height: 1.7;
}

kbd {
  background: #0e1222;
  border: 1px solid var(--panel-border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 0 5px;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text);
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(8, 10, 20, 0.82);
  backdrop-filter: blur(3px);
}

.overlay[hidden] {
  display: none;
}

.overlay-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.overlay-copy {
  margin: 0;
  max-width: 380px;
  color: var(--muted);
  line-height: 1.55;
}

.overlay-copy strong {
  color: var(--text);
}

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

  .stage {
    width: 100%;
    max-height: none;
  }

  .panel {
    flex: none;
    width: 100%;
  }
}
