:root {
  --bg: #050916;
  --panel: rgba(9, 18, 40, 0.88);
  --panel-2: rgba(13, 28, 57, 0.9);
  --text: #f4f8ff;
  --muted: #91a7c7;
  --cyan: #52f7ff;
  --violet: #9a6cff;
  --pink: #ff4fd8;
  --line: rgba(126, 191, 255, 0.2);
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(82, 247, 255, 0.14), transparent 27rem),
    radial-gradient(circle at 90% 24%, rgba(154, 108, 255, 0.16), transparent 30rem),
    linear-gradient(180deg, #07101f 0%, var(--bg) 65%, #03050c 100%);
  padding: 24px;
}

button { font: inherit; }
button:focus-visible { outline: 3px solid white; outline-offset: 3px; }

.shell { width: min(1080px, 100%); margin: 0 auto; }

.hero,
.leaderboard-card {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.hero { margin-bottom: 18px; }

.eyebrow,
.mini-label,
.hud-label {
  margin: 0;
  color: var(--cyan);
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  font-weight: 800;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 8px;
  font-size: clamp(2.5rem, 7vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.055em;
  text-shadow: 0 0 28px rgba(82, 247, 255, 0.24);
}

h2 { margin-bottom: 8px; }
.tagline { max-width: 680px; margin-bottom: 0; color: var(--muted); line-height: 1.5; }

.game-card,
.leaderboard-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 23, 48, 0.92), rgba(5, 10, 24, 0.92));
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.game-card { border-radius: 24px; overflow: hidden; }

.hud {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 7, 18, 0.45);
}

.hud-item { display: flex; flex-direction: column; gap: 4px; }
.hud-center { text-align: center; }
.hud-right { text-align: right; }
.hud strong { font-size: 1.05rem; letter-spacing: 0.06em; }

.game-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #030815;
  touch-action: none;
}

canvas { width: 100%; height: 100%; display: block; }

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 6, 16, 0.58);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.overlay.visible { opacity: 1; pointer-events: auto; }

.overlay-panel,
.dialog-content {
  width: min(470px, 100%);
  border: 1px solid rgba(118, 212, 255, 0.28);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(15, 28, 58, 0.96), rgba(6, 12, 28, 0.96));
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
}

.overlay-panel { padding: 28px; text-align: center; }
.overlay-panel h2 { margin-top: 7px; font-size: clamp(1.7rem, 4vw, 2.5rem); }
.overlay-panel p:not(.mini-label) { color: var(--muted); line-height: 1.55; }

.primary-btn,
.ghost-btn,
.control-btn,
.icon-btn {
  border: 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 120ms ease, filter 120ms ease, background 120ms ease;
}
.primary-btn:hover,
.ghost-btn:hover,
.control-btn:hover,
.icon-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.primary-btn:active,
.ghost-btn:active,
.control-btn:active,
.icon-btn:active { transform: translateY(1px); }

.primary-btn {
  min-width: 150px;
  padding: 13px 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), #65a8ff 52%, var(--violet));
  color: #04101e;
  font-weight: 900;
  letter-spacing: 0.03em;
  box-shadow: 0 0 30px rgba(82, 247, 255, 0.2);
}

.ghost-btn {
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(8, 17, 37, 0.72);
  font-weight: 700;
}

.controls {
  display: grid;
  grid-template-columns: 86px 1fr 86px;
  align-items: center;
  gap: 14px;
  padding: 14px 18px 18px;
}
.controls p { margin: 0; text-align: center; color: var(--muted); font-size: 0.9rem; }
.control-btn {
  min-height: 52px;
  border: 1px solid rgba(82, 247, 255, 0.25);
  border-radius: 15px;
  background: linear-gradient(180deg, rgba(19, 45, 83, 0.96), rgba(8, 20, 44, 0.96));
  font-size: 1.3rem;
  user-select: none;
  -webkit-user-select: none;
}
.mobile-help { display: none; }

.leaderboard-card {
  margin-top: 18px;
  padding: 20px;
  border-radius: 20px;
  align-items: flex-start;
}
.leaderboard-card h2 { margin-top: 5px; margin-bottom: 0; }
#mis-leaderboard { width: min(650px, 100%); }

#howToDialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--text);
}
#howToDialog::backdrop { background: rgba(1, 4, 12, 0.76); backdrop-filter: blur(6px); }
.dialog-content { width: 100%; padding: 24px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.dialog-content p { color: var(--muted); line-height: 1.55; }
.dialog-content strong { color: var(--text); }
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.6rem;
}

@media (max-width: 700px) {
  body { padding: 14px; }
  .hero { align-items: flex-start; flex-direction: column; gap: 14px; }
  .hero .ghost-btn { align-self: flex-start; }
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-center { display: none; }
  .controls { grid-template-columns: 74px 1fr 74px; padding-inline: 12px; }
  .desktop-help { display: none; }
  .mobile-help { display: inline; }
  .leaderboard-card { flex-direction: column; }
  .overlay-panel { padding: 20px; }
}

@media (max-width: 430px) {
  h1 { font-size: 2.8rem; }
  .tagline { font-size: 0.92rem; }
  .hud { padding-inline: 12px; }
  .hud-label { font-size: 0.6rem; }
  .controls { grid-template-columns: 66px 1fr 66px; }
  .control-btn { min-height: 48px; }
}
