* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background: #1a1a2e;
  color: #eee;
  font-family: "Courier New", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding-bottom: 40px;
}
a {
  color: #88d8f1;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
.topbar {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  background: #0f0f23;
  border-bottom: 1px solid #333;
  font-family: -apple-system, sans-serif;
  font-size: 12px;
}
.btn-back {
  display: inline-block;
  padding: 4px 12px;
  background: #16213e;
  color: #88d8f1;
  border: 1px solid #88d8f1;
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-back:hover {
  background: #88d8f1;
  color: #10131f;
  text-decoration: none;
}
.topbar .other {
  color: #8a8aa3;
}
h1 {
  margin: 20px 0 10px;
  font-size: 1.5em;
  color: #e94560;
}
.info {
  color: #888;
  margin-bottom: 15px;
  font-size: 0.85em;
  text-align: center;
  padding: 0 8px;
}
#levels {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  max-width: 480px;
  margin-bottom: 12px;
}
#levels button {
  background: #16213e;
  color: #eee;
  border: 1px solid #555;
  padding: 4px 0;
  width: 44px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  border-radius: 4px;
}
#levels button:hover {
  border-color: #e94560;
}
#levels button.done {
  border-color: #4fcc30;
  color: #4fcc30;
}
#levels button.active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}
canvas {
  border: 2px solid #e94560;
  image-rendering: pixelated;
  display: block;
}
#game {
  width: auto;
  height: auto;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 290px);
  min-height: 200px;
}
#crt-frame {
  position: relative;
  display: inline-block;
}
#crt-frame.crt-on canvas {
  filter: saturate(1.15) contrast(1.06) brightness(1.03) drop-shadow(0 0 6px rgba(120, 200, 255, .18));
  border-radius: 10px;
}
#crt-frame #crt-fx {
  display: none;
}
#crt-frame.crt-on #crt-fx {
  display: block;
  position: absolute;
  inset: 2px;
  pointer-events: none;
  border-radius: 9px;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, .28) 0 1px,
      transparent 1px 3px),
    repeating-linear-gradient(
      to right,
      rgba(255, 60, 60, .05) 0 1px,
      rgba(60, 255, 60, .04) 1px 2px,
      rgba(60, 120, 255, .05) 2px 3px),
    radial-gradient(
      ellipse at center,
      transparent 58%,
      rgba(0, 0, 0, .28) 100%);
}
#crt-frame.crt-on #crt-fx::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 9px;
  background:
    linear-gradient(
      to bottom,
      transparent 0%,
      rgba(255, 255, 255, .045) 48%,
      rgba(255, 255, 255, .075) 50%,
      rgba(255, 255, 255, .045) 52%,
      transparent 100%);
  background-size: 100% 220%;
  animation: crt-roll 7s linear infinite;
}
@keyframes crt-roll {
  from {
    background-position: 0 -110%;
  }
  to {
    background-position: 0 110%;
  }
}
@media (prefers-reduced-motion: reduce) {
  #crt-frame.crt-on #crt-fx::after {
    animation: none;
  }
}
.crt-toggle {
  font-size: 0.8em;
  color: #888;
  cursor: pointer;
  user-select: none;
  margin-left: 10px;
}
.crt-toggle input {
  vertical-align: middle;
  accent-color: #e94560;
}
#status {
  margin: 15px 0;
  font-size: 1.1em;
  min-height: 1.5em;
  text-align: center;
  padding: 0 8px;
}
#status.win {
  color: #4fcc30;
}
#status.warn {
  color: #ffaa33;
}
#controls {
  display: flex;
  gap: 20px;
  margin: 10px 0;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 100vw;
}
.key-group {
  text-align: center;
}
.key-row {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 2px 0;
}
.key {
  background: #16213e;
  border: 1px solid #555;
  color: #eee;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.9em;
  min-width: 36px;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
}
.key:hover {
  border-color: #e94560;
}
.key.active {
  background: #e94560;
  border-color: #e94560;
}
