@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --amber: #ffb000;
  --amber-dim: #a86f00;
  --amber-dark: #4d3300;
  --brick: #e0533a;
}

body {
  background: #000;
  font-family: 'Press Start 2P', monospace;
  color: var(--amber);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.crt {
  position: relative;
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(255, 176, 0, 0.15), inset 0 0 120px rgba(0,0,0,0.6);
  transform-origin: center center;
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 20;
  border-radius: 12px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.25) 3px,
    rgba(0,0,0,0.25) 4px
  );
  animation: flicker 0.15s infinite;
}

@keyframes flicker {
  0% { opacity: 0.95; }
  50% { opacity: 1; }
  100% { opacity: 0.97; }
}

#game-container {
  position: relative;
  background: #0a0700;
  padding: 10px 20px 16px;
  border: 3px solid var(--amber-dark);
  border-radius: 12px;
}

header, footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 520px;
  padding: 10px 4px;
  font-size: 11px;
  line-height: 1.5;
  text-shadow: 0 0 6px var(--amber);
}

.hud-item.right { text-align: right; }

.title-small { text-align: center; color: var(--brick); text-shadow: 0 0 8px var(--brick); }

canvas {
  display: block;
  background: #000;
  border: 2px solid var(--amber-dark);
  image-rendering: pixelated;
}

#touch-controls {
  display: none;
  width: 520px;
  margin-top: 10px;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}

#touch-controls button {
  font-family: inherit;
  font-size: 18px;
  height: 64px;
  background: #140e00;
  color: var(--amber);
  border: 2px solid var(--amber-dim);
  border-radius: 8px;
  text-shadow: 0 0 6px var(--amber);
  touch-action: none;
}

#touch-controls button.active { background: var(--amber-dark); }

@media (pointer: coarse) {
  #touch-controls { display: grid; }
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  background: rgba(8, 5, 0, 0.94);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 22px;
  text-align: center;
  padding: 20px;
  border-radius: 12px;
}

.hidden { display: none !important; }

h1 {
  font-size: 36px;
  line-height: 1.4;
  letter-spacing: 4px;
}

.glow { color: var(--amber); text-shadow: 0 0 12px var(--amber), 0 0 40px var(--amber); }
.glow.red { color: var(--brick); text-shadow: 0 0 12px var(--brick), 0 0 40px var(--brick); }

.blink { animation: blink 1s step-end infinite; font-size: 12px; }
.blink.small { font-size: 9px; }

@keyframes blink { 50% { opacity: 0; } }

.controls p, .credit { font-size: 8px; line-height: 2; color: var(--amber-dim); }

.lb-preview h2 {
  font-size: 12px;
  color: var(--brick);
  text-shadow: 0 0 8px var(--brick);
  margin-bottom: 12px;
}

table {
  border-collapse: collapse;
  font-size: 11px;
  min-width: 380px;
}

td {
  padding: 5px 10px;
  text-shadow: 0 0 5px var(--amber);
}

tr:first-child td { color: #fff27a; text-shadow: 0 0 8px #fff27a; }
tr:nth-child(2) td { color: #cccccc; }
tr:nth-child(3) td { color: #cc8844; }

td.pts { text-align: right; }

#name-entry input {
  background: #000;
  border: 2px solid var(--amber);
  color: var(--amber);
  font-family: inherit;
  font-size: 28px;
  text-align: center;
  width: 120px;
  padding: 10px;
  margin-top: 12px;
  text-transform: uppercase;
  text-shadow: 0 0 8px var(--amber);
  outline: none;
  caret-color: var(--amber);
}

#name-entry p { font-size: 11px; margin-top: 10px; }

td.notice { color: var(--brick); text-shadow: 0 0 6px var(--brick); text-align: center; }
