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

html, body {
  height: 100%;
  overflow: hidden;
  background: #0a0e1a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#camera {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

#sky-fallback {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, #1b2b4d 0%, #3d5a8a 45%, #b98a5e 85%, #6b4a3a 100%);
}
#sky-fallback[hidden] { display: none; }

#gl {
  position: fixed;
  inset: 0;
  z-index: 1;
}

#radar { position: fixed; inset: 0; z-index: 2; pointer-events: none; }

#damage-flash {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255,60,0,.25) 0%, rgba(255,30,0,.65) 100%);
}
#damage-flash.flash { animation: damage-flash .7s ease-out; }
@keyframes damage-flash { 0% { opacity: 1 } 100% { opacity: 0 } }
.radar-arrow {
  position: absolute;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  filter: drop-shadow(0 0 6px rgba(0,0,0,.6));
  transition: opacity .2s;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 12px);
  left: 12px; right: 12px;
  display: flex;
  gap: 8px;
  z-index: 5;
  align-items: center;
}
#hud[hidden] { display: none; }

.hud-pill {
  background: rgba(10, 14, 26, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: #fff;
}
.hud-btn { margin-left: auto; }
button.hud-pill { font-family: inherit; }

.orb-icon {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #dffaff, #35d6ff 55%, #0a6d9e);
  box-shadow: 0 0 8px rgba(53, 214, 255, .8);
  display: inline-block;
}

#hint {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 36px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,.85);
  background: rgba(10, 14, 26, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  animation: hint-bob 2.2s ease-in-out infinite;
  pointer-events: none;
  white-space: nowrap;
}
#hint[hidden] { display: none; }
@keyframes hint-bob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-8px); } }

#toast {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid rgba(255,255,255,.15);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
#toast[hidden] { display: none; }

/* ---------- Start screen ---------- */
#start-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(80, 40, 160, .35), transparent 60%),
    linear-gradient(180deg, #0a0e1a 0%, #131c33 60%, #0a0e1a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
#start-screen[hidden] { display: none; }

.start-emblem {
  font-size: 84px;
  filter: drop-shadow(0 0 30px rgba(140, 90, 255, .7));
  animation: emblem-float 3.5s ease-in-out infinite;
}
@keyframes emblem-float { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-14px) } }

#start-screen h1 {
  font-size: 42px;
  letter-spacing: .02em;
  margin: 12px 0 10px;
  background: linear-gradient(90deg, #ffd76a, #ff8a5c, #c86bff);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline { color: rgba(255,255,255,.75); font-size: 16px; line-height: 1.5; margin-bottom: 32px; }

#start-btn {
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  color: #14060a;
  background: linear-gradient(135deg, #ffd76a, #ff8a5c);
  border: none;
  border-radius: 999px;
  padding: 16px 44px;
  cursor: pointer;
  box-shadow: 0 6px 30px rgba(255, 150, 90, .45);
}
#start-btn:active { transform: scale(.96); }

.fineprint { margin-top: 18px; font-size: 12px; color: rgba(255,255,255,.4); }

/* ---------- Catch card ---------- */
#catch-card {
  position: fixed;
  inset: 0;
  z-index: 9;
  background: rgba(5, 8, 16, .72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#catch-card[hidden] { display: none; }

.card-inner {
  position: relative;
  width: min(340px, 88vw);
  background: linear-gradient(180deg, #182338, #0d1424);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 24px;
  padding: 32px 24px 28px;
  text-align: center;
  animation: card-pop .45s cubic-bezier(.2, 1.4, .4, 1);
  overflow: hidden;
}
@keyframes card-pop { from { transform: scale(.6); opacity: 0 } to { transform: scale(1); opacity: 1 } }

.card-glow {
  position: absolute;
  top: -60px; left: 50%;
  width: 260px; height: 260px;
  transform: translateX(-50%);
  border-radius: 50%;
  filter: blur(50px);
  opacity: .5;
  pointer-events: none;
}

.card-dragon { position: relative; height: 110px; display: flex; align-items: center; justify-content: center; }
.card-dragon svg { height: 100px; filter: drop-shadow(0 4px 18px rgba(0,0,0,.5)); }

#catch-card h2 { font-size: 26px; margin: 10px 0 4px; }
#card-name { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
#card-meta { font-size: 13px; color: rgba(255,255,255,.65); margin-bottom: 22px; }

#card-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  color: #0a0e1a;
  background: #fff;
  border: none;
  border-radius: 999px;
  padding: 13px 34px;
  cursor: pointer;
}

.rarity-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 6px;
}

/* ---------- Dex panel ---------- */
#dex-panel {
  position: fixed;
  inset: 0;
  z-index: 8;
  background: rgba(8, 11, 20, .96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px 24px;
  overflow-y: auto;
  touch-action: pan-y;
}
#dex-panel[hidden] { display: none; }

.dex-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.dex-header h2 { font-size: 24px; }
#dex-close {
  font-family: inherit;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
}

#dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.dex-card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 14px 10px 12px;
  text-align: center;
}
.dex-card svg { height: 58px; margin-bottom: 6px; }
.dex-card .dname { font-size: 14px; font-weight: 700; }
.dex-card .dmeta { font-size: 11px; color: rgba(255,255,255,.55); margin-top: 2px; }

#dex-empty {
  text-align: center;
  color: rgba(255,255,255,.45);
  font-size: 15px;
  line-height: 1.6;
  margin-top: 26vh;
}
#dex-empty.gone { display: none; }
