:root {
  color-scheme: dark;
  --bg: #080d10;
  --panel: #10181d;
  --panel-2: #162228;
  --ink: #e8f3ef;
  --muted: #8fa39b;
  --line: #294047;
  --accent: #38d7be;
  --accent-2: #ffb84a;
  --good: #42e08f;
  --bad: #ff5d5d;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(rgba(56, 215, 190, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(56, 215, 190, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 34px 34px, 34px 34px, cover;
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  width: min(1220px, calc(100% - 32px));
  min-height: calc(100vh - 32px);
  margin: 16px auto;
  background: linear-gradient(180deg, #111b20 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.map-panel {
  position: relative;
  min-height: 680px;
  background: #0b1115;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.map-panel.is-panning {
  cursor: grabbing;
}

.tile-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #0b1115;
}

.tile-layer img {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}

.map-vignette {
  position: absolute;
  inset: 0;
  box-shadow:
    inset 0 0 0 1px rgba(56, 215, 190, 0.24),
    inset 0 0 70px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 1;
}

.marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 0;
  background: var(--accent-2);
  border: 3px solid #10181d;
  box-shadow: 0 0 0 4px rgba(255, 184, 74, 0.26), 0 0 24px rgba(255, 184, 74, 0.68);
  transform: translate(-50%, -50%) rotate(-45deg);
  z-index: 3;
  transition: left 180ms ease, top 180ms ease;
}

.marker::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10181d;
  left: 5px;
  top: 5px;
}

.device-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid #081012;
  box-shadow: 0 0 0 5px rgba(56, 215, 190, 0.25), 0 0 22px rgba(56, 215, 190, 0.85);
  transform: translate(-50%, -50%);
  z-index: 4;
  display: none;
}

.device-marker.is-visible {
  display: block;
}

.device-marker::after {
  content: "";
  position: absolute;
  inset: -13px;
  border: 2px solid rgba(56, 215, 190, 0.42);
  border-radius: 50%;
  animation: devicePulse 1500ms ease-out infinite;
}

@keyframes devicePulse {
  0% { opacity: 0.9; transform: scale(0.55); }
  100% { opacity: 0; transform: scale(1.35); }
}

.answer-burst {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(260px, 58vw);
  height: min(260px, 58vw);
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 50;
  opacity: 0;
}

.burst-icon,
.burst-ring {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.burst-icon::before {
  display: grid;
  place-items: center;
  width: min(124px, 28vw);
  height: min(124px, 28vw);
  border-radius: 50%;
  font-size: clamp(56px, 14vw, 96px);
  font-weight: 900;
  line-height: 1;
}

.burst-ring::before,
.burst-ring::after {
  content: "";
  position: absolute;
  inset: 20px;
  border-radius: 50%;
}

.answer-burst.is-victory {
  animation: burstVisibility 1100ms ease-out both;
}

.answer-burst.is-victory::before,
.answer-burst.is-sad::before {
  content: "";
  position: fixed;
  inset: -100vmax;
  z-index: -1;
  pointer-events: none;
}

.answer-burst.is-victory::before {
  background: radial-gradient(circle, rgba(66, 224, 143, 0.28), rgba(66, 224, 143, 0.08) 18%, transparent 42%);
  animation: viewportVictoryFlash 1100ms ease-out both;
}

.answer-burst.is-victory .burst-icon::before {
  content: "✓";
  color: #06100e;
  background: var(--good);
  box-shadow: 0 0 28px rgba(66, 224, 143, 0.9);
  animation: victoryPop 760ms cubic-bezier(.17,.89,.32,1.35) both;
}

.answer-burst.is-victory .burst-ring::before {
  border: 2px solid rgba(66, 224, 143, 0.85);
  animation: ringExpand 1000ms ease-out both;
}

.answer-burst.is-victory .burst-ring::after {
  border: 2px dashed rgba(56, 215, 190, 0.85);
  animation: ringExpand 1000ms 120ms ease-out both, ringSpin 900ms linear both;
}

.answer-burst.is-sad {
  animation: burstVisibility 1150ms ease-out both;
}

.answer-burst.is-sad::before {
  background: radial-gradient(circle, rgba(255, 93, 93, 0.3), rgba(255, 93, 93, 0.08) 18%, transparent 44%);
  animation: viewportSadFlash 1150ms ease-out both;
}

.answer-burst.is-sad .burst-icon::before {
  content: "×";
  color: #160708;
  background: var(--bad);
  box-shadow: 0 0 26px rgba(255, 93, 93, 0.82);
  animation: sadDrop 880ms ease-in-out both;
}

.answer-burst.is-sad .burst-ring::before {
  border: 2px solid rgba(255, 93, 93, 0.72);
  animation: sadPulse 1050ms ease-out both;
}

.answer-burst.is-sad .burst-ring::after {
  inset: 48px 30px 30px;
  border: 0;
  border-bottom: 3px solid rgba(255, 93, 93, 0.9);
  border-radius: 50%;
  animation: sadMouth 900ms ease-out both;
}

@keyframes burstVisibility {
  0% { opacity: 0; }
  12% { opacity: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes viewportVictoryFlash {
  0% { opacity: 0; transform: scale(0.92); }
  14% { opacity: 1; transform: scale(1); }
  60% { opacity: 0.84; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(1.12); }
}

@keyframes viewportSadFlash {
  0% { opacity: 0; transform: translateY(-12px) scale(0.96); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  42% { opacity: 0.9; transform: translateY(8px) scale(0.98); }
  100% { opacity: 0; transform: translateY(22px) scale(0.94); }
}

@keyframes victoryPop {
  0% { transform: scale(0.35) rotate(-22deg); }
  48% { transform: scale(1.16) rotate(8deg); }
  100% { transform: scale(1) rotate(0); }
}

@keyframes ringExpand {
  0% { opacity: 0.95; transform: scale(0.35); }
  100% { opacity: 0; transform: scale(1.65); }
}

@keyframes ringSpin {
  0% { transform: rotate(0deg) scale(0.45); }
  100% { transform: rotate(160deg) scale(1.5); }
}

@keyframes sadDrop {
  0% { transform: translateY(-22px) scale(0.6); }
  42% { transform: translateY(8px) scale(1); }
  62% { transform: translateY(-3px) scale(0.94); }
  100% { transform: translateY(12px) scale(0.92); }
}

@keyframes sadPulse {
  0% { opacity: 0.85; transform: scale(0.55); }
  55% { opacity: 0.55; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.28); }
}

@keyframes sadMouth {
  0% { opacity: 0; transform: translateY(-8px) scaleX(0.55); }
  35% { opacity: 1; transform: translateY(4px) scaleX(1); }
  100% { opacity: 0; transform: translateY(13px) scaleX(0.85); }
}

.scale,
.map-help,
.attribution {
  position: absolute;
  z-index: 4;
  background: rgba(8, 13, 16, 0.72);
  color: rgba(232, 243, 239, 0.86);
  backdrop-filter: blur(3px);
  font-size: 12px;
}

.scale {
  left: 22px;
  bottom: 22px;
  width: 132px;
  height: 36px;
  border-left: 2px solid rgba(56, 215, 190, 0.76);
  border-right: 2px solid rgba(56, 215, 190, 0.76);
  border-bottom: 2px solid rgba(56, 215, 190, 0.76);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
}

.map-help {
  left: 22px;
  top: 22px;
  padding: 7px 9px;
  border: 1px solid rgba(56, 215, 190, 0.28);
  border-radius: 6px;
}

.map-control {
  position: absolute;
  z-index: 5;
  width: 46px;
  height: 46px;
  min-height: 46px;
  border: 1px solid rgba(56, 215, 190, 0.38);
  border-radius: 8px;
  background: rgba(8, 13, 16, 0.76);
  color: var(--accent);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(3px);
  font-size: 25px;
  line-height: 1;
  padding: 0;
  touch-action: manipulation;
}

.map-control:hover {
  background: rgba(56, 215, 190, 0.12);
}

.map-control:disabled {
  opacity: 0.62;
}

.locate-control {
  right: 16px;
  top: 16px;
}

.attribution {
  right: 12px;
  bottom: 12px;
  max-width: min(360px, calc(100% - 170px));
  padding: 6px 8px;
  border-radius: 6px;
}

.side-panel {
  padding: 26px;
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.status-bar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(22, 34, 40, 0.78);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.status-led {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--good);
  font-weight: 700;
}

.status-led::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 12px rgba(66, 224, 143, 0.7);
}

.topline {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-size: 30px;
  line-height: 1.12;
}

.intro,
.meta {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.language-control {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.language-control select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(12, 19, 23, 0.9);
  color: var(--ink);
  cursor: pointer;
}

.language-control select:focus {
  outline: 2px solid rgba(56, 215, 190, 0.5);
  outline-offset: 2px;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(22, 34, 40, 0.95), rgba(12, 19, 23, 0.95));
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

legend {
  padding: 0;
  margin-bottom: 12px;
  font-weight: 700;
}

#choices {
  display: grid;
  gap: 10px;
}

.choice {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  background: rgba(12, 19, 23, 0.72);
  color: var(--ink);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.choice:hover {
  border-color: rgba(56, 215, 190, 0.7);
  background: rgba(22, 34, 40, 0.94);
  box-shadow: inset 3px 0 0 rgba(56, 215, 190, 0.7);
}

.choice input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  margin: 0;
}

.choice.is-locked {
  cursor: default;
  opacity: 0.72;
}

.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #06100e;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  padding: 0 10px;
  white-space: normal;
}

button:hover {
  background: #5de4d0;
}

button:disabled {
  cursor: not-allowed;
  background: #415258;
  color: #a7b9b2;
}

.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

.secondary:hover {
  background: rgba(56, 215, 190, 0.1);
}

.result {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: rgba(12, 19, 23, 0.76);
}

.result strong {
  display: block;
  margin-bottom: 6px;
}

.result span {
  color: var(--muted);
  line-height: 1.45;
}

.result.good {
  border-color: rgba(66, 224, 143, 0.38);
  background: rgba(66, 224, 143, 0.12);
}

.result.bad {
  border-color: rgba(255, 93, 93, 0.38);
  background: rgba(255, 93, 93, 0.12);
}

.meta {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.meta a {
  display: inline-block;
  margin-top: 8px;
  color: var(--accent);
  text-decoration: none;
}

.meta a:hover {
  text-decoration: underline;
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(100% - 20px, 720px);
    min-height: auto;
    margin: 10px auto;
  }

  .map-panel {
    min-height: 440px;
  }

  .side-panel {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 22px;
  }

  h1 {
    font-size: 25px;
  }

  .actions {
    grid-template-columns: 1fr;
  }

  .score-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .attribution {
    max-width: calc(100% - 24px);
    right: 12px;
    bottom: 70px;
  }

  .locate-control {
    right: 12px;
    top: 12px;
  }
}
