:root {
  --bg: #081d2f;
  --panel: rgba(7, 21, 36, 0.84);
  --panel-border: rgba(164, 215, 248, 0.18);
  --text: #f3f7fb;
  --muted: #b8cddd;
  --sea-1: #0a3252;
  --sea-2: #115b82;
  --foam: rgba(255, 255, 255, 0.16);
  --mayday: #ff6b4a;
  --panpan: #ffb341;
  --securite: #5ed2c3;
  --success: #8df0b5;
  --danger: #ff8f88;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
  --mono: "Menlo", "Consolas", monospace;
  --display: "Avenir Next", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(94, 210, 195, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 107, 74, 0.16), transparent 24%),
    linear-gradient(180deg, #09233c 0%, #05111d 100%);
  color: var(--text);
  font-family: var(--display);
}

body {
  padding: 24px;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

@supports (padding: max(0px)) {
  body {
    padding-top: max(24px, env(safe-area-inset-top));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    padding-left: max(24px, env(safe-area-inset-left));
  }
}

button,
input,
textarea,
select {
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}

.app-shell {
  max-width: 1380px;
  margin: 0 auto;
  min-height: calc(100dvh - 48px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 24px;
}

.hero-copy h1 {
  margin: 0;
  font-size: clamp(2.8rem, 6vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: -0.06em;
}

.eyebrow,
.label,
.scenario-mode {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.74rem;
  color: #96d8f4;
  font-family: var(--mono);
}

.hero-text,
.source-panel p,
.protocol-list,
.scenario-story p,
#feedbackBody,
#correctAnswerNote {
  color: var(--muted);
  line-height: 1.6;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.chip,
.badge,
.filter-button,
.ghost-button,
.next-button {
  border-radius: 999px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
}

.flag-lab {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.sidebar,
.game-column {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  border-radius: 28px;
  padding: 22px;
}

.panel h2,
.panel h3 {
  margin-top: 0;
}

.protocol-panel {
  position: sticky;
  top: 24px;
}

.signal-card {
  padding: 14px 16px;
  border-radius: 18px;
  margin-bottom: 12px;
  border: 1px solid transparent;
}

.signal-card h3 {
  margin: 0 0 6px;
}

.signal-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.signal-card.mayday {
  background: rgba(255, 107, 74, 0.12);
  border-color: rgba(255, 107, 74, 0.35);
}

.signal-card.panpan {
  background: rgba(255, 179, 65, 0.12);
  border-color: rgba(255, 179, 65, 0.35);
}

.signal-card.securite {
  background: rgba(94, 210, 195, 0.12);
  border-color: rgba(94, 210, 195, 0.35);
}

.protocol-list {
  padding-left: 18px;
  margin: 18px 0 0;
}

.protocol-list li + li {
  margin-top: 10px;
}

.small {
  font-size: 0.92rem;
}

.hud {
  padding-bottom: 18px;
}

.score-row,
.filter-row,
.scenario-header,
.answers-header,
.feedback-topline,
.feedback-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.score-row {
  margin-bottom: 18px;
}

.value {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 900;
}

.filter-row {
  flex-wrap: wrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-button,
.ghost-button,
.next-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
  min-height: 46px;
  touch-action: manipulation;
}

.filter-button {
  padding: 10px 14px;
  flex: 0 0 auto;
}

@media (hover: hover) and (pointer: fine) {
  .filter-button:hover,
  .ghost-button:hover,
  .next-button:hover,
  .answer-button:hover {
    transform: translateY(-2px);
  }
}

.filter-button.active {
  background: rgba(150, 216, 244, 0.18);
  border-color: rgba(150, 216, 244, 0.34);
}

.ghost-button,
.next-button {
  padding: 10px 18px;
}

.scenario-header {
  align-items: flex-start;
}

.scenario-header h2 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  line-height: 1.02;
}

.scenario-tags {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badge {
  font-size: 0.8rem;
  background: rgba(255, 255, 255, 0.08);
}

.badge.subtle {
  color: #bedcec;
}

.sea-stage {
  position: relative;
  margin: 22px 0;
  min-height: 370px;
  border-radius: 26px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background:
    linear-gradient(180deg, rgba(94, 210, 195, 0.08), rgba(94, 210, 195, 0)),
    linear-gradient(160deg, var(--sea-2), var(--sea-1));
}

.sea-pattern,
.sea-stage::before,
.sea-stage::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.sea-pattern {
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1), transparent 12%),
    radial-gradient(circle at 80% 24%, rgba(255, 255, 255, 0.08), transparent 14%),
    radial-gradient(circle at 32% 74%, rgba(255, 255, 255, 0.12), transparent 10%);
  opacity: 0.65;
  animation: drift 16s linear infinite;
}

.sea-stage::before {
  content: "";
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 11.8%,
      rgba(255, 255, 255, 0.06) 11.8% 12%
    ),
    repeating-linear-gradient(
      180deg,
      transparent 0 11.8%,
      rgba(255, 255, 255, 0.06) 11.8% 12%
    );
  opacity: 0.22;
}

.sea-stage::after {
  content: "";
  background:
    radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.12), transparent 32%),
    linear-gradient(180deg, transparent 55%, rgba(255, 255, 255, 0.04));
}

.stage-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#rangeLine {
  stroke: rgba(245, 248, 252, 0.6);
  stroke-dasharray: 5 4;
  stroke-width: 0.55;
}

.distance-pill {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 8px 12px;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: #e5f4ff;
  background: rgba(4, 15, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.ship {
  position: absolute;
  width: 72px;
  height: 72px;
  transform: translate(-50%, -50%);
}

.ship::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.14);
  animation: pulse 2.6s ease-out infinite;
}

.ship-body {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22px;
  height: 42px;
  transform: translate(-50%, -50%);
  border-radius: 12px 12px 8px 8px;
  background:
    linear-gradient(180deg, #eff6ff 0 52%, #d95c4b 52% 100%);
  box-shadow: 0 0 0 2px rgba(4, 16, 26, 0.28);
  animation: bob 2.8s ease-in-out infinite;
}

.ship-body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -7px;
  width: 0;
  height: 0;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 15px solid #f6fbff;
}

.ship.own .ship-body {
  background:
    linear-gradient(180deg, #f7f5e8 0 50%, #ff7d54 50% 100%);
}

.ship.target .ship-body {
  background:
    linear-gradient(180deg, #f3fbff 0 50%, #57b7ff 50% 100%);
}

.ship.distress .ship-body {
  box-shadow:
    0 0 0 2px rgba(4, 16, 26, 0.28),
    0 0 26px rgba(255, 107, 74, 0.42);
}

.ship.distress::before {
  border-color: rgba(255, 107, 74, 0.38);
}

.ship.listing {
  transform: translate(-50%, -50%) rotate(-16deg);
}

.ship-label {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  white-space: nowrap;
  font-size: 0.72rem;
  font-family: var(--mono);
  background: rgba(4, 15, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.hazard-marker {
  position: absolute;
  width: 108px;
  height: 108px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.hazard-marker::before,
.hazard-marker::after {
  content: "";
  position: absolute;
}

.hazard-fire::before {
  left: 34px;
  top: 22px;
  width: 24px;
  height: 40px;
  background: radial-gradient(circle at 50% 70%, #ffe08a, #ff6b4a 64%, transparent 68%);
  filter: drop-shadow(0 0 10px rgba(255, 107, 74, 0.6));
  animation: flicker 0.9s ease-in-out infinite alternate;
}

.hazard-fire::after {
  left: 22px;
  top: 10px;
  width: 48px;
  height: 32px;
  background: radial-gradient(circle, rgba(45, 55, 65, 0.82), transparent 68%);
  animation: smoke 2.8s linear infinite;
}

.hazard-medical::before {
  left: 36px;
  top: 30px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(245, 248, 252, 0.86);
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.24);
}

.hazard-medical::after {
  left: 51px;
  top: 36px;
  width: 6px;
  height: 24px;
  background: #ff6b4a;
  box-shadow: -9px 9px 0 0 #ff6b4a;
}

.hazard-sinking::before,
.hazard-weather::before,
.hazard-obstruction::before,
.hazard-sar::before {
  inset: 0;
}

.hazard-sinking::before {
  left: 24px;
  top: 36px;
  width: 56px;
  height: 18px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.2), transparent 35%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.06));
  animation: swell 2.2s ease-in-out infinite;
}

.hazard-sinking::after {
  left: 42px;
  top: 18px;
  width: 18px;
  height: 30px;
  clip-path: polygon(50% 100%, 0 40%, 28% 40%, 28% 0, 72% 0, 72% 40%, 100% 40%);
  background: rgba(255, 107, 74, 0.82);
  animation: drop 1.8s ease-in-out infinite;
}

.hazard-weather::before {
  left: 20px;
  top: 20px;
  width: 70px;
  height: 38px;
  border-radius: 40px;
  background:
    radial-gradient(circle at 25% 50%, rgba(245, 248, 252, 0.92), transparent 44%),
    radial-gradient(circle at 50% 36%, rgba(245, 248, 252, 0.9), transparent 42%),
    radial-gradient(circle at 75% 52%, rgba(245, 248, 252, 0.88), transparent 44%);
  opacity: 0.94;
}

.hazard-weather::after {
  left: 46px;
  top: 52px;
  width: 14px;
  height: 32px;
  clip-path: polygon(48% 0, 100% 0, 62% 44%, 100% 44%, 0 100%, 34% 54%, 0 54%);
  background: #ffe08a;
  animation: flash 1.3s linear infinite;
}

.hazard-obstruction::before {
  left: 28px;
  top: 30px;
  width: 54px;
  height: 36px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, #c8842d, #8b5d20),
    linear-gradient(90deg, transparent 49%, rgba(0, 0, 0, 0.16) 50%, transparent 51%);
  box-shadow: 0 12px 0 -8px rgba(255, 255, 255, 0.16);
  animation: drift-tilt 3.6s ease-in-out infinite;
}

.hazard-obstruction::after {
  left: 22px;
  top: 62px;
  width: 68px;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.12), transparent);
}

.hazard-sar::before {
  left: 36px;
  top: 36px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 224, 138, 0.84);
  animation: pulse 2.2s ease-out infinite;
}

.hazard-sar::after {
  left: 49px;
  top: 17px;
  width: 12px;
  height: 58px;
  background: linear-gradient(180deg, transparent, rgba(255, 224, 138, 0.94), transparent);
}

.scenario-grid,
.feedback-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.flag-section-header,
.flag-quiz-header,
.flag-score-row,
.flag-quiz-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.flag-section-header {
  align-items: flex-end;
  margin-bottom: 18px;
}

.flag-reference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.flag-reference-card {
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.flag-reference-meta {
  margin-top: 12px;
}

.flag-reference-meta h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.flag-reference-meta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.flag-quiz-header {
  align-items: flex-start;
  margin-bottom: 18px;
}

.flag-score-row > div {
  min-width: 96px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.flag-quiz-stage {
  display: grid;
  grid-template-columns: minmax(220px, 320px) 1fr;
  gap: 18px;
  align-items: start;
}

.flag-display-card {
  padding: 16px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03)),
    rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.flag-display-face,
.flag-face {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 18px;
  overflow: hidden;
  background: rgba(4, 15, 28, 0.3);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.flag-display-face svg,
.flag-face svg {
  display: block;
  width: 100%;
  height: 100%;
}

.flag-quiz-copy {
  display: grid;
  gap: 14px;
}

.flag-prompt {
  margin: 0;
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.5;
}

.flag-answers-list {
  margin-top: 2px;
}

.level-result-card {
  display: grid;
  grid-template-columns: minmax(250px, 340px) 1fr;
  gap: 18px;
  align-items: center;
  padding: 18px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.level-result-copy h3 {
  margin: 0 0 10px;
  font-size: clamp(1.35rem, 3.2vw, 2rem);
}

.level-result-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.level-result-scene {
  position: relative;
  min-height: 220px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, #204c72 0%, #0a2238 100%);
}

.level-tier-fail .level-result-scene {
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.08), transparent 18%),
    linear-gradient(180deg, #334b63 0%, #09131f 100%);
}

.level-tier-happy .level-result-scene {
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 224, 138, 0.22), transparent 18%),
    linear-gradient(180deg, #2f8cc0 0%, #0d3555 100%);
}

.level-tier-great .level-result-scene {
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 224, 138, 0.28), transparent 20%),
    linear-gradient(180deg, #43a7d8 0%, #0f3e63 100%);
}

.level-tier-perfect .level-result-scene {
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 224, 138, 0.38), transparent 22%),
    radial-gradient(circle at 82% 14%, rgba(255, 255, 255, 0.18), transparent 16%),
    linear-gradient(180deg, #60bceb 0%, #15517d 100%);
}

.result-sea {
  position: absolute;
  left: -10%;
  right: -10%;
  border-radius: 50%;
}

.sea-back {
  bottom: 32px;
  height: 76px;
  background: rgba(19, 91, 130, 0.72);
  animation: wave-roll 4.6s ease-in-out infinite;
}

.sea-front {
  bottom: -8px;
  height: 98px;
  background:
    radial-gradient(circle at 20% 14%, rgba(255, 255, 255, 0.16), transparent 15%),
    linear-gradient(180deg, #0f4f7a, #0a3252);
  animation: wave-roll 3.7s ease-in-out infinite reverse;
}

.result-sun {
  position: absolute;
  width: 72px;
  height: 72px;
  left: 22px;
  top: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6c7, #ffd76d 60%, #ffb341 100%);
  box-shadow: 0 0 28px rgba(255, 215, 109, 0.4);
}

.result-cloud {
  position: absolute;
  width: 84px;
  height: 28px;
  top: 28px;
  border-radius: 999px;
  background: rgba(235, 245, 252, 0.6);
}

.result-cloud::before,
.result-cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(235, 245, 252, 0.6);
}

.result-cloud::before {
  width: 30px;
  height: 30px;
  left: 12px;
  top: -12px;
}

.result-cloud::after {
  width: 40px;
  height: 40px;
  right: 12px;
  top: -18px;
}

.cloud-left {
  left: 20px;
}

.cloud-right {
  right: 20px;
  top: 48px;
  transform: scale(0.82);
}

.wreck-ship {
  --wreck-scale: 1;
  position: absolute;
  left: 54%;
  top: 52%;
  width: 150px;
  height: 104px;
  transform-origin: center;
  animation: sink-tilt 4.8s ease-in-out infinite;
}

.wreck-hull {
  position: absolute;
  left: 26px;
  bottom: 20px;
  width: 96px;
  height: 30px;
  border-radius: 14px 18px 18px 10px;
  background: linear-gradient(180deg, #f6fbff 0 40%, #d95c4b 40% 100%);
  box-shadow: 0 0 0 2px rgba(4, 16, 26, 0.2);
}

.wreck-cabin {
  position: absolute;
  left: 48px;
  bottom: 48px;
  width: 34px;
  height: 24px;
  border-radius: 8px 8px 4px 4px;
  background: #f7f5e8;
}

.wreck-mast {
  position: absolute;
  left: 78px;
  bottom: 56px;
  width: 4px;
  height: 34px;
  background: #f3f7fb;
}

.wreck-mast::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 6px;
  width: 26px;
  height: 4px;
  transform: rotate(-30deg);
  transform-origin: left center;
  background: #f3f7fb;
}

.bubble {
  position: absolute;
  bottom: 20px;
  border-radius: 50%;
  background: rgba(243, 251, 255, 0.6);
  animation: bubble-rise 3.8s ease-in infinite;
}

.bubble-1 {
  left: 58%;
  width: 10px;
  height: 10px;
}

.bubble-2 {
  left: 63%;
  width: 14px;
  height: 14px;
  animation-delay: 0.8s;
}

.bubble-3 {
  left: 69%;
  width: 8px;
  height: 8px;
  animation-delay: 1.5s;
}

.bubble-4 {
  left: 73%;
  width: 12px;
  height: 12px;
  animation-delay: 2.2s;
}

.celebration-boat {
  --boat-scale: 1;
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: 190px;
  height: 122px;
  transform: translateX(-50%);
  animation: harbor-bob 3s ease-in-out infinite;
}

.celebration-hull {
  position: absolute;
  left: 34px;
  bottom: 14px;
  width: 120px;
  height: 34px;
  border-radius: 16px 18px 20px 18px;
  background: linear-gradient(180deg, #f7f5e8 0 38%, #ff7d54 38% 100%);
  box-shadow: 0 0 0 2px rgba(4, 16, 26, 0.18);
}

.celebration-cabin {
  position: absolute;
  left: 58px;
  bottom: 40px;
  width: 38px;
  height: 26px;
  border-radius: 8px 8px 4px 4px;
  background: #f3fbff;
}

.sailor {
  position: absolute;
  left: 92px;
  bottom: 44px;
  width: 56px;
  height: 88px;
}

.sailor-head {
  position: absolute;
  left: 14px;
  top: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffd7b0;
}

.sailor-head::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 8px;
  width: 12px;
  height: 3px;
  border-radius: 999px;
  background: #1b2c3a;
  box-shadow: 0 0 0 1px transparent;
}

.sailor-head::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 13px;
  width: 10px;
  height: 5px;
  border-bottom: 2px solid #1b2c3a;
  border-radius: 0 0 10px 10px;
}

.sailor-body {
  position: absolute;
  left: 12px;
  top: 20px;
  width: 26px;
  height: 30px;
  border-radius: 10px 10px 8px 8px;
  background: linear-gradient(180deg, #57b7ff 0 48%, #f6fbff 48% 100%);
}

.sailor-arm,
.sailor-leg {
  position: absolute;
  width: 6px;
  border-radius: 999px;
  background: #ffd7b0;
}

.sailor-arm {
  top: 24px;
  height: 25px;
  transform-origin: top center;
}

.arm-wave {
  left: 8px;
  animation: sailor-wave 1.5s ease-in-out infinite;
}

.arm-rest {
  left: 36px;
  transform: rotate(-24deg);
}

.sailor-leg {
  top: 48px;
  height: 24px;
  background: #132d46;
}

.leg-left {
  left: 18px;
  transform: rotate(10deg);
}

.leg-right {
  left: 28px;
  transform: rotate(-8deg);
}

.sailor-great,
.sailor-perfect {
  animation: sailor-bounce 1.8s ease-in-out infinite;
}

.sailor-perfect .sailor-head::after {
  width: 12px;
  height: 7px;
}

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

.confetti-piece {
  position: absolute;
  left: var(--left);
  top: -10px;
  width: 9px;
  height: 16px;
  border-radius: 3px;
  background: var(--piece);
  opacity: 0.92;
  animation: confetti-fall 3.1s linear infinite;
  animation-delay: var(--delay);
}

.sparkle,
.firework {
  position: absolute;
  border-radius: 50%;
}

.sparkle {
  width: 14px;
  height: 14px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.92), transparent 68%);
  animation: sparkle-pulse 2s ease-in-out infinite;
}

.sparkle-a {
  right: 48px;
  top: 42px;
}

.sparkle-b {
  left: 84px;
  top: 78px;
  animation-delay: 0.7s;
}

.firework {
  width: 72px;
  height: 72px;
  border: 3px dashed rgba(255, 224, 138, 0.88);
  animation: firework-burst 1.9s ease-out infinite;
}

.firework-left {
  left: 18px;
  top: 18px;
}

.firework-right {
  right: 18px;
  top: 12px;
  animation-delay: 0.8s;
}

.sailor-trophy {
  position: absolute;
  left: 34px;
  top: -8px;
  width: 26px;
  height: 34px;
  animation: trophy-lift 1.8s ease-in-out infinite;
}

.trophy-cup {
  position: absolute;
  left: 5px;
  top: 0;
  width: 16px;
  height: 14px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #ffe08a, #ffb341);
}

.trophy-cup::before,
.trophy-cup::after {
  content: "";
  position: absolute;
  top: 3px;
  width: 7px;
  height: 8px;
  border: 2px solid #ffd76d;
  border-radius: 999px;
}

.trophy-cup::before {
  left: -7px;
  border-right: 0;
}

.trophy-cup::after {
  right: -7px;
  border-left: 0;
}

.trophy-base {
  position: absolute;
  left: 9px;
  top: 14px;
  width: 8px;
  height: 12px;
  background: #ffd76d;
}

.trophy-base::after {
  content: "";
  position: absolute;
  left: -5px;
  bottom: -5px;
  width: 18px;
  height: 6px;
  border-radius: 4px;
  background: #7a5a25;
}

.scenario-story,
.feedback-columns > div {
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.answers-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.answer-button {
  width: 100%;
  padding: 16px 18px;
  min-height: 78px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    opacity 150ms ease;
}

.answer-button:disabled {
  cursor: default;
}

.answer-button.correct {
  background: rgba(141, 240, 181, 0.1);
  border-color: rgba(141, 240, 181, 0.38);
}

.answer-button.incorrect {
  background: rgba(255, 143, 136, 0.08);
  border-color: rgba(255, 143, 136, 0.32);
}

.answer-button.dimmed {
  opacity: 0.58;
}

.answer-title {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.answer-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #9dcde4;
  font-size: 0.84rem;
  font-family: var(--mono);
}

.feedback-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hidden {
  display: none;
}

.result-pill {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.result-pill.correct {
  background: rgba(141, 240, 181, 0.14);
  color: var(--success);
}

.result-pill.incorrect {
  background: rgba(255, 143, 136, 0.12);
  color: var(--danger);
}

#actionList {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

#actionList li + li,
#flagDetailList li + li {
  margin-top: 8px;
}

#flagDetailList {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.87rem;
  color: #dbedf8;
  line-height: 1.6;
}

@keyframes bob {
  0%,
  100% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  50% {
    transform: translate(-50%, calc(-50% - 3px)) rotate(1deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.7);
    opacity: 0.62;
  }
  100% {
    transform: scale(1.3);
    opacity: 0;
  }
}

@keyframes drift {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(32px);
  }
}

@keyframes flicker {
  0% {
    transform: scale(0.92) translateY(2px);
  }
  100% {
    transform: scale(1.06) translateY(-2px);
  }
}

@keyframes smoke {
  0% {
    transform: translateY(8px) scale(0.86);
    opacity: 0.52;
  }
  100% {
    transform: translateY(-18px) scale(1.2);
    opacity: 0;
  }
}

@keyframes swell {
  0%,
  100% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
}

@keyframes drop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(6px);
  }
}

@keyframes flash {
  0%,
  70%,
  100% {
    opacity: 0.18;
  }
  72%,
  88% {
    opacity: 1;
  }
}

@keyframes drift-tilt {
  0%,
  100% {
    transform: rotate(-3deg);
  }
  50% {
    transform: rotate(3deg) translateY(2px);
  }
}

@keyframes wave-roll {
  0%,
  100% {
    transform: translateX(-2%) translateY(0);
  }
  50% {
    transform: translateX(2%) translateY(-4px);
  }
}

@keyframes sink-tilt {
  0%,
  100% {
    transform: scale(var(--wreck-scale)) translateY(-6px) rotate(-10deg);
  }
  45% {
    transform: scale(var(--wreck-scale)) translateY(8px) rotate(12deg);
  }
  70% {
    transform: scale(var(--wreck-scale)) translateY(20px) rotate(24deg);
  }
}

@keyframes bubble-rise {
  0% {
    transform: translateY(0) scale(0.75);
    opacity: 0;
  }
  15% {
    opacity: 0.7;
  }
  100% {
    transform: translateY(-110px) scale(1.15);
    opacity: 0;
  }
}

@keyframes harbor-bob {
  0%,
  100% {
    transform: translateX(-50%) translateY(0) scale(var(--boat-scale));
  }
  50% {
    transform: translateX(-50%) translateY(-6px) scale(var(--boat-scale));
  }
}

@keyframes sailor-wave {
  0%,
  100% {
    transform: rotate(-12deg);
  }
  50% {
    transform: rotate(42deg);
  }
}

@keyframes sailor-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes confetti-fall {
  0% {
    transform: translate3d(0, -14px, 0) rotate(0deg);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift), 220px, 0) rotate(var(--rotation));
    opacity: 0;
  }
}

@keyframes sparkle-pulse {
  0%,
  100% {
    transform: scale(0.85);
    opacity: 0.35;
  }
  50% {
    transform: scale(1.4);
    opacity: 1;
  }
}

@keyframes firework-burst {
  0% {
    transform: scale(0.25);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: scale(1.15);
    opacity: 0;
  }
}

@keyframes trophy-lift {
  0%,
  100% {
    transform: translateY(0) rotate(-10deg);
  }
  50% {
    transform: translateY(-8px) rotate(8deg);
  }
}

@media (max-width: 1080px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .protocol-panel {
    position: static;
  }

  .flag-quiz-stage {
    grid-template-columns: 1fr;
  }

  .level-result-card {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  body {
    padding: 14px;
  }

  @supports (padding: max(0px)) {
    body {
      padding-top: max(14px, env(safe-area-inset-top));
      padding-right: max(14px, env(safe-area-inset-right));
      padding-bottom: max(14px, env(safe-area-inset-bottom));
      padding-left: max(14px, env(safe-area-inset-left));
    }
  }

  .app-shell {
    min-height: calc(100dvh - 28px);
  }

  .hero,
  .scenario-header,
  .answers-header,
  .feedback-topline,
  .feedback-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .scenario-grid,
  .feedback-columns {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .hero {
    gap: 18px;
  }

  .hero-copy h1 {
    font-size: clamp(2.35rem, 12vw, 4rem);
  }

  .hero-badges,
  .scenario-tags,
  .flag-quiz-actions {
    justify-content: flex-start;
  }

  .score-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    align-items: stretch;
  }

  .score-row > div {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
  }

  .value {
    font-size: 1.35rem;
  }

  .filter-row {
    flex-wrap: nowrap;
    padding-bottom: 4px;
    margin-right: -2px;
  }

  .filter-button {
    min-height: 44px;
  }

  .answers-header,
  .feedback-footer {
    align-items: stretch;
  }

  .ghost-button,
  .next-button {
    width: 100%;
    justify-content: center;
  }

  .flag-section-header,
  .flag-quiz-header,
  .flag-score-row,
  .flag-quiz-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .flag-score-row > div {
    min-width: 0;
  }

  .flag-reference-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .level-result-scene {
    min-height: 200px;
  }

  .celebration-boat {
    --boat-scale: 0.9;
  }

  .wreck-ship {
    --wreck-scale: 0.88;
    left: 50%;
  }

  .sea-stage {
    min-height: 290px;
    border-radius: 22px;
  }

  .ship {
    width: 58px;
    height: 58px;
  }

  .ship::before {
    inset: 8px;
  }

  .ship-body {
    width: 18px;
    height: 35px;
  }

  .ship-body::before {
    top: -6px;
    border-left-width: 8px;
    border-right-width: 8px;
    border-bottom-width: 12px;
  }

  .ship-label {
    top: 62px;
    max-width: 112px;
    text-align: center;
    white-space: normal;
    font-size: 0.66rem;
  }

  .hazard-marker {
    width: 88px;
    height: 88px;
    transform: translate(-50%, -50%) scale(0.82);
  }

  .distance-pill {
    max-width: 54%;
    padding: 7px 10px;
    font-size: 0.72rem;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .score-row {
    grid-template-columns: 1fr;
  }

  .flag-reference-grid {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 16px;
  }

  .level-result-card {
    padding: 14px;
  }

  .level-result-scene {
    min-height: 180px;
  }

  .celebration-boat {
    bottom: 16px;
    --boat-scale: 0.78;
  }

  .wreck-ship {
    top: 48%;
    --wreck-scale: 0.72;
  }

  .sea-stage {
    min-height: 250px;
  }

  .answer-button {
    padding: 14px 16px;
    min-height: 72px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
