﻿:root {
  --bg: #eef6f0;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #18342b;
  --accent: #2f8f5b;
  --accent-2: #f2b84b;
  --danger: #d66b6b;
  --focus: #2f8f5b;
  --shadow: 0 8px 20px rgba(18, 37, 31, 0.18);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", "Noto Sans", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: radial-gradient(circle at 20% 10%, #f8fff5, #d9f0de 45%, #c4e7d0);
}

button {
  font: inherit;
  color: inherit;
}

button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.app {
  width: min(1100px, 96vw);
  margin: 18px auto;
  min-height: calc(100vh - 36px);
  position: relative;
}

.screen {
  display: none;
  min-height: calc(100vh - 36px);
  animation: fadeIn 0.28s ease;
}

.screen.active {
  display: flex;
}

.panel {
  width: 100%;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: blur(4px);
}

.loading-panel,
.home-panel {
  max-width: 560px;
  margin: auto;
  text-align: center;
  padding: 22px;
}

.game-title {
  margin: 0;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.subtitle {
  margin: 10px 0;
  color: #355e4f;
}

.home-actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  border: 0;
  background: #fff;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: inset 0 0 0 1px rgba(27, 68, 50, 0.12);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(27, 68, 50, 0.2), 0 6px 16px rgba(20, 50, 39, 0.15);
}

.btn.primary {
  background: linear-gradient(180deg, #44a16d, #2f8f5b);
  color: #fff;
}

.btn.small {
  padding: 8px 10px;
  font-size: 0.95rem;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions,
.hud {
  display: flex;
  gap: 8px;
  align-items: center;
}

.map-panel,
.museum-panel,
.game-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.map-board {
  min-height: 70vh;
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(240, 255, 244, 0.6)),
    center / cover no-repeat;
  position: relative;
  overflow: hidden;
}

.map-stage {
  position: absolute;
  width: 96px;
  border-radius: 16px;
  border: 0;
  padding: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.map-stage.locked {
  opacity: 0.6;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.path-dot {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px solid #69a47f;
}

.game-area {
  height: min(68vh, 540px);
  border-radius: 16px;
  overflow: hidden;
  position: relative;
  background: #dff2e6;
  box-shadow: inset 0 0 0 1px rgba(16, 48, 34, 0.1);
}

.game-area.paused-for-modal {
  pointer-events: none;
}

.game-bg,
.bug-layer,
.hide-layer,
.race-layer,
.boss-layer,
.ram-layer {
  position: absolute;
  inset: 0;
}

.game-bg {
  background-size: cover;
  background-position: center;
  pointer-events: none;
  z-index: 1;
}

.bug-layer {
  pointer-events: auto;
  z-index: 5;
}

.stage-message {
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 600;
  pointer-events: none;
  z-index: 15;
}

.ram-sprite,
.sprite-button img,
.placeholder-asset {
  user-select: none;
  -webkit-user-drag: none;
}

.ram-sprite {
  position: absolute;
  width: clamp(90px, 15vw, 150px);
  bottom: 10px;
  left: 14px;
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.24));
}

.ram-layer {
  pointer-events: none;
  z-index: 2;
}

.sprite-button {
  position: absolute;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  animation: floaty 1.8s ease-in-out infinite;
  pointer-events: auto;
  touch-action: manipulation;
  z-index: 20;
}

.sprite-button.wrong-catch {
  animation: wrongCatchShake 0.18s linear 2;
}

.sprite-button img,
.asset-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.placeholder-asset {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: repeating-linear-gradient(45deg, #f2d9a4, #f2d9a4 10px, #f9efce 10px, #f9efce 20px);
  color: #4b3f2b;
  font-size: 0.72rem;
  text-align: center;
  padding: 6px;
}

.tap-pad {
  display: none;
}

.race-layer,
.hide-layer,
.boss-layer {
  pointer-events: none;
  z-index: 8;
}

.race-ui,
.hide-ui,
.boss-ui {
  pointer-events: auto;
}

.race-track {
  position: absolute;
  left: 5%;
  width: 90%;
  top: 42%;
  height: 18px;
  background: rgba(255, 255, 255, 0.74);
  border-radius: 999px;
}

.race-track-real {
  top: 24%;
  height: 52%;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(242, 255, 246, 0.9), rgba(221, 242, 229, 0.95));
  border: 1px solid rgba(47, 143, 91, 0.22);
}

.race-callout {
  position: absolute;
  left: 50%;
  top: 6%;
  transform: translateX(-50%);
  font-weight: 800;
  font-size: clamp(1rem, 2.8vw, 1.5rem);
  color: #1f7247;
  text-shadow: 0 1px 0 #fff;
}

.race-lane {
  position: absolute;
  left: 3%;
  width: 94%;
  height: 36%;
  border-radius: 12px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.68),
    rgba(255, 255, 255, 0.68) 24px,
    rgba(234, 245, 238, 0.65) 24px,
    rgba(234, 245, 238, 0.65) 48px
  );
  box-shadow: inset 0 0 0 1px rgba(38, 94, 66, 0.14);
}

.race-lane-ram {
  top: 10%;
}

.race-lane-grass {
  bottom: 10%;
}

.lane-label {
  position: absolute;
  left: 6px;
  top: -24px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #245740;
}

.race-finish-line {
  position: absolute;
  right: 2%;
  top: 9%;
  width: 8px;
  height: 82%;
  background: repeating-linear-gradient(
    180deg,
    #fff,
    #fff 8px,
    #1a1a1a 8px,
    #1a1a1a 16px
  );
  border-radius: 4px;
  opacity: 0.8;
}

.race-marker {
  position: absolute;
  top: 50%;
  left: 2%;
  width: 54px;
  height: 54px;
  transform: translate(-50%, -50%);
  transition: left 0.08s linear, transform 0.08s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
}

.race-marker.boost {
  transform: translate(-50%, -50%) scale(1.08);
}

.race-marker .asset-image {
  width: 100%;
  height: 100%;
}

.race-stats {
  position: absolute;
  left: 50%;
  bottom: 5%;
  transform: translateX(-50%);
  width: min(560px, 92%);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 700;
}

.target-banner {
  position: absolute;
  left: 50%;
  top: 16%;
  transform: translateX(-50%);
  z-index: 45;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  box-shadow: 0 10px 20px rgba(16, 57, 37, 0.2);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  color: #1d6a42;
  animation: targetBannerIn 1.8s ease forwards;
}

.target-banner-icon {
  width: 34px;
  height: 34px;
}

.target-badge {
  position: absolute;
  top: 58px;
  right: 10px;
  z-index: 38;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(44, 117, 75, 0.25);
  border-radius: 12px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 700;
  color: #245740;
}

.target-badge-icon {
  width: 24px;
  height: 24px;
}

.stage-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 50;
  background: rgba(31, 51, 43, 0.92);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.86rem;
  animation: toastRise 0.9s ease forwards;
  pointer-events: none;
}

.jump-race-ui {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.jump-race-banner {
  position: absolute;
  top: 8%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  color: #1f7247;
}

.jump-race-track {
  position: absolute;
  inset: 20% 4% 18%;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(247, 255, 249, 0.92), rgba(226, 244, 233, 0.95));
  border: 1px solid rgba(51, 126, 84, 0.18);
  overflow: hidden;
}

.jump-ground-line {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  height: 4px;
  background: linear-gradient(90deg, #3e875f, #52a270);
}

.jump-runner {
  position: absolute;
  width: clamp(72px, 10vw, 108px);
  height: clamp(72px, 10vw, 108px);
  bottom: 8px;
  transition: transform 0.1s ease;
  z-index: 8;
}

.runner-ram {
  left: 16%;
}

.runner-grass {
  left: 34%;
}

.jump-runner.hit {
  animation: answerShake 0.25s ease;
}

.jump-obstacle-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.jump-obstacle {
  position: absolute;
  bottom: 8px;
  border-radius: 10px 10px 3px 3px;
  background: linear-gradient(180deg, #916c49, #6f4f34);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
}

.jump-race-progress {
  position: absolute;
  left: 50%;
  bottom: 3%;
  transform: translateX(-50%);
  width: min(560px, 92%);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.jump-boost-pop {
  position: absolute;
  transform: translate(-50%, 0);
  color: #2f8f5b;
  font-weight: 800;
  font-size: 0.82rem;
  text-shadow: 0 1px 0 #fff;
  pointer-events: none;
  animation: jumpBoostRise 0.68s ease forwards;
  z-index: 22;
}

.jump-race-bars {
  position: absolute;
  left: 50%;
  bottom: 11%;
  transform: translateX(-50%);
  width: min(560px, 92%);
  display: grid;
  gap: 6px;
}

.jump-race-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(34, 79, 55, 0.16);
  overflow: hidden;
}

.jump-race-fill {
  height: 100%;
  width: 0;
  transition: width 0.12s linear;
}

.ram-fill {
  background: linear-gradient(90deg, #2f8f5b, #52b77b);
}

.grass-fill {
  background: linear-gradient(90deg, #d0a044, #f0c364);
}

.race-runner,
.race-target {
  position: absolute;
  top: calc(42% - 24px);
  width: 46px;
  height: 46px;
}

.race-runner {
  left: 5%;
}

.race-target {
  left: calc(95% - 46px);
}

.race-btn {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

.hide-object {
  position: absolute;
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 35% 20%, #9cc68f, #69935f);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow);
}

.hide-rock {
  position: absolute;
  width: clamp(72px, 11vw, 118px);
  height: clamp(52px, 8vw, 82px);
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 48% 52% 46% 54%;
  background: radial-gradient(circle at 32% 26%, #c7b08f, #8e745a 72%);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.26);
  cursor: pointer;
  z-index: 20;
}

.hide-rock-ridge {
  position: absolute;
  width: 60%;
  height: 12%;
  left: 20%;
  top: 24%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.hide-rock.lifted {
  transform: translate(-50%, -66%) rotate(-8deg);
  transition: transform 0.2s ease;
}

.hide-rock.wrong {
  animation: wrongCatchShake 0.22s linear 2;
}

.hide-spider {
  position: absolute;
  width: clamp(64px, 8vw, 100px);
  height: clamp(64px, 8vw, 100px);
  transform: translate(-50%, -28%);
  z-index: 12;
  pointer-events: none;
}

.boss-bug {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translateX(-50%);
  width: clamp(130px, 18vw, 220px);
  height: clamp(130px, 18vw, 220px);
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, #2e2e2e, #1a1a1a 70%);
  border: 8px solid #f2b84b;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.38);
}

.boss-bug::before,
.boss-bug::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  top: 34%;
}

.boss-bug::before {
  left: 24%;
}

.boss-bug::after {
  right: 24%;
}

.boss-hit {
  position: absolute;
  top: 72%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: auto;
}

.boss-hit-target {
  position: absolute;
  width: clamp(120px, 17vw, 190px);
  height: clamp(120px, 17vw, 190px);
  transform: translate(-50%, -50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  z-index: 10;
}

.museum-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.museum-card {
  border: 0;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 8px;
  text-align: center;
  min-height: 170px;
  position: relative;
}

.museum-card.locked {
  opacity: 0.5;
}

.badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.72rem;
  background: #ffed94;
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
}

.modal-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.modal-layer.active {
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.35);
}

.modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 92vw);
  background: #fff;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 20px 36px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
}

.answer-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.answer-btn {
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 8px;
  background: #f7fbf8;
  position: relative;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.16s ease;
}

.answer-btn:hover,
.answer-btn:focus-visible {
  border-color: #6fb68c;
  transform: translateY(-1px);
}

.answer-btn.selected {
  border-color: #4ea878;
  animation: answerPop 0.2s ease;
}

.answer-btn.correct {
  border-color: #1f9a58;
  box-shadow: 0 0 0 2px rgba(31, 154, 88, 0.2), 0 0 18px rgba(31, 154, 88, 0.34);
}

.answer-btn.correct::after {
  content: "✓";
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #1f9a58;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 0.9rem;
}

.answer-btn.wrong {
  border-color: #d45555;
  box-shadow: 0 0 0 2px rgba(212, 85, 85, 0.18);
  animation: answerShake 0.34s ease;
}

.answer-btn:disabled {
  opacity: 0.9;
  cursor: default;
}

.answer-btn.active {
  border-color: var(--accent);
}

.answer-feedback {
  min-height: 24px;
  margin-top: 12px;
  font-weight: 700;
  color: #245740;
}

.question-modal.confetti-on {
  position: relative;
}

.question-modal.confetti-on::before {
  content: "";
  position: absolute;
  inset: -8px;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 194, 87, 0.75) 0 2px, transparent 2px),
    radial-gradient(circle, rgba(80, 186, 122, 0.7) 0 2px, transparent 2px),
    radial-gradient(circle, rgba(98, 160, 255, 0.65) 0 2px, transparent 2px);
  background-size: 18px 18px, 22px 22px, 26px 26px;
  animation: confettiFade 0.8s ease forwards;
}

.answer-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 6px;
}

.progress-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: #e8f2eb;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #5fb980, #2f8f5b);
  transition: width 0.2s ease;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0;
  gap: 10px;
}

.debug-toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  background: rgba(26, 38, 33, 0.9);
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.82rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.14s ease, transform 0.14s ease;
  z-index: 1200;
  pointer-events: none;
}

.debug-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.debug-toast.hit {
  background: rgba(28, 106, 69, 0.92);
}

@media (max-width: 700px) {
  .panel {
    padding: 12px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .map-stage {
    width: 86px;
  }
}

@keyframes floaty {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes jumpBoostRise {
  0% {
    opacity: 0;
    transform: translate(-50%, 6px) scale(0.9);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -24px) scale(1.02);
  }
}

@keyframes answerPop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1.02);
  }
}

@keyframes answerShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-3px);
  }
  50% {
    transform: translateX(3px);
  }
  75% {
    transform: translateX(-2px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes confettiFade {
  0% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
  }
}

@keyframes targetBannerIn {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.96);
  }
  18% {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px) scale(0.98);
  }
}

@keyframes toastRise {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  18% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-8px);
  }
}

@keyframes wrongCatchShake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  50% {
    transform: translateX(4px);
  }
  75% {
    transform: translateX(-3px);
  }
  100% {
    transform: translateX(0);
  }
}
