:root {
  --bg-1: #06111b;
  --bg-2: #091a28;
  --panel: rgba(10, 28, 43, 0.82);
  --panel-2: rgba(13, 35, 52, 0.96);
  --line: rgba(143, 194, 226, 0.12);
  --line-strong: rgba(143, 194, 226, 0.28);
  --text: #eaf6ff;
  --muted: #9fb8c8;
  --accent: #8cf1c9;
  --accent-2: #ffd67a;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius-xl: 30px;
  --radius-lg: 26px;
  --radius-md: 20px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(121, 215, 255, 0.18), transparent 22%),
    radial-gradient(circle at 88% 10%, rgba(140, 241, 201, 0.12), transparent 18%),
    radial-gradient(circle at 50% 100%, rgba(255, 214, 122, 0.08), transparent 22%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  width: 34vw;
  height: 34vw;
  max-width: 420px;
  max-height: 420px;
  border-radius: 50%;
  filter: blur(78px);
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: -110px;
  left: -110px;
  background: #69d1ff;
}

body::after {
  right: -100px;
  bottom: -120px;
  background: #72f2b5;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1400px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 999px;
  background: rgba(7, 21, 32, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.brand {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

.quiz-link,
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  color: #07141d;
  background: linear-gradient(135deg, var(--accent), #c3ffe0);
  box-shadow: 0 14px 30px rgba(140, 241, 201, 0.2);
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.quiz-link:hover,
.back-link:hover {
  transform: translateY(-1px);
}

.gallery-wrap {
  margin-top: 18px;
}

.insect-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.insect-card {
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(143, 194, 226, 0.14);
  background:
    radial-gradient(circle at 50% 40%, rgba(140, 241, 201, 0.08), transparent 34%),
    radial-gradient(circle at 70% 75%, rgba(255, 214, 122, 0.06), transparent 26%),
    linear-gradient(180deg, rgba(12, 31, 47, 0.98), rgba(9, 21, 32, 0.98));
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
  isolation: isolate;
}

.insect-card::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: calc(var(--radius-xl) - 10px);
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.insect-card::after {
  content: "";
  position: absolute;
  inset: auto 12% -18% 12%;
  height: 46%;
  background: radial-gradient(circle, rgba(140, 241, 201, 0.1), transparent 70%);
  filter: blur(18px);
  pointer-events: none;
  opacity: 0.8;
}

.insect-card:hover {
  transform: translateY(-4px);
  border-color: var(--line-strong);
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.36);
}

.insect-card:focus-visible {
  outline: 3px solid rgba(121, 215, 255, 0.5);
  outline-offset: 3px;
}

.insect-card.is-active {
  border-color: rgba(255, 214, 122, 0.74);
  box-shadow: 0 26px 70px rgba(255, 214, 122, 0.18);
}

.insect-card.is-holding .hold-meter::after {
  transform: scaleX(1);
}

.insect-card.is-busy {
  opacity: 0.34;
  cursor: not-allowed;
}

.card-media {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 16px;
}

.card-media img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.28));
  transition: transform 220ms ease, filter 220ms ease;
  transform: translateZ(0);
}

.insect-card:hover .card-media img,
.insect-card.is-active .card-media img {
  transform: scale(1.03) translateY(-2px);
  filter: drop-shadow(0 26px 32px rgba(0, 0, 0, 0.36));
}

.hold-meter {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 18px;
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.hold-meter::after {
  content: "";
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 2s linear;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.quiz-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.quiz-panel {
  width: min(680px, 100%);
  padding: 36px;
  border-radius: 32px;
  text-align: center;
  background: rgba(8, 25, 38, 0.84);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.quiz-panel h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.quiz-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.quiz-actions {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 1100px) {
  .insect-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 18px, 100%);
  }

  .topbar {
    padding: 12px 14px;
  }

  .brand {
    font-size: 0.76rem;
    letter-spacing: 0.14em;
  }

  .insect-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
  }

  .insect-card {
    padding: 10px;
    border-radius: 22px;
  }

  .card-media {
    padding: 10px;
  }

  .hold-meter {
    left: 14px;
    right: 14px;
    bottom: 12px;
  }

  .quiz-panel {
    padding: 28px 22px;
  }
}
