@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Noto+Sans+TC:wght@400;500;600;700;800;900&display=swap');

:root {
  color-scheme: light;
  font-family: 'Baloo 2', 'Noto Sans TC', system-ui, sans-serif;
  color: #12325a;
  background: #077fac;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --navy: #082c52;
  --sky: #47e5f4;
  --gold: #ffd85a;
  --cream: #fff8db;
  --ink: #112e50;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; }
body { overflow: hidden; background: #0783b3; }
button, a { font: inherit; }
button { color: inherit; }

.map-stage {
  position: fixed;
  inset: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  justify-items: safe center;
  background: #0584b1;
  touch-action: pan-x pan-y;
}
.map-stage::-webkit-scrollbar { display: none; }
.world {
  position: relative;
  flex: none;
  width: max(100vw, 163svh);
  max-width: 1900px;
  aspect-ratio: 43 / 24;
  margin-inline: auto;
  isolation: isolate;
  overflow: hidden;
  background: #47cfdb;
  box-shadow: 0 15px 65px #00284b52;
}
.world-map {
  position: absolute;
  z-index: -2;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}
.map-shine {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, #03366808 0%, transparent 23%, transparent 76%, #03386b08 100%);
}

.topbar {
  position: fixed;
  z-index: 5;
  inset: max(13px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) auto max(14px, env(safe-area-inset-left));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  pointer-events: none;
}
.brand-badge, .sound-toggle { pointer-events: auto; }
.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  max-width: min(480px, 70vw);
  padding: 8px 15px 8px 9px;
  border: 2px solid #fff9dc;
  border-radius: 24px;
  color: #fff;
  text-decoration: none;
  background: linear-gradient(135deg, #073766f2, #0a6793ed);
  box-shadow: 0 5px 15px #052d5580, inset 0 1px #ffffff44;
  backdrop-filter: blur(9px);
}
.brand-badge img { width: clamp(34px, 3.3vw, 44px); height: auto; filter: drop-shadow(0 2px 3px #00285280); }
.brand-copy { display: flex; flex-direction: column; gap: 1px; line-height: 1.16; min-width: 0; }
.brand-copy strong { color: #ffe77a; font-size: clamp(12px, 1.23vw, 16px); letter-spacing: .015em; }
.brand-divider { color: #a9f7f4; }
.brand-copy > span { color: #ecfbff; font-size: clamp(9px, .93vw, 12px); font-weight: 500; }
.sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 116px;
  min-height: 47px;
  padding: 6px 14px;
  border: 2px solid #fff8d8;
  border-radius: 22px;
  background: linear-gradient(145deg, #074779f5, #053058f2);
  color: white;
  box-shadow: 0 5px 16px #00284b88;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.sound-toggle:hover { transform: translateY(-2px); box-shadow: 0 8px 20px #00284baa; }
.sound-toggle:active { transform: scale(.96); }
.sound-toggle:focus-visible, .island-marker:focus-visible, .dialog-close:focus-visible, .quest-link:focus-visible { outline: 4px solid #ffdf61; outline-offset: 3px; }
.sound-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #59ddef; color: #07416b; font-size: 19px; font-weight: 800; }
.sound-label { display: grid; text-align: left; line-height: 1.06; }
.sound-label strong { color: #ffe783; font-size: 12px; }
.sound-label > span { color: #dcf7ff; font-size: 11px; }
.sound-toggle[aria-pressed="false"] .sound-icon { background: #7b94a7; color: white; }
.sound-toggle[aria-pressed="false"] .sound-label strong { color: #d8e5ef; }

.island-markers { position: absolute; inset: 0; }
.island-marker {
  --marker-color: #ffd95b;
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: clamp(50px, 5vw, 70px);
  min-height: 84px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
  color: #fff;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 3px 4px #06294f91);
  transition: filter .2s ease, scale .2s ease;
  animation: bob 3.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.island-marker:nth-child(even) { animation-duration: 3.65s; }
.island-marker:hover, .island-marker:focus-visible { z-index: 2; scale: 1.11; filter: drop-shadow(0 0 11px var(--marker-color)) drop-shadow(0 4px 5px #052448a6); }
.marker-medallion {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(44px, 4.5vw, 62px);
  height: clamp(44px, 4.5vw, 62px);
  margin: 0 auto 3px;
  border: 3px solid #fff8d8;
  border-radius: 50%;
  background: radial-gradient(circle at 33% 25%, #fff9c9 0%, var(--marker-color) 38%, #f48842 115%);
  box-shadow: 0 0 0 2px #063a63bd, inset 0 -4px 0 #492c2452, 0 4px 0 #074069;
  font-size: clamp(23px, 2.6vw, 36px);
  line-height: 1;
}
.marker-medallion::after { content: ''; position: absolute; inset: -8px; border: 2px solid #fff7bfaa; border-radius: 50%; animation: halo 2.6s ease-out infinite; }
.marker-number { position: absolute; top: -7px; right: -7px; z-index: 1; display: grid; place-items: center; width: 19px; height: 19px; border: 2px solid #fff; border-radius: 50%; background: #083f69; color: white; font: 800 9px/1 'Baloo 2', sans-serif; }
.marker-caption { display: grid; justify-items: center; gap: 0; width: max-content; max-width: 146px; margin: auto; padding: 2px 7px 3px; border: 1.5px solid #fff5d5; border-radius: 10px; background: #073765eF; box-shadow: 0 2px 6px #00284b70; line-height: 1.02; white-space: nowrap; }
.marker-caption strong { color: #fff6c9; font-size: clamp(10px, 1vw, 13px); font-weight: 800; }
.marker-caption span { color: #d8f7ff; font-size: clamp(8px, .77vw, 10px); font-weight: 600; }
.marker-status { position: absolute; top: -15px; left: 50%; padding: 1px 5px; border: 1px solid #fff; border-radius: 8px; background: #ed7b43; color: white; font-size: 8px; font-weight: 800; white-space: nowrap; transform: translateX(-50%) rotate(-5deg); }

.map-tip, .sound-note, .page-footnote { position: fixed; z-index: 3; pointer-events: none; color: white; text-shadow: 0 2px 5px #033252; }
.map-tip { left: max(15px, env(safe-area-inset-left)); bottom: max(42px, calc(env(safe-area-inset-bottom) + 35px)); display: flex; align-items: center; gap: 9px; max-width: min(440px, 76vw); padding: 9px 14px 9px 10px; border: 1.5px solid #fff4d3; border-radius: 17px; background: #05395fcf; box-shadow: 0 5px 15px #00294f71; backdrop-filter: blur(5px); }
.map-tip > span:last-child { display: grid; line-height: 1.12; }
.map-tip strong { color: #ffe787; font-size: clamp(11px, 1.18vw, 15px); }
.map-tip > span:last-child > span { color: #e9fbff; font-size: clamp(9px, .95vw, 12px); }
.tip-sparkle { display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 10px; background: #47d9dc; color: #07446c; font-size: 18px; }
.sound-note { right: max(17px, env(safe-area-inset-right)); bottom: max(42px, calc(env(safe-area-inset-bottom) + 37px)); max-width: 43vw; padding: 6px 10px; border-radius: 12px; background: #063963b8; color: #effcff; text-align: right; font-size: clamp(9px, .87vw, 11px); }
.page-footnote { inset: auto 0 max(8px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; gap: 15px; padding: 0 17px; color: #f4fcff; font-size: 10px; font-weight: 700; }

.quest-dialog {
  position: fixed;
  width: min(460px, calc(100vw - 34px));
  max-height: min(88svh, 720px);
  padding: 28px clamp(22px, 5vw, 40px) 30px;
  overflow: auto;
  border: 4px solid #ffecaa;
  border-radius: 30px;
  background: linear-gradient(160deg, #fffef5, #fff5d4);
  box-shadow: 0 22px 90px #00234091, inset 0 0 0 2px #fff;
  text-align: center;
  color: var(--ink);
}
.quest-dialog[open] { animation: pop-in .24s cubic-bezier(.2,.8,.2,1) both; }
.quest-dialog::backdrop { background: #022647ab; backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 12px; right: 14px; display: grid; place-items: center; width: 39px; height: 39px; padding: 0; border: 2px solid #fff; border-radius: 50%; background: #0c5281; box-shadow: 0 2px 4px #032e5063; color: white; font-size: 29px; line-height: 1; cursor: pointer; }
.quest-art { display: grid; place-items: center; width: 74px; height: 74px; margin: 2px auto 8px; border: 3px solid white; border-radius: 25px; background: linear-gradient(135deg, #65d9d5, #a2ebba); box-shadow: 0 4px 0 #23858b45; font-size: 39px; }
.quest-eyebrow { margin: 7px 0 3px; color: #19839b; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.quest-eyebrow span { margin-left: 5px; color: #54869a; font-size: 9px; }
.quest-dialog h1 { margin: 0; color: #153b61; font-size: clamp(23px, 5vw, 31px); font-weight: 900; line-height: 1.16; }
.quest-subtitle { display: grid; gap: 0; margin-top: 3px; color: #448297; font-size: 15px; font-weight: 800; line-height: 1.2; }
.quest-description { margin: 18px 0 12px; color: #274363; font-size: 15px; font-weight: 600; line-height: 1.72; text-align: left; }
.science-note { padding: 12px 14px; border: 1.5px solid #a2deda; border-radius: 16px; background: #e8faf3; color: #21544f; font-size: 13px; font-weight: 600; line-height: 1.6; text-align: left; }
.science-note strong { color: #08736d; }
.quest-footer { display: grid; gap: 10px; margin-top: 19px; }
.quest-link { display: flex; justify-content: center; align-items: center; gap: 9px; min-height: 50px; padding: 9px 17px; border: 3px solid white; border-radius: 18px; background: linear-gradient(135deg, #ff9c4a, #f36b4f); box-shadow: 0 5px 0 #bd4c36, 0 7px 12px #af5b343d; color: white; font-size: 15px; font-weight: 900; text-decoration: none; transition: transform .15s ease, filter .15s ease; }
.quest-link:hover { transform: translateY(-2px); filter: saturate(1.14); }
.quest-link:active { transform: translateY(2px); box-shadow: 0 2px 0 #bd4c36; }
.quest-link span { display: grid; line-height: 1.08; }
.quest-link small { font-size: 12px; font-weight: 700; }
.coming-message { padding: 12px; border: 2px dashed #d3a749; border-radius: 16px; background: #fff4ca; color: #795412; font-weight: 900; line-height: 1.35; }
.coming-message span { display: block; color: #936d28; font-size: 13px; }
.quest-category { margin-top: 9px; color: #677f93; font-size: 11px; font-weight: 700; }

@keyframes bob { 0%, 100% { translate: 0 0; } 50% { translate: 0 -6px; } }
@keyframes halo { 0% { opacity: .82; transform: scale(.85); } 90%, 100% { opacity: 0; transform: scale(1.45); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(9px) scale(.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 600px) {
  .topbar { inset: max(8px, env(safe-area-inset-top)) max(9px, env(safe-area-inset-right)) auto max(9px, env(safe-area-inset-left)); gap: 7px; }
  .brand-badge { gap: 7px; padding: 5px 9px 5px 6px; border-radius: 17px; }
  .brand-badge img { width: 34px; height: 34px; }
  .brand-copy strong { font-size: 11px; }
  .brand-copy > span { max-width: 190px; font-size: 8.5px; }
  .sound-toggle { gap: 5px; min-width: 92px; min-height: 41px; padding: 5px 9px; border-radius: 16px; }
  .sound-icon { width: 25px; height: 25px; font-size: 17px; }
  .sound-label strong { font-size: 10px; }
  .sound-label > span { font-size: 9px; }
  .island-marker { width: 54px; min-height: 72px; }
  .marker-medallion { width: 42px; height: 42px; border-width: 2.5px; font-size: 24px; }
  .marker-number { top: -7px; right: -7px; width: 17px; height: 17px; font-size: 8px; }
  .marker-caption { padding: 2px 5px; border-radius: 8px; }
  .marker-caption strong { font-size: 9px; }
  .marker-caption span { font-size: 7.4px; }
  .map-tip { bottom: max(41px, calc(env(safe-area-inset-bottom) + 34px)); gap: 6px; padding: 7px 9px 7px 7px; }
  .tip-sparkle { width: 23px; height: 23px; border-radius: 8px; font-size: 14px; }
  .map-tip strong { font-size: 10px; }
  .map-tip > span:last-child > span { font-size: 8px; }
  .sound-note { right: 9px; bottom: max(42px, calc(env(safe-area-inset-bottom) + 37px)); max-width: 38vw; padding: 5px 7px; font-size: 8px; }
  .page-footnote { padding: 0 10px; font-size: 8px; }
  .page-footnote span:last-child { text-align: right; }
  .quest-dialog { padding: 24px 21px 23px; border-width: 3px; border-radius: 25px; }
  .quest-art { width: 61px; height: 61px; border-radius: 21px; font-size: 33px; }
  .quest-description { margin-top: 14px; font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
