:root {
  --bg: #eef3f8;
  --card: #ffffff;
  --soft: #f6f8fb;
  --ink: #172033;
  --muted: #607089;
  --line: #d9e1ec;
  --accent: #0f9f8e;
  --accent-dark: #087e72;
  --danger: #d94d4d;
  --space: #111827;
  --shadow: 0 18px 45px rgba(33, 45, 70, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: radial-gradient(circle at 12% 0%, rgba(15, 159, 142, 0.14), transparent 30rem),
    linear-gradient(180deg, #f9fbfd, var(--bg));
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(100%, 900px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.topbar {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.home-link,
.modal-link {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.brand span {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
}

.game-card {
  align-self: start;
  padding: 16px;
  border: 1px solid rgba(217, 225, 236, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.game-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.08;
}

.stats {
  display: flex;
  gap: 8px;
}

.stats div {
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  text-align: center;
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.stats strong {
  display: block;
  margin-top: 2px;
  font-size: 1.2rem;
}

.stage {
  position: relative;
  width: min(100%, 420px);
  aspect-ratio: 21 / 31;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #263246;
  border-radius: 8px;
  background: var(--space);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(17, 24, 39, 0.72);
}

.overlay.show {
  display: flex;
}

.modal {
  width: min(100%, 300px);
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  text-align: center;
}

.modal h2 {
  margin-bottom: 8px;
  font-size: 1.55rem;
}

.modal p {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.45;
}

.primary,
.shoot,
.control {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.primary {
  width: 100%;
  min-height: 46px;
  background: var(--accent);
  color: #fff;
}

.modal-link {
  display: inline-block;
  margin-top: 14px;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 10px;
  width: min(100%, 420px);
  margin: 14px auto 0;
}

.control,
.shoot {
  min-height: 52px;
  border: 1px solid var(--line);
  user-select: none;
}

.control {
  background: #e7edf5;
  color: var(--ink);
  font-size: 1.5rem;
}

.shoot {
  background: var(--accent);
  color: #fff;
}

.primary:active,
.shoot:active,
.control:active {
  transform: translateY(1px);
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 540px) {
  .shell {
    padding: 10px;
    gap: 8px;
  }

  .topbar {
    min-height: 38px;
  }

  .brand {
    font-size: 0.82rem;
  }

  .game-card {
    padding: 10px;
  }

  .game-head {
    align-items: stretch;
    margin-bottom: 10px;
  }

  .stats {
    align-self: end;
  }

  .stats div {
    min-width: 64px;
    padding: 7px 8px;
  }

  .stats strong {
    font-size: 1.05rem;
  }

  .stage {
    width: min(100%, 420px);
    min-width: 280px;
  }

  .touch-controls {
    gap: 8px;
    margin-top: 10px;
  }

  .control,
  .shoot {
    min-height: 48px;
  }
}

@media (max-width: 540px) and (max-height: 700px) {
  .stage {
    width: min(100%, 280px);
  }
}

.is-mobile-controls .touch-controls {
  grid-template-columns: 1fr 1fr;
}

.is-mobile-controls .shoot {
  display: none;
}

@media (max-width: 360px) {
  .game-head {
    flex-direction: column;
    gap: 8px;
  }

  .stats {
    width: 100%;
  }

  .stats div {
    flex: 1;
  }

  .stage {
    min-width: 0;
    width: 100%;
  }
}
