:root {
  --green-0: #0b3d2e;
  --green-1: #0f5135;
  --green-2: #157a48;
  --green-3: #2faa63;
  --ink: #0a1410;
  --paper: #f5f8f4;
  --gold: #ffd24a;
  --gold-deep: #f2a93b;
  --line: rgba(255, 255, 255, 0.85);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: radial-gradient(120% 90% at 50% 0%, #14243a 0%, #0a1622 55%, #060d15 100%);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  color: var(--paper);
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  background: #0a1622;
  box-shadow: var(--shadow);
}

/* ---------- HUD ---------- */
#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(180deg, rgba(7, 18, 14, 0.95), rgba(7, 18, 14, 0.6));
  z-index: 5;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-mark { font-size: 22px; }
.brand-name {
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: 1.5px;
  font-size: 22px;
  line-height: 1;
}
.brand-name b { color: var(--gold); font-weight: 400; }

.hud-stats { display: flex; gap: 8px; }
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 46px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat-label { font-size: 9px; letter-spacing: 1px; opacity: 0.6; font-weight: 600; }
.stat-value { font-size: 17px; font-weight: 800; line-height: 1.1; }
.stat.tier { min-width: 70px; }
.stat.tier .stat-value { font-size: 11px; }
.stat.tier.pro {
  background: linear-gradient(135deg, rgba(255, 210, 74, 0.22), rgba(242, 169, 59, 0.12));
  border-color: rgba(255, 210, 74, 0.5);
}
.stat.tier.pro .stat-value { color: var(--gold); }

/* ---------- Stage / canvas ---------- */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
}
#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#game.dragging { cursor: grabbing; }

.banner {
  position: absolute;
  top: 16%;
  left: 50%;
  translate: -50% 0;
  font-family: "Bebas Neue", sans-serif;
  font-size: 64px;
  letter-spacing: 2px;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  transition: opacity 0.18s ease;
  z-index: 4;
}
.banner.show { animation: pop 1.1s ease forwards; }
.banner.goal { color: var(--gold); }
.banner.save { color: #ff6b6b; }
.banner.miss { color: #9fb6ff; }
@keyframes pop {
  0% { opacity: 0; scale: 0.5; }
  18% { opacity: 1; scale: 1.08; }
  70% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: 1; }
}

.hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  translate: -50% 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 4;
}
.hint.fade { opacity: 0; }

/* ---------- Controls ---------- */
#controls {
  display: flex;
  gap: 8px;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(7, 18, 14, 0.96), rgba(7, 18, 14, 0.5));
  z-index: 5;
}
.ctrl-btn {
  flex: 1;
  padding: 13px 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--paper);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.2s ease, border 0.2s ease;
}
.ctrl-btn:active { transform: scale(0.96); }
.ctrl-btn.primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  color: #2b1d00;
  border-color: transparent;
}
.ctrl-btn.ghost { flex: 0 0 84px; background: transparent; opacity: 0.8; }
.ctrl-btn.active {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* ---------- Paywall modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 8, 0.72);
  backdrop-filter: blur(8px);
  z-index: 50;
  animation: fade 0.2s ease;
}
.modal-overlay.hidden { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%;
  max-width: 380px;
  padding: 26px 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, #122b20, #0c1f17);
  border: 1px solid rgba(255, 210, 74, 0.35);
  box-shadow: var(--shadow);
  text-align: center;
  animation: rise 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes rise { from { transform: translateY(20px) scale(0.96); opacity: 0; } }
.modal-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--gold);
  background: rgba(255, 210, 74, 0.12);
  border: 1px solid rgba(255, 210, 74, 0.35);
  margin-bottom: 12px;
}
.modal h2 { font-size: 22px; margin-bottom: 8px; }
.modal p { font-size: 14px; line-height: 1.5; opacity: 0.85; margin-bottom: 16px; }
.modal p b { color: var(--gold); }
.perks { list-style: none; text-align: left; margin: 0 auto 18px; max-width: 280px; }
.perks li { font-size: 14px; padding: 6px 0; opacity: 0.92; }
.price {
  font-family: "Bebas Neue", sans-serif;
  font-size: 40px;
  color: var(--gold);
  margin-bottom: 16px;
}
.price span { font-family: "Inter"; font-size: 13px; opacity: 0.6; }
.modal-actions { display: flex; flex-direction: column; gap: 8px; }
.modal-actions .ctrl-btn { flex: 1; }

@media (max-width: 380px) {
  .hud-stats .stat:not(.tier) { min-width: 40px; padding: 5px 5px; }
  .banner { font-size: 48px; }
}
