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

body {
  background: #01120b;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e8eaed;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#back-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-weight: 700;
  z-index: 40;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(95, 99, 104, 0.7);
  transition: background 0.2s;
  line-height: 1;
}

#back-btn:hover {
  background: #80868b;
}

#game-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  top: 14px;
  left: 18px;
  z-index: 10;
  pointer-events: none;
}

.hud-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

#score {
  font-size: 42px;
  font-weight: 800;
  color: #39ff88;
  text-shadow: 0 0 20px rgba(57, 255, 136, 0.55);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.unit {
  font-size: 18px;
  font-weight: 700;
  color: rgba(57, 255, 136, 0.65);
}

.hud-row.sub {
  margin-top: 4px;
  gap: 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7fa792;
}

#level {
  color: #39ff88;
}

/* ---------- Level banner ---------- */

#level-banner {
  position: fixed;
  top: 32%;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #39ff88;
  text-shadow: 0 0 26px rgba(57, 255, 136, 0.6);
  z-index: 12;
  pointer-events: none;
  animation: banner 1.4s ease-out forwards;
}

@keyframes banner {
  0%   { opacity: 0; transform: scale(0.85); }
  18%  { opacity: 1; transform: scale(1); }
  70%  { opacity: 1; }
  100% { opacity: 0; transform: scale(1.08); }
}

/* ---------- Overlays ---------- */

#start-screen,
#pause-screen,
#gameover-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  background: rgba(1, 10, 6, 0.86);
  backdrop-filter: blur(3px);
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

h1 {
  font-size: 68px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #39ff88;
  text-shadow: 0 0 32px rgba(57, 255, 136, 0.55);
}

h2 {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #39ff88;
}

#start-screen p,
#gameover-screen p {
  max-width: 460px;
  font-size: 15px;
  line-height: 1.6;
  color: #9dbfae;
}

#go-detail {
  font-size: 30px;
  font-weight: 800;
  color: #e8eaed;
}

.best-line {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7fa792;
}

button {
  margin-top: 6px;
  padding: 14px 34px;
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #01120b;
  background: #39ff88;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 0 26px rgba(57, 255, 136, 0.35);
  transition: transform 0.15s, box-shadow 0.15s;
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 34px rgba(57, 255, 136, 0.55);
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  color: #7fa792;
}

.legend b {
  color: #cfe9dc;
}

.hazards {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7fa792;
}

.hz {
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: 10px;
  vertical-align: -3px;
  border: 2px solid #39ff88;
  background: #000;
}

.hz.mover {
  border-color: #b7ffd4;
  border-radius: 3px;
}

.hz.tunnel {
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  background: #000;
}

.hz.gap {
  border-style: dashed;
  background: transparent;
}

.hidden {
  display: none !important;
}

@media (max-width: 620px) {
  h1 { font-size: 46px; }
  h2 { font-size: 30px; }
  #score { font-size: 34px; }
  .hud-row.sub { font-size: 11px; gap: 10px; }
  #level-banner { font-size: 30px; }
  #start-screen p, #gameover-screen p { font-size: 14px; }
}

/* Footer link back to the arcade (internal linking / SEO) */
.site-footer {
  position: fixed;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 12px;
  line-height: 1;
  pointer-events: auto;
}
.site-footer a {
  color: #9aa0a6;
  text-decoration: none;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.site-footer a:hover { opacity: 1; text-decoration: underline; }

/* Page heading (SEO + screen readers) */
.page-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #e8eaed;
}

@media (max-width: 700px) {
  /* keep clear of the on-screen controls, which sit bottom-centre */
  .site-footer {
    left: 10px;
    bottom: 8px;
    transform: none;
    font-size: 11px;
  }
}
