:root {
  --sea: #BDE3F2;
  --sea-deep: #8CCBE6;
  --sand: #F6E3B4;
  --sand-edge: #E6C98A;
  --grass: #9CD08A;
  --grass-deep: #6FAE5C;
  --ink: #2E3A59;
  --ink-soft: #5B6684;
  --bird: #8E7CD8;
  --bird-soft: #E6E0FA;
  --beak: #F29A38;
  --pattern: #C9560F;
  --paper: #FFFDF7;
  --word-font: "Andika", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --ui-font: ui-rounded, "SF Pro Rounded", "PingFang TC", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ui-font);
  color: var(--ink);
  background: radial-gradient(120% 80% at 50% 110%, var(--sea-deep), var(--sea) 60%);
  background-attachment: fixed;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 3px solid var(--bird); outline-offset: 3px; }
.loading { text-align: center; margin-top: 40vh; font-size: 1.2rem; color: var(--ink-soft); }

/* ---------- 選角色 ---------- */
.who { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px 40px; gap: 20px; }
.who h1 { font-size: clamp(1.6rem, 5vw, 2.4rem); margin: 0; letter-spacing: .04em; }
.pick { display: flex; gap: clamp(12px, 4vw, 40px); justify-content: center; flex-wrap: wrap; }
.pick-btn {
  background: var(--paper); border: 0; border-radius: 36px 36px 30px 30px;
  width: clamp(150px, 40vw, 260px); padding: 18px 12px 16px;
  box-shadow: inset 0 -8px 0 rgba(46,58,89,.08), 0 8px 0 var(--sand-edge);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .15s;
}
.pick-btn:active { transform: translateY(5px); box-shadow: inset 0 -8px 0 rgba(46,58,89,.08), 0 3px 0 var(--sand-edge); }
.pick-btn img { height: clamp(120px, 30vw, 200px); width: auto; }
.pick-btn span { font-size: clamp(1.2rem, 4vw, 1.6rem); font-weight: 700; }
.who .hint { margin: 0; color: var(--ink-soft); text-align: center; max-width: 26em; line-height: 1.6; }

/* ---------- 單字島 ---------- */
.island-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 10px 14px 18px; }
.island-screen .stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; width: 100%; }
.topbar { width: 100%; max-width: 720px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.me-btn, .icon-btn {
  background: rgba(255,253,247,.85); border: 0; border-radius: 999px;
  display: flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; min-height: 44px;
}
.me-btn img { width: 38px; height: 38px; object-fit: contain; }
.icon-btn { padding: 0; width: 44px; justify-content: center; font-size: 1.3rem; }
.title { text-align: center; flex: 1; }
.title h1 { font-size: clamp(1.05rem, 3.6vw, 1.4rem); margin: 0; }
.chip { display: inline-block; margin-top: 2px; font-size: .85rem; padding: 2px 10px; border-radius: 999px; background: var(--bird-soft); color: #4B3C99; }

.map {
  container-type: inline-size;
  position: relative; width: min(94vw, 680px, 60vh); aspect-ratio: 1 / 1; margin: 8px auto 0;
}
.map .island-bg { position: absolute; inset: 0; width: 100%; height: 100%; }
.center-node {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 32cqw; height: 32cqw; border-radius: 50%; border: 0;
  background: radial-gradient(circle at 40% 30%, #B8E0A8, var(--grass) 60%, var(--grass-deep));
  box-shadow: inset 0 -1.5cqw 0 rgba(0,0,0,.08), 0 1.4cqw 0 rgba(70,120,60,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6cqw;
}
.center-node .c-en { font-family: var(--word-font); font-weight: 700; font-size: 8.5cqw; line-height: 1; color: var(--ink); }
.center-node .c-zh { font-size: 3.2cqw; color: #2F4A2A; padding: 0 3cqw; line-height: 1.2; }

.word {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 22cqw; max-width: 36cqw; padding: 2.4cqw 3.4cqw 2.8cqw;
  border: 0; border-radius: 6cqw 6cqw 5cqw 5cqw; background: var(--paper);
  box-shadow: inset 0 -1.2cqw 0 rgba(46,58,89,.07), 0 1.2cqw 0 var(--sand-edge);
  font-family: var(--word-font); font-size: var(--fs, 6.4cqw); line-height: 1.1; letter-spacing: .02em;
  transition: transform .15s, box-shadow .15s;
}
.word:active { transform: translate(-50%, -46%); box-shadow: inset 0 -1.2cqw 0 rgba(46,58,89,.07), 0 .4cqw 0 var(--sand-edge); }
.word.playing { background: #FFF1C9; transform: translate(-50%, -50%) scale(1.08); }
.hl { color: var(--pattern); font-weight: 700; }
.seen-star { position: absolute; top: -2.4cqw; right: -1.6cqw; font-size: 4.4cqw; line-height: 1; color: #F2B705; filter: drop-shadow(0 1px 0 rgba(0,0,0,.15)); }

.bottom { width: min(94vw, 680px); display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin-top: 4px; }
.team { display: flex; align-items: flex-end; }
.team img { height: clamp(70px, 17vw, 150px); width: auto; transition: transform .3s; }
.team img + img { margin-left: -10px; }
.team img.dim { transform: scale(.9); transform-origin: bottom; }
.team.bob img:not(.dim) { animation: bob .9s ease-in-out infinite; }
.team.bob img.dim { animation: bob .9s ease-in-out .45s infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }


.big-btn {
  border: 0; border-radius: 999px; background: var(--ink); color: #fff;
  font-size: clamp(1rem, 3.6vw, 1.2rem); font-weight: 700; padding: 14px 22px; min-height: 52px;
  box-shadow: 0 5px 0 #1B2440; display: inline-flex; align-items: center; gap: 8px;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 #1B2440; }
.big-btn.soft { background: var(--paper); color: var(--ink); box-shadow: 0 5px 0 var(--sand-edge); }
.big-btn.soft:active { box-shadow: 0 2px 0 var(--sand-edge); }
.big-btn svg { width: 1.2em; height: 1.2em; }

/* ---------- 底部抽屜 ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(46,58,89,.35); }
.sheet {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 560px); max-height: 88vh; overflow-y: auto;
  background: var(--paper); border-radius: 28px 28px 0 0;
  padding: 22px 20px calc(24px + env(safe-area-inset-bottom, 0));
  animation: up .22s ease-out;
}
@keyframes up { from { transform: translate(-50%, 30%); opacity: .4; } }
.sheet-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: #F1ECDD; font-size: 1.1rem; }
.sheet h2.w { font-family: var(--word-font); font-size: clamp(2.4rem, 11vw, 3.4rem); margin: 6px 0 0; line-height: 1.1; letter-spacing: .03em; user-select: text; -webkit-user-select: text; }
.ipa { font-family: var(--word-font); color: var(--ink-soft); font-size: 1.1rem; margin: 4px 0 14px; }
.badge { display: inline-block; font-size: .85rem; padding: 3px 10px; border-radius: 999px; background: #FFF1C9; color: #7A5400; }
.row { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.card { background: #F6F1E3; border-radius: 18px; padding: 12px 14px; margin: 12px 0; }
.card h3 { font-size: .95rem; margin: 0 0 6px; color: var(--ink-soft); font-weight: 600; }
.card p { margin: 4px 0; line-height: 1.6; }
.reveal { border: 2px dashed var(--sand-edge); background: transparent; border-radius: 14px; padding: 10px 14px; width: 100%; text-align: left; font-size: 1rem; min-height: 48px; }
.zh-big { font-size: 1.5rem; font-weight: 700; }
.example { font-family: var(--word-font); font-size: 1.25rem; }
.example-zh { color: var(--ink-soft); }
.tip { color: var(--ink-soft); font-size: .95rem; }

.settings label { display: block; font-weight: 600; margin: 16px 0 6px; }
.settings select { width: 100%; font: inherit; font-size: 1rem; padding: 10px; border-radius: 12px; border: 2px solid var(--sand-edge); background: #fff; color: var(--ink); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; border: 2px solid var(--sand-edge); background: #fff; border-radius: 12px; padding: 10px; min-height: 46px; }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.small { font-size: .85rem; color: var(--ink-soft); line-height: 1.6; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 16px; z-index: 30; max-width: 90vw; text-align: center; line-height: 1.5; }

/* 入場：單字依位置一顆一顆出現（只有這一個自動動畫） */
.map.enter .word { animation: pop .35s ease-out backwards; animation-delay: calc(var(--i) * 90ms + 150ms); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -30%) scale(.6); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (orientation: landscape) {
  .map { width: min(94vw, 640px, 72vh); }
}
