:root {
  --bg: #08121f;
  --panel: rgba(9, 21, 35, 0.76);
  --panel-strong: rgba(8, 18, 30, 0.9);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text: #eef6ff;
  --muted: rgba(238, 246, 255, 0.74);
  --cyan: #73e1ff;
  --gold: #ffd36d;
  --green: #5ef5b2;
  --danger: #ff8d8d;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --nav-height: 86px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

body {
  position: relative;
}

button,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

.app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(92, 182, 255, 0.16), transparent 34%),
    linear-gradient(180deg, #7fd1ff 0%, #8fe5ff 18%, #89d99f 18.2%, #78cc89 100%);
}

.main-content {
  position: absolute;
  inset: 0;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  overflow: hidden;
}

.page {
  position: absolute;
  inset: 0;
  transition: opacity 220ms ease, transform 220ms ease;
}

.page.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
}

.map-page {
  overflow: hidden;
  background: linear-gradient(180deg, #7fd1ff 0%, #8fe5ff 22%, #89d99f 22.2%, #78cc89 100%);
}

.collection-page,
.profile-page {
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 18px) 16px calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 18px);
  background:
    radial-gradient(circle at top, rgba(92, 182, 255, 0.14), transparent 28%),
    linear-gradient(180deg, #0d2034 0%, #0b1625 100%);
}

.map-shell {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.map-tiles {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(113, 200, 255, 0.45), rgba(92, 185, 120, 0.35));
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 54%, transparent 0 100px, rgba(0, 0, 0, 0.08) 170px, rgba(0, 0, 0, 0.16) 100%),
    linear-gradient(180deg, rgba(8, 18, 30, 0.16) 0%, rgba(8, 18, 30, 0.06) 22%, rgba(8, 18, 30, 0.26) 100%);
}

.map-page .top-bar,
.map-page .map-status,
.encounter-ui,
.status-banner {
  position: absolute;
  left: 16px;
  right: 16px;
  z-index: 5;
}

.top-bar {
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.brand,
.badge,
.map-status,
.collection-card,
.collection-empty,
.profile-card,
.encounter-card,
.status-banner {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.brand {
  padding: 12px 14px;
  border-radius: 18px;
  min-width: 0;
}

.brand h1,
.page-title {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.brand p,
.page-subtitle,
.section-copy {
  margin: 4px 0 0;
  font-size: 0.82rem;
  line-height: 1.35;
  color: var(--muted);
}

.badges {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.badge {
  min-width: 72px;
  padding: 10px 12px;
  border-radius: 16px;
  text-align: center;
}

.badge strong {
  display: block;
  font-size: 0.95rem;
}

.badge span {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.arena {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.visibility-radius {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 160px;
  height: 160px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(94, 245, 178, 0.18);
  border: 2px solid rgba(94, 245, 178, 0.52);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 0 1px rgba(17, 61, 40, 0.06);
  z-index: 1;
  pointer-events: none;
}

.interaction-radius {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 164, 84, 0.18);
  border: 2px solid rgba(255, 164, 84, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 244, 232, 0.18),
    0 0 22px rgba(255, 164, 84, 0.12);
  z-index: 2;
  pointer-events: none;
}

.player-ring {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 120px;
  height: 120px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(62, 192, 255, 0.3) 0%, rgba(62, 192, 255, 0.14) 42%, transparent 72%);
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 0 0 18px rgba(80, 198, 255, 0.08);
}

.player-marker {
  position: absolute;
  left: 50%;
  top: 54%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffffff 0%, #cff4ff 100%);
  box-shadow:
    0 0 0 7px rgba(47, 174, 235, 0.42),
    0 10px 24px rgba(0, 0, 0, 0.22);
  z-index: 3;
}

.spawn {
  position: absolute;
  width: 72px;
  height: 72px;
  padding: 0;
  transform: translate(-50%, -50%);
  background: transparent;
  z-index: 2;
}

.spawn::before {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.78) 0%, rgba(115, 225, 255, 0.58) 38%, rgba(115, 225, 255, 0) 70%);
  animation: pulse 2.4s ease-in-out infinite;
}

.spawn-core {
  position: absolute;
  inset: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(211, 245, 255, 0.88));
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.18);
  font-size: 1rem;
  font-weight: 700;
  color: #06273b;
}

.spawn-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 4px);
  transform: translateX(-50%);
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(7, 17, 28, 0.72);
  color: #f7fbff;
  font-size: 0.72rem;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.16);
}

.spawn[data-rarity="rare"] .spawn-core {
  background: linear-gradient(180deg, #fff6cc, #ffe287);
}

.collection-card,
.collection-empty,
.profile-card {
  border-radius: 24px;
  padding: 18px;
}

.section-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.profile-topic-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.topic-button {
  padding: 11px 18px;
  font-weight: 700;
  color: var(--text);
  background: rgba(8, 18, 30, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
}

.topic-button.active {
  color: #072030;
  background: linear-gradient(180deg, #c8f6ff 0%, var(--cyan) 100%);
}

.map-status {
  top: calc(env(safe-area-inset-top, 0px) + 104px);
  margin: 0 auto;
  max-width: min(100%, 420px);
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  text-align: center;
}

.map-status.error,
.status-banner.error {
  color: #fff1f1;
  border-color: rgba(255, 141, 141, 0.45);
  background: rgba(49, 10, 18, 0.78);
}

.page-stack {
  display: grid;
  gap: 14px;
}

.collection-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.collection-tab {
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.collection-tab.active {
  color: #082131;
  background: linear-gradient(180deg, #cbf6ff 0%, var(--cyan) 100%);
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.collection-card {
  overflow: hidden;
  padding: 0;
  border-color: var(--item-soft-strong, var(--panel-border));
  background: var(--item-panel, var(--panel));
}

.collection-art {
  display: grid;
  place-items: center;
  height: 140px;
  background:
    radial-gradient(circle at top, var(--item-soft-strong, rgba(115, 225, 255, 0.22)), transparent 48%),
    linear-gradient(180deg, color-mix(in srgb, var(--item-accent, #73e1ff) 42%, rgba(37, 73, 112, 0.9)), rgba(12, 24, 39, 0.92));
}

.collection-art img {
  max-width: 150px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.3));
}

.collection-copy {
  padding: 14px 14px 16px;
}

.collection-name {
  margin: 0;
  font-size: 0.98rem;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  color: #dff6ff;
  background: rgba(115, 225, 255, 0.14);
  border: 1px solid rgba(115, 225, 255, 0.18);
}

.collection-card .tag,
.wrong-question-card .tag {
  background: var(--item-soft, rgba(115, 225, 255, 0.14));
  border-color: var(--item-soft-strong, rgba(115, 225, 255, 0.18));
}

.collection-empty {
  text-align: center;
  padding: 28px 20px;
}

.collection-empty strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.wrong-question-list {
  display: grid;
  gap: 14px;
}

.wrong-question-card {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: var(--item-panel, var(--panel));
  border-color: var(--item-soft-strong, var(--panel-border));
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.wrong-question-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.4;
}

.wrong-question-card .tag-row {
  margin-top: 12px;
}

.profile-card .current-topic {
  display: inline-flex;
  align-items: center;
  margin-top: 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 211, 109, 0.16);
  border: 1px solid rgba(255, 211, 109, 0.24);
  color: #ffeeb7;
  font-size: 0.82rem;
  font-weight: 700;
}

.topic-input-row {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.topic-input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

.topic-input::placeholder {
  color: rgba(238, 246, 255, 0.48);
}

.profile-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.bottom-nav {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  z-index: 12;
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(7, 17, 29, 0.84);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.3);
}

.nav-item {
  flex: 1;
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 10px 6px;
  border-radius: 18px;
  background: transparent;
  color: rgba(238, 246, 255, 0.72);
}

.nav-item.active {
  color: #092233;
  background: linear-gradient(180deg, #cbf6ff 0%, var(--cyan) 100%);
}

.nav-icon {
  font-size: 1rem;
  font-weight: 700;
}

.nav-label {
  font-size: 0.74rem;
  font-weight: 700;
}

.encounter-view {
  position: absolute;
  inset: 0;
  z-index: 15;
  background:
    radial-gradient(circle at top, rgba(38, 86, 134, 0.28), transparent 40%),
    #000;
}

.encounter-view.hidden {
  display: none !important;
}

video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.video-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(5, 14, 24, 0.52) 0%, rgba(5, 14, 24, 0.08) 26%, rgba(5, 14, 24, 0.18) 72%, rgba(5, 14, 24, 0.68) 100%);
  z-index: 1;
  pointer-events: none;
}

.encounter-ui,
.status-banner {
  left: 16px;
  right: 16px;
}

.encounter-ui {
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  z-index: 4;
}

.encounter-card {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 18px;
}

.encounter-card h2 {
  margin: 0;
  font-size: 1rem;
}

.encounter-card p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.action-chip,
.primary-button,
.secondary-button {
  box-shadow: var(--shadow);
}

.action-chip {
  padding: 12px 16px;
  color: var(--text);
  background: rgba(6, 15, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
}

.creature-stage {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18vh);
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  user-select: none;
}

.creature-image {
  width: min(48vw, 240px);
  height: auto;
  display: block;
  filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.34));
  animation: creature-bob 2.2s ease-in-out infinite;
}

.creature-stage.captured .creature-image {
  animation: capture-exit 1.3s cubic-bezier(0.2, 0.78, 0.2, 1) forwards;
}

.creature-stage.escaped .creature-image {
  animation: escape-exit 0.95s cubic-bezier(0.22, 0.82, 0.22, 1) forwards;
}

.encounter-controls {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.primary-button {
  min-width: min(78vw, 300px);
  padding: 15px 26px;
  font-weight: 700;
  color: #082131;
  background: linear-gradient(180deg, #fff0a5 0%, var(--gold) 100%);
}

.secondary-button {
  padding: 12px 22px;
  font-weight: 700;
  color: var(--text);
  background: rgba(8, 18, 30, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
}

.status-banner {
  bottom: calc(env(safe-area-inset-bottom, 0px) + 110px);
  padding: 12px 14px;
  border-radius: 16px;
  text-align: center;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--muted);
  z-index: 4;
}

.quiz-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 24px 16px calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: rgba(4, 10, 18, 0.42);
  backdrop-filter: blur(8px);
}

.quiz-card {
  width: min(100%, 420px);
  border-radius: 26px;
  padding: 20px 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 19, 31, 0.92);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.34);
}

.quiz-kicker {
  margin: 0 0 8px;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
}

.quiz-question {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.quiz-help {
  margin: 10px 0 0;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

.quiz-options {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.quiz-option {
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.correct {
  color: #041d12;
  background: linear-gradient(180deg, #bff7dc 0%, var(--green) 100%);
  border-color: rgba(94, 245, 178, 0.92);
}

.quiz-option.incorrect {
  color: #fff2f2;
  background: linear-gradient(180deg, #7d2430 0%, #5a111b 100%);
  border-color: rgba(255, 141, 141, 0.86);
}

.quiz-option.dimmed {
  opacity: 0.55;
}

.quiz-result {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.4;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.quiz-result.success {
  color: #dfffee;
  background: rgba(15, 84, 55, 0.64);
  border-color: rgba(94, 245, 178, 0.46);
}

.quiz-result.failure {
  color: #fff0f0;
  background: rgba(92, 17, 28, 0.72);
  border-color: rgba(255, 141, 141, 0.46);
}

.capture-flash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.88);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
  transition: opacity 120ms ease;
}

.capture-flash.active {
  opacity: 1;
}

@keyframes capture-exit {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  55% {
    transform: translateY(-18px) rotate(420deg) scale(0.94);
    opacity: 1;
  }
  100% {
    transform: translateY(55vh) rotate(900deg) scale(0.56);
    opacity: 0;
  }
}

@keyframes escape-exit {
  0% {
    transform: translateX(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(62vw) scale(0.92);
    opacity: 0;
  }
}

@keyframes creature-bob {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-14px);
  }
}

.hidden {
  display: none !important;
}

@keyframes pulse {
  0%, 100% {
    transform: scale(0.92);
    opacity: 0.62;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

@media (max-width: 460px) {
  .map-page .top-bar,
  .map-page .map-status,
  .encounter-ui,
  .status-banner {
    left: 12px;
    right: 12px;
  }

  .top-bar,
  .encounter-ui {
    gap: 8px;
  }

  .badge {
    min-width: 62px;
    padding: 9px 10px;
  }

  .collection-grid {
    grid-template-columns: 1fr;
  }

  .creature-stage {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 21vh);
  }

  .creature-image {
    width: min(58vw, 220px);
  }
}
