:root {
  --bg-top: #0d3d81;
  --bg-mid: #2470c8;
  --bg-bottom: #8ed4ff;
  --panel: rgba(6, 20, 45, 0.78);
  --panel-border: rgba(255, 255, 255, 0.16);
  --text-main: #f4f7fb;
  --text-muted: rgba(244, 247, 251, 0.72);
  --accent: #ffd166;
  --accent-strong: #ffb703;
  --danger: #ff6b6b;
  --shadow: 0 24px 60px rgba(6, 20, 45, 0.4);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Outfit", sans-serif;
  color: var(--text-main);
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.15), transparent 30%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 58%, var(--bg-bottom) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(transparent 0%, rgba(255, 255, 255, 0.06) 100%),
    repeating-linear-gradient(90deg, transparent 0 120px, rgba(255, 255, 255, 0.025) 120px 121px);
  opacity: 0.6;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  width: 100vw;
}

.hud,
.game-layout {
  position: relative;
  z-index: 1;
}

.hud {
  position: absolute;
  inset: 18px 18px auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin: 0;
  max-width: none;
  pointer-events: none;
}

.eyebrow,
.overlay-kicker,
.stat-label {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.brand-block h1,
.overlay-card h2,
.sidebar h2 {
  margin: 0;
  font-family: "Cinzel", serif;
}

.brand-block h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.stats {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex-wrap: wrap;
  justify-content: flex-end;
  pointer-events: auto;
}

.brand-block {
  pointer-events: auto;
}

.stat-card,
.panel,
.floating-panel,
.overlay-card,
.secondary-button,
.primary-button,
.touch-button {
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.stat-card,
.panel,
.floating-panel,
.overlay-card {
  background: var(--panel);
}

.stat-card {
  min-width: 110px;
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-card strong {
  font-size: 1.8rem;
}

.secondary-button,
.primary-button,
.touch-button {
  font: inherit;
  border-radius: 18px;
  cursor: pointer;
}

.secondary-button,
.primary-button {
  padding: 14px 18px;
}

.secondary-button {
  color: var(--text-main);
  background: rgba(7, 32, 72, 0.68);
}

.primary-button {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #3a2400;
  font-weight: 700;
}

.game-layout {
  width: 100vw;
  height: 100vh;
}

.canvas-frame {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  overflow: hidden;
  border: 0;
  background: rgba(6, 20, 45, 0.25);
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  touch-action: none;
}

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

.leaderboard {
  margin: 18px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.leaderboard li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-main);
}

.leaderboard span {
  color: var(--text-muted);
}

.live-score {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 180px;
  padding: 12px 18px;
  border-radius: 18px;
  background: rgba(6, 20, 45, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  pointer-events: none;
}

.live-score-label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.live-score strong {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 24px;
  background: rgba(4, 10, 26, 0.56);
  z-index: 10;
}

.overlay.visible {
  display: grid;
}

.overlay-card {
  width: min(520px, 100%);
  border-radius: 28px;
  padding: 28px;
  text-align: center;
}

.overlay-card h2 {
  margin-top: 10px;
  font-size: clamp(1.9rem, 4vw, 2.6rem);
}

.overlay-card p {
  color: var(--text-muted);
}

.start-instructions {
  margin-top: 18px;
  text-align: left;
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.start-instructions p {
  margin: 0 0 8px;
}

.start-instructions p:last-child {
  margin-bottom: 0;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 18px;
}

.results-panel {
  margin-top: 22px;
  text-align: left;
}

.results-panel h3 {
  margin: 0;
  font-family: "Cinzel", serif;
  font-size: 1.1rem;
}

.save-score-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.save-score-form input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font: inherit;
}

.touch-controls {
  position: absolute;
  inset-inline: 18px;
  bottom: max(22px, env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  z-index: 3;
  pointer-events: auto;
}

.touch-button {
  width: 96px;
  height: 96px;
  font-size: 2rem;
  color: var(--text-main);
  background: rgba(6, 20, 45, 0.68);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.touch-button:active {
  transform: scale(0.96);
}

.hidden {
  display: none;
}

@media (max-width: 1024px) {
  .hud {
    inset: 16px 16px auto 16px;
  }
}

@media (max-width: 720px) {
  .hud {
    inset: max(12px, env(safe-area-inset-top)) 12px auto 12px;
    justify-content: flex-end;
    align-items: stretch;
  }

  .brand-block {
    display: none;
  }

  .live-score {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    min-width: 148px;
    padding: 10px 12px;
    border-radius: 16px;
  }

  .stats {
    width: auto;
    justify-content: flex-end;
    gap: 8px;
  }

  .stat-card,
  .secondary-button {
    flex: 0 0 auto;
  }

  .stat-card {
    min-width: 84px;
    padding: 10px 12px;
  }

  .stat-card strong {
    font-size: 1.25rem;
  }

  .secondary-button {
    padding: 10px 12px;
    font-size: 0.92rem;
  }

  #game-canvas {
    height: 100vh;
  }

  .touch-button {
    width: 112px;
    height: 112px;
    font-size: 2.2rem;
    border-radius: 24px;
  }

  .overlay {
    padding: 16px;
  }

  .overlay-card {
    width: 100%;
    padding: 22px 18px;
    border-radius: 22px;
  }

  .results-panel {
    max-height: 28vh;
    overflow: auto;
  }
}