html, body, #game-root {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body { min-width: 0; }
#game-root {
  position: relative;
  isolation: isolate;
  background: #087e9f;
}
#main {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
}
#main:focus { outline: none; }

.floating-controls {
  position: absolute;
  z-index: 4;
  top: max(14px, env(safe-area-inset-top));
  left: max(15px, env(safe-area-inset-left));
  right: max(15px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.utility-group {
  display: flex;
  gap: clamp(5px, 1vw, 13px);
  align-items: center;
  pointer-events: auto;
}
.utility-right { margin-inline-start: auto; }
.utility-button {
  display: grid;
  place-items: center;
  width: clamp(40px, 4vw, 62px);
  aspect-ratio: 1;
  padding: 0;
  color: #fff2bc;
  border: 3px solid #542c19;
  border-radius: 50%;
  background: radial-gradient(ellipse at 34% 25%, #b87836, #8b4b22 65%, #6b391f);
  box-shadow: inset 0 0 0 2px #f6bd66b0, 0 4px 0 #39231f, 0 5px 12px #032d4b60;
  transition: transform 160ms ease, filter 160ms ease;
}
.utility-button:hover, .utility-button:focus-visible {
  transform: translateY(-2px) scale(1.05);
  filter: brightness(1.14);
}
.utility-button:focus-visible, .island:focus-visible, .start-game:focus-visible {
  outline: 3px solid #fff3a7;
  outline-offset: 4px;
}
.utility-button .ico { width: 57%; height: 57%; stroke-width: 2.25; }
.island-reset-actions {justify-content:flex-end;align-items:center;}
@media (max-width: 800px) {
  .utility-button[data-action="reset-island"] {
    position:absolute;inset-inline-end:0;inset-block-start:calc(100% + 8px);
  }
}

.ocean {
  --art-height: min(100dvh, 56.25vw);
  --sea-fade: linear-gradient(transparent, #000 7%, #000 92%, transparent);
  position: relative;
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background: linear-gradient(#02bde3, #01badf);
}
/* The ocean outside the artwork follows the colors of its left and right shores. */
.ocean::before, .ocean::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  top: 50%;
  height: var(--art-height);
  translate: 0 -50%;
  pointer-events: none;
  mask-image: var(--sea-fade);
  background: linear-gradient(#02bde3 0%, #03bce2 9%, #02bce1 18%, #01c7e4 28%, #01d9ec 38%, #01cfe7 47%, #02d1dd 55%, #01cfde 63%, #01c9e3 70%, #01c5e4 77%, #01c3e4 85%, #02bbe2 94%, #01b9e0 100%);
}
.ocean::after {
  background: linear-gradient(#01bce2 0%, #01bde2 9%, #01bde1 18%, #00cae6 28%, #01d7e9 38%, #01d7e8 47%, #01cbd9 55%, #01ccdd 63%, #00c9e4 70%, #01c6e3 77%, #00c0e1 85%, #01bce1 94%, #01badf 100%);
  mask-image: var(--sea-fade), linear-gradient(to right, transparent 25%, #000 75%);
  mask-composite: intersect;
}
.game-stage {
  position: relative;
  z-index: 1;
  grid-area: 1 / 1;
  width: min(100vw, 177.7778dvh);
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}
.island-art, .mist, .mist-cloud {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.island-art {
  object-fit: contain;
  mask-image: linear-gradient(transparent, #000 6%, #000 91%, transparent),
    linear-gradient(to right, transparent, #000 .55%, #000 99.45%, transparent);
  mask-composite: intersect;
  transition: filter 850ms ease;
}
.title-stage { z-index: 3; pointer-events: none; }
.title-stage .start-game { pointer-events: auto; }
.home-screen {
  --reveal-duration: 1800ms;
  --mist-blur: clamp(10px, 1.9vw, 34px);
}
.home-screen .island-art, .home-screen .villagers, .home-screen::before, .home-screen::after {
  filter: saturate(.8) brightness(1.06);
}
.villagers { position: absolute; left: 17.8%; top: 58.3%; width: 4.15%; translate: -50% -50%; pointer-events: none; }
.home-foreground {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.home-heritage {
  position: absolute;
  bottom: -3dvh;
  width: min(21vw, 37dvh);
  opacity: .87;
  filter: saturate(.8) drop-shadow(0 8px 14px #16647e36);
  transition: opacity 820ms ease 240ms, translate 1050ms ease 240ms;
}
.home-hibiscus { left: -1vw; transform: rotate(-8deg); }
.home-wau { right: -1vw; transform: rotate(8deg); }
.mist {
  z-index: 2;
  isolation: isolate;
  overflow: hidden;
  background: #ebfbff29;
  transition: background-color 1320ms ease;
}
.mist-cloud {
  inset: -11%;
  width: 122%;
  height: 122%;
  opacity: var(--rest-opacity, .82);
  filter: blur(var(--mist-blur));
  animation: drift var(--drift-time, 24s) ease-in-out infinite var(--drift-direction, alternate);
}
.mist-west {
  --lag: 0ms;
  --out-x: -66%;
  --out-y: -20%;
  background:
    radial-gradient(ellipse at 11% 53%, #fff 0%, #ffffffeb 13%, transparent 37%),
    radial-gradient(ellipse at 23% 67%, #fff 0%, #ffffffcd 14%, transparent 38%),
    radial-gradient(ellipse at 43% 53%, #fff 0%, #ffffffc8 12%, transparent 33%);
}
.mist-east {
  --lag: 105ms;
  --out-x: 66%;
  --out-y: -16%;
  --drift-time: 29s;
  --drift-direction: alternate-reverse;
  background:
    radial-gradient(ellipse at 89% 56%, #fff 0%, #ffffffdf 14%, transparent 40%),
    radial-gradient(ellipse at 74% 68%, #fff 0%, #ffffffdb 15%, transparent 39%),
    radial-gradient(ellipse at 55% 49%, #fff 0%, #ffffffb8 10%, transparent 29%);
}
.mist-high {
  --lag: 165ms;
  --out-x: 10%;
  --out-y: -55%;
  --rest-opacity: .64;
  --drift-time: 33s;
  background:
    radial-gradient(ellipse at 44% 32%, #fff 0%, #ffffffc9 13%, transparent 42%),
    radial-gradient(ellipse at 65% 26%, #fff 0%, #ffffffa0 11%, transparent 34%);
}
.mist-low {
  --lag: 220ms;
  --out-x: 18%;
  --out-y: 54%;
  --rest-opacity: .72;
  --drift-time: 36s;
  --drift-direction: alternate-reverse;
  background:
    radial-gradient(ellipse 46% 27% at 22% 77%, #fff9, #ffffff75 48%, transparent 100%),
    radial-gradient(ellipse 50% 33% at 63% 82%, #fffd, #ffffff82 47%, transparent 100%),
    radial-gradient(ellipse 35% 22% at 88% 72%, #fff9, transparent 100%);
}
@keyframes drift {
  from { translate: -4% 1%; }
  to { translate: 6% -3%; }
}

.home-content {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: clamp(12px, 2.35cqw, 46px);
  z-index: 1;
  transition: opacity 480ms ease, transform 610ms ease;
}
.game-title {
  margin: 0;
  color: #fff2b4;
  text-align: center;
  font: 800 clamp(42px, 13.1cqw, 246px)/.82 var(--display);
  letter-spacing: -.035em;
  paint-order: stroke fill;
  -webkit-text-stroke: clamp(2px, .49cqw, 9px) #633920;
  text-shadow: 0 .052em 0 #9b5425, 0 .095em 0 #6f3c25, 0 .12em .12em #17445c73;
  transform: rotate(-3deg);
}
.game-title span { display: block; }
.game-title span + span { color: #ffc35c; margin-top: .055em; }

.wood {
  color: #fff0b9;
  background:
    radial-gradient(circle at 11px 50%, #efbf6f 0 2px, #7f451e 3px 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 11px) 50%, #efbf6f 0 2px, #7f451e 3px 4px, transparent 5px),
    repeating-linear-gradient(174deg, #713c171a 0 2px, transparent 3px 11px),
    linear-gradient(#c88b43, #a6612e 51%, #935021 53%, #a96934);
  border: 3px solid #60351e;
  border-radius: 13px 10px 15px 9px;
  box-shadow: inset 0 0 0 2px #f5c77b9e, 0 4px 0 #62391e, 0 6px 13px #1e263848;
  text-shadow: 0 2px 0 #643719;
}
.start-game {
  min-width: clamp(125px, 21.5cqw, 410px);
  min-height: clamp(48px, 7.25cqw, 132px);
  padding: .26em 1.15em;
  font: 800 clamp(22px, 4.55cqw, 86px)/1 var(--display);
  transition: transform 180ms ease, filter 180ms ease;
}
.start-game:hover, .start-game:focus-visible { transform: translateY(-3px) scale(1.05); filter: brightness(1.13); }
.home-screen.revealing .island-art, .home-screen.revealing .villagers,
.home-screen.revealing::before, .home-screen.revealing::after { filter: none; }
.revealing .home-content { opacity: 0; transform: translateY(-20px) scale(.97); pointer-events: none; }
.revealing .home-heritage { opacity: 0; }
.revealing .home-hibiscus { translate: -20% 12%; }
.revealing .home-wau { translate: 20% 12%; }
.revealing .mist { background-color: transparent; }
.revealing .mist-cloud {
  animation: drift var(--drift-time, 24s) ease-in-out infinite var(--drift-direction, alternate),
    disperse calc(var(--reveal-duration) - var(--lag) - 70ms) cubic-bezier(.28,.52,.4,1) var(--lag) both;
}
@keyframes disperse {
  from {
    transform: translate(0, 0) scale(1);
    filter: blur(var(--mist-blur));
    opacity: var(--rest-opacity, .82);
  }
  40% { opacity: calc(var(--rest-opacity, .82) * .88); }
  to {
    transform: translate(var(--out-x), var(--out-y)) scale(1.12);
    filter: blur(4px);
    opacity: 0;
  }
}
.map-screen .island { animation: appear 320ms ease both; }
@keyframes appear { from { opacity: .35; } to { opacity: 1; } }

.island {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  translate: -50% -50%;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: end;
  color: #fff0b9;
  background: transparent;
  border: 0;
  border-radius: 45% 45% 35% 35%;
}
.island::before {
  content: "";
  position: absolute;
  inset: 9% 7% 16%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #fff3a823, #ffffb11f 44%, transparent 73%);
  opacity: 0;
  transition: opacity 200ms ease;
}
.island-label {
  position: relative;
  width: min(100%, 28cqw);
  min-height: clamp(32px, 4.8cqw, 78px);
  padding: .36em .88em;
  display: grid;
  place-content: center;
  gap: .08em;
  font: 800 clamp(9.5px, 1.58cqw, 29px)/1.05 var(--display);
  transition: transform 180ms ease, filter 180ms ease;
}
.island-label small {
  display: block;
  color: #ffe198;
  font: 700 .7em/1.04 var(--display);
  letter-spacing: .04em;
}
.island:hover::before, .island:focus-visible::before { opacity: 1; }
.island:hover .island-label, .island:focus-visible .island-label {
  transform: translateY(-4px) scale(1.055);
  filter: brightness(1.12);
}
.flight {
  position: absolute;
  left: 66%;
  top: 54%;
  translate: -50% -50%;
  color: #f6fbf0;
  filter: drop-shadow(0 1px 1px #075374);
  rotate: 110deg;
  pointer-events: none;
}
.flight .ico { width: clamp(13px, 2.2cqw, 43px); height: auto; }

#main.learning-screen { background: #f7efdb; }
.learning-screen > .view {
  --fit: 1;
  position: absolute;
  top: calc((100% + var(--control-space)) / 2);
  left: 50%;
  margin: 0;
  padding: 0;
  transform: translate(-50%, -50%) scale(var(--fit));
  transform-origin: center;
}
.learning-screen .zone-title { margin-bottom: .65rem; }
.learning-screen .zone-title h1 { font-size: clamp(1.8rem, 4vw, 3.25rem); }
.learning-screen .zone-title .lead { font-size: 1rem; }
.learning-screen textarea { resize: none; field-sizing: content; min-height: 54px; }
.learning-screen .evidence-choice { padding-block: .3rem; margin-bottom: .45rem; }
.learning-screen .evidence-choice label { padding-block: .18rem; }
.learning-screen .sentence { margin-bottom: .46rem; }
.learning-screen .final-readout blockquote { margin-block: .35rem .6rem; }

#game-root { --control-space: 85px; }
.sheet {
  --fit: 1;
  position: fixed;
  inset: 50% auto auto 50%;
  margin: 0;
  max-height: none;
  overflow: hidden;
  transform: translate(-50%, -50%) scale(var(--fit));
  transform-origin: center;
}
.sheet::backdrop { background: #12384ca3; }
.wood-sheet {
  width: min(530px, calc(100vw - 28px));
  color: #422919;
  border: 5px solid #6a3c24;
  border-radius: 19px 14px 19px 16px;
  background:
    repeating-linear-gradient(175deg, #a25c2320 0 1px, transparent 2px 9px),
    linear-gradient(145deg, #fae0a2, #ecc380);
  box-shadow: inset 0 0 0 3px #bd823e, 0 6px 0 #593522, 0 14px 36px #12364870;
  scrollbar-gutter: auto;
}
.wood-sheet .sheet-inner { padding: clamp(14px, 4vw, 34px); }
.wood-sheet h2 { color: #572f19; font-size: clamp(1.55rem, 4vw, 2.65rem); }
.wood-sheet .close { background: #fff0c1; border-color: #8a4c27; color: #5b321b; }
.volume-row { display: grid; grid-template-columns: 1fr auto; gap: .4rem .85rem; font-weight: 800; margin-top: 1rem; }
.volume-row input { grid-column: 1 / -1; width: 100%; margin: 0; min-height: 31px; accent-color: #79451f; }
.volume-row output { min-width: 3.4em; text-align: right; }
.game-guide { margin: .65rem 0 0; padding-left: 1.25rem; line-height: 1.5; }
.game-guide li + li { margin-top: .4rem; }

@media (max-width: 650px), (max-height: 510px) {
  #game-root { --control-space: 62px; }
  .floating-controls { top: 9px; left: 9px; right: 9px; }
  .utility-button { width: 38px; border-width: 2px; }
  .island-label { border-width: 2px; border-radius: 7px; box-shadow: inset 0 0 0 1px #f5c77b9e, 0 2px 0 #62391e; }
}
@media (prefers-reduced-motion: reduce) {
  .mist-cloud { animation: none; }
}
