:root {
  --bg: #0a0a12;
  --panel: #12121f;
  --accent: #ffd54f;
  --accent-dim: #c9a227;
  --text: #f5f5f7;
  --muted: #8b8b9e;
  --wall: #2f6bff;
  --wall-glow: #5b8cff;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at top, #1a1030 0%, var(--bg) 55%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
}

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--panel);
  border: 1px solid rgba(255, 213, 79, 0.15);
  border-radius: 12px;
  padding: 0.75rem 1rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.brand-name {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.brand-tag {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.5rem;
  font-variant-numeric: tabular-nums;
}

.hud-item .label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.hud-item span:last-child {
  font-weight: 700;
  font-size: 1.1rem;
}

#lives {
  letter-spacing: 0.15em;
  color: var(--accent);
}

.stage-wrap {
  position: relative;
  display: flex;
  justify-content: center;
}

#game {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  border-radius: 8px;
  background: #000;
  box-shadow:
    0 0 0 2px rgba(47, 107, 255, 0.35),
    0 12px 40px rgba(0, 0, 0, 0.55);
  touch-action: none;
}

.message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0.65rem 1rem;
  background: rgba(0, 0, 0, 0.82);
  border: 1px solid rgba(255, 213, 79, 0.35);
  border-radius: 999px;
  font-size: 0.95rem;
  text-align: center;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  z-index: 2;
}

.message.hidden {
  pointer-events: none;
}

.touch-controls {
  display: none;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.25rem 0.5rem 0.5rem;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 3.25rem);
  grid-template-rows: repeat(3, 3.25rem);
  gap: 0.35rem;
}

.ctrl-up { grid-column: 2; grid-row: 1; }
.ctrl-left { grid-column: 1; grid-row: 2; }
.ctrl-down { grid-column: 2; grid-row: 3; }
.ctrl-right { grid-column: 3; grid-row: 2; }

.ctrl-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 3.25rem;
  min-height: 3.25rem;
  border: 1px solid rgba(255, 213, 79, 0.35);
  border-radius: 12px;
  background: rgba(18, 18, 31, 0.92);
  color: var(--accent);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active,
.ctrl-btn.is-active {
  background: rgba(255, 213, 79, 0.22);
  border-color: var(--accent);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ctrl-action {
  font-size: 1rem;
}

.footer-desktop {
  display: block;
}

.footer-mobile {
  display: none;
}

.message.hidden {
  opacity: 0;
  transition: opacity 0.25s ease;
}

.footer {
  margin-top: auto;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
}

.footer a {
  color: var(--accent-dim);
  text-decoration: none;
}

.footer a:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 480px), (hover: none) and (pointer: coarse) {
  .page {
    padding: 0.5rem;
  }

  .message {
    font-size: 0.8rem;
    white-space: normal;
    max-width: 90%;
  }

  .touch-controls {
    display: flex;
  }

  .footer-desktop {
    display: none;
  }

  .footer-mobile {
    display: block;
  }
}
