:root {
  --ink: #6f5a41;
  --ink-soft: #9a8569;
  --paper: #fdf8e8;
  --paper-2: #f6eed6;
  --line: #e8dcc0;
  --mint: #7fd0b8;
  --mint-dark: #5cb89e;
  --sun: #f7d560;
  --coral: #ee8d78;
  --sky: #8fc9f0;
  --shadow: 0 4px 0 rgba(150, 125, 85, .18), 0 8px 18px rgba(90, 70, 40, .16);
  --font: Huninn, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #8fd8e4;
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  overscroll-behavior: none;
  touch-action: pan-x pan-y; /* 手指雙擊或捏合不會把整個網頁放大，面板仍可捲動 */
  user-select: none;
  -webkit-user-select: none;
}

input { font: inherit; color: inherit; user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
h2, h3, h4, p { margin: 0; }

canvas#farm {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.overlay { position: fixed; inset: 0; overflow: hidden; pointer-events: none; }

.ic { width: 22px; height: 22px; flex: none; }
.ic.tiny { width: 16px; height: 16px; }
.sub { color: var(--ink-soft); font-size: 13px; line-height: 1.45; }
.center { text-align: center; }

:focus-visible { outline: 3px solid #4aa3c4; outline-offset: 2px; }

body:not(.in-game) .hud,
body:not(.in-game) .dock { visibility: hidden; }

/* ---------- 浮在島上的標籤 ---------- */

.world-label {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  transition: opacity .18s ease;
  will-change: transform;
}
.world-label.show { opacity: 1; }

.world-label.name {
  padding: 1px 10px;
  background: rgba(253, 248, 232, .92);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12.5px;
  line-height: 19px;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(90, 70, 40, .18);
}
.world-label.name.mine { background: var(--mint); color: #fff; }
.world-label.name.villager { background: #fbe9b4; }
.world-label.name.unlock { background: var(--sun); }

.world-label.bubble {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: 0 3px 8px rgba(90, 70, 40, .28);
  animation: floaty 1.5s ease-in-out infinite;
}
.world-label.bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  margin-left: -6px;
  border: 6px solid transparent;
  border-top-color: var(--paper);
  border-bottom: 0;
}
.world-label.bubble img { width: 25px; height: 25px; }
@keyframes floaty { 50% { margin-top: -5px; } }

.world-label.speech {
  max-width: 200px;
  padding: 7px 13px;
  background: var(--paper);
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  box-shadow: 0 3px 8px rgba(90, 70, 40, .25);
  z-index: 2;
}
.world-label.speech::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 50%;
  margin-left: -7px;
  border: 7px solid transparent;
  border-top-color: var(--paper);
  border-bottom: 0;
}

.float-text {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 600;
  font-size: 17px;
  white-space: nowrap;
  color: #fff;
  text-shadow: 0 1px 0 rgba(90, 70, 40, .7), 0 2px 5px rgba(90, 70, 40, .55);
}
.float-text > * { display: block; }
.float-text { animation: float-up 1.5s ease-out forwards; }
.float-text.gold { color: #ffe58a; }
.float-text.pink { color: #ffd0d8; }
.float-text.big { font-size: 25px; color: #ffe58a; }
@keyframes float-up {
  0% { opacity: 0; margin-top: 8px; }
  15% { opacity: 1; margin-top: 0; }
  75% { opacity: 1; }
  100% { opacity: 0; margin-top: -46px; }
}

/* ---------- 按鈕 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--sun);
  box-shadow: 0 3px 0 #dfb73f;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .06s ease, box-shadow .06s ease, background-color .12s ease;
}
/* 只有滑鼠才有 hover；觸控螢幕點一下後不會卡在亮色 */
@media (hover: hover) { .btn:hover:not(:disabled) { background: #fadf7c; } }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 #dfb73f; }
.btn:disabled { background: #efe7d2; color: #b3a48c; box-shadow: 0 3px 0 #ddd2b8; cursor: not-allowed; }
.btn.small { min-height: 38px; padding: 5px 14px; font-size: 14px; }
.btn.wide { width: 100%; white-space: normal; line-height: 1.3; }
.btn.big { min-height: 54px; font-size: 18px; }
.btn.ghost { background: #fff; box-shadow: 0 3px 0 var(--line); }
@media (hover: hover) { .btn.ghost:hover:not(:disabled) { background: #fffdf6; } }
.btn.danger { background: #f4a493; box-shadow: 0 3px 0 #d98673; }
@media (hover: hover) { .btn.danger:hover:not(:disabled) { background: #f7b5a7; } }
.btn.danger-ghost { background: #fff; color: #bb5a44; box-shadow: 0 3px 0 #f0cfc5; }
.btn.icon-only { padding: 5px 9px; }

.x {
  width: 44px;
  height: 44px;
  flex: none;
  border: 0;
  background: none;
  font-size: 28px;
  line-height: 1;
  color: var(--ink);
}

/* ---------- 上方資訊 ---------- */

.hud {
  position: fixed;
  top: calc(10px + var(--safe-t));
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  pointer-events: none;
}
.hud-left { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; min-width: 0; }

.hud-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.clock { flex-direction: column; align-items: flex-start; gap: 0; padding: 5px 15px 6px; }
.clock-main { display: flex; align-items: baseline; gap: 5px; }
.clock-main b { font-size: 25px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.clock-period { font-size: 12.5px; color: var(--ink-soft); }
.clock-date { font-size: 12px; color: var(--ink-soft); }

.player { padding: 4px 13px 4px 5px; }
.hud-avatar { width: 38px; height: 38px; flex: none; }
.hud-info { min-width: 92px; overflow: hidden; }
.hud-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.hud-top b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 104px; font-size: 14px; }
.lv {
  flex: none;
  padding: 0 7px;
  border-radius: 8px;
  background: var(--mint);
  color: #fff;
  font-size: 11.5px;
  line-height: 18px;
}
.xp { height: 8px; background: var(--line); border-radius: 5px; overflow: hidden; }
.xp-fill { height: 100%; width: 0; background: var(--sun); border-radius: 5px; transition: width .3s ease; }

.coins { padding: 7px 16px 7px 10px; font-size: 17px; font-variant-numeric: tabular-nums; flex: none; }

.visitors { display: flex; flex-wrap: wrap; gap: 5px; max-width: 60vw; }
.visitor {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px 2px 3px;
  background: rgba(253, 248, 232, .95);
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 2px 5px rgba(90, 70, 40, .18);
}
.visitor .ic { width: 22px; height: 22px; }

.visit-bar {
  position: fixed;
  top: calc(60px + var(--safe-t));
  right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 8px;
  background: #fbe9b4;
  border-radius: 20px;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 20px);
}
.visit-ic { width: 34px; height: 34px; flex: none; }
.visit-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.visit-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visit-title .sub { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- 下方列 ---------- */

.dock {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-b));
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}

.round-btn {
  position: relative;
  pointer-events: auto;
  width: 54px;
  height: 54px;
  flex: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  transition: transform .08s ease;
}
.round-btn:active { transform: scale(.94); }
.round-btn img { width: 32px; height: 32px; }
.phone-btn { width: 62px; height: 62px; background: #fff; }
.phone-btn img { width: 40px; height: 40px; }

.tray {
  pointer-events: auto;
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  padding: 4px 3px 7px;
  overflow-x: auto;
  scrollbar-width: none;
  justify-content: safe center;
}
.tray::-webkit-scrollbar { display: none; }

.seed {
  flex: none;
  width: 70px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 2px 5px;
  border: 0;
  background: var(--paper);
  border-radius: 18px;
  box-shadow: 0 3px 0 rgba(150, 125, 85, .22), 0 5px 10px rgba(90, 70, 40, .14);
  transition: transform .08s ease, background-color .12s ease;
}
.seed:active { transform: translateY(2px); }
.seed.on { background: var(--sun); transform: translateY(-3px); }
.seed.prank.on { background: #d9c8f2; }
.seed-ic { width: 36px; height: 36px; }
.seed-name { font-size: 12px; font-weight: 600; line-height: 1.2; }
.seed-count { font-size: 11px; color: var(--ink-soft); line-height: 1.3; font-variant-numeric: tabular-nums; }
.seed.on .seed-count { color: var(--ink); }

.visit-help {
  flex: 1;
  min-width: 160px;
  max-width: 340px;
  align-self: center;
  padding: 7px 12px;
  background: rgba(253, 248, 232, .95);
  border-radius: 16px;
  font-size: 12.5px;
  line-height: 1.4;
}

.badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: var(--coral);
  color: #fff;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}
.dot-badge { min-width: 14px; height: 14px; padding: 0; }

.hint, .fish-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(112px + var(--safe-b));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 7px 16px;
  background: rgba(111, 90, 65, .92);
  color: #fff8ea;
  border-radius: 16px;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
}
.hint { animation: bob 1.8s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-50%, -4px); } }
.fish-prompt { font-size: 16px; }
.fish-prompt.urgent { background: var(--coral); animation: shake .22s linear infinite; font-weight: 600; }
@keyframes shake { 25% { transform: translate(calc(-50% - 2px), 0); } 75% { transform: translate(calc(-50% + 2px), 0); } }

.harvest-all {
  position: fixed;
  right: 12px;
  bottom: calc(84px + var(--safe-b));
}
.water-all {
  position: fixed;
  right: 12px;
  bottom: calc(138px + var(--safe-b));
  background: #bfeaf6;
}
.row.special { box-shadow: inset 0 0 0 2px var(--sun); }

/* 手機與平板的虛擬搖桿 */
.stick {
  position: fixed;
  left: 14px;
  bottom: calc(86px + var(--safe-b));
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: rgba(253, 248, 232, .55);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .7), 0 4px 12px rgba(90, 70, 40, .15);
  touch-action: none;
  z-index: 3;
}
.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow);
  pointer-events: none;
}
body:has(.phone.show) .water-all, body:has(.phone.show) .harvest-all, body:has(.phone.show) .stick, body:has(.dialogue.show) .stick, body:has(.place-bar:not([hidden])) .stick, body:has(.house-bar:not([hidden])) .stick { display: none; }
body.touch .hint { bottom: calc(198px + var(--safe-b)); }
/* 和島民講話時先收起來，才不會和對話選項疊在一起 */
body:has(.dialogue.show) .harvest-all, body:has(.dialogue.show) .water-all { visibility: hidden; }

/* ---------- 佈置模式 ---------- */

.place-bar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 20px));
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 13px;
  background: var(--paper);
  border-radius: 24px;
  box-shadow: var(--shadow);
  z-index: 5;
}
.place-hint { text-align: center; }
.place-actions { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; }
.build-bar { width: min(460px, calc(100vw - 20px)); }
.build-catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.build-chip {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px; border: 2px solid transparent; border-radius: 16px;
  background: var(--paper-2); font: inherit; font-size: 13px; color: inherit; cursor: pointer;
}
.build-chip .ic { width: 26px; height: 26px; }
.build-chip .sub { font-size: 11px; opacity: 0.7; }
.build-chip.on { border-color: var(--mint); background: #e3f6ef; }
.build-chip:disabled { opacity: 0.45; cursor: default; }
.build-hint { font-size: 13px; line-height: 1.45; }
.bp-name, .bp-code { width: 100%; box-sizing: border-box; margin: 6px 0; }
.bp-import { display: flex; flex-direction: column; gap: 4px; }
.confirm-text { white-space: pre-line; }
.island-map { width: 100%; height: auto; border-radius: 18px; display: block; margin: 4px 0 8px; box-shadow: inset 0 0 0 2px var(--line); }
.map-num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: #e8826a; color: #fff; font-weight: 700; font-size: 13px; display: grid; place-items: center; }
.map-num.off { background: #a8a193; }
.row-sub { white-space: pre-line; }
.tank { flex: none; position: relative; height: 230px; border-radius: 22px; overflow: hidden; margin: 4px 0 8px; cursor: pointer;
  background: linear-gradient(#bfeaf6, #6fc3e0 60%, #4aa8cc); background-size: cover; background-position: center bottom;
  box-shadow: inset 0 0 0 4px #e9f6fb, 0 3px 0 var(--line); }
.tank.has-art { box-shadow: inset 0 0 0 3px rgba(233, 246, 251, .8), 0 3px 0 var(--line); }
/* 水裡晃動的光（有沒有背景圖都會有） */
.tank-rays { position: absolute; inset: -20% -10% 0; pointer-events: none; opacity: .35; mix-blend-mode: screen;
  background: repeating-linear-gradient(105deg, transparent 0 38px, rgba(255, 255, 255, .5) 46px, transparent 60px 96px);
  animation: rays 9s ease-in-out infinite alternate; }
@keyframes rays { from { transform: translateX(-4%) skewX(-4deg); } to { transform: translateX(4%) skewX(4deg); } }
.tank-layer { position: absolute; inset: 0; }
.tank-fish { position: absolute; left: 0; top: 0; will-change: transform; filter: drop-shadow(0 4px 3px rgba(20, 60, 90, .22)); }
.tank-fish .fish-flip { position: relative; will-change: transform; }
.tank-fish img { display: block; width: 100%; height: auto; pointer-events: none; }
.tank-fish .fish-tail { position: absolute; inset: 0; }
.tank-fish .fish-body { position: relative; }
.tank-fish .fish-lv { position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: -1px; padding: 0 4px; border-radius: 999px; background: rgba(255, 255, 255, .72); color: #2f6a8a; font-size: 9px; font-weight: 800; line-height: 12px; white-space: nowrap; pointer-events: none; }
.tank-fish.king .fish-lv { background: #ffe38a; color: #8a5a10; }
.tank-fish.king::before { content: '👑'; position: absolute; left: 50%; top: -15px; transform: translateX(-50%); font-size: 14px; line-height: 1; pointer-events: none; }
.tank-fish.levelup .fish-flip { animation: fish-levelup 1.6s ease-out 2; }
.tank-fish.levelup::after { content: '✨'; position: absolute; right: -6px; top: -10px; font-size: 16px; animation: fish-spark 1.6s ease-out 2 both; pointer-events: none; }
@keyframes fish-levelup { 0%, 100% { filter: none; } 35% { filter: brightness(1.5) drop-shadow(0 0 8px #fff3a6); } }
@keyframes fish-spark { 0% { opacity: 0; transform: translateY(6px) scale(.6); } 30% { opacity: 1; transform: translateY(-4px) scale(1.2); } 100% { opacity: 0; transform: translateY(-14px) scale(.8); } }
.aqua-actions { flex-wrap: wrap; justify-content: center; }
.aqua-full { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; }
.aqua-full .progress { flex: 1; }
.aqua-full-label { flex: none; }
.tank-food { position: absolute; left: 0; top: 0; width: 9px; height: 9px; margin: -4px 0 0 -4px; border-radius: 50%; background: #e9c77a; box-shadow: inset -1px -1px 0 #c79a45; pointer-events: none; }
img.tank-food { background: none; box-shadow: none; border-radius: 0; width: 11px; height: 11px; }
.tank-bubble { position: absolute; left: 0; top: 0; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .8); pointer-events: none; }
img.tank-bubble { border: 0; }
.tank-front, .tank-glass { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center bottom; pointer-events: none; }
.tank-sand { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; background: #ecdcaa; border-radius: 50% 50% 0 0 / 30% 30% 0 0; pointer-events: none; }
.tank-dirt { position: absolute; inset: 0; background: #7a9a4a center / cover no-repeat; pointer-events: none; }
.tank-dirt[style*="url"] { background-color: rgba(122, 154, 74, .25); }
.tank-name { position: absolute; left: 0; top: 0; padding: 2px 9px; border-radius: 999px; background: rgba(255, 255, 255, .92); font-size: 12px; font-weight: 700; pointer-events: none; transform: translate(-50%, -130%); white-space: nowrap; }
.tank-empty { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 700; }
.aqua-stats { display: flex; flex-wrap: wrap; gap: 6px 12px; justify-content: center; font-size: 13px; margin-bottom: 6px; }
.aqua-stats .warn { color: #c0533c; font-weight: 700; }
.flag { flex: none; width: 34px; text-align: center; font-size: 26px; }
.progress { height: 6px; border-radius: 3px; background: var(--paper-2); overflow: hidden; margin: 3px 0; }
.progress span { display: block; height: 100%; background: var(--mint); }
@media (prefers-reduced-motion: reduce) { .tank-fish, .tank-bubble, .tank-fish.levelup .fish-flip, .tank-fish.levelup::after { animation: none; } .tank-fish { left: 30%; } }

/* ---------- 聊天 ---------- */

.chat {
  position: fixed;
  left: 12px;
  bottom: calc(76px + var(--safe-b));
  width: min(320px, calc(100vw - 24px));
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px 13px 13px;
  background: var(--paper);
  border-radius: 22px;
  box-shadow: var(--shadow);
  z-index: 6;
}
.chat.show { display: flex; }
.chat-head { display: flex; justify-content: space-between; align-items: center; }
.chat-log {
  height: 140px;
  max-height: 26vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  user-select: text;
  -webkit-user-select: text;
}
.chat-line { overflow-wrap: anywhere; line-height: 1.4; }
.chat-line b { margin-right: 6px; color: var(--mint-dark); }
.chat-line.mine b { color: #c9894a; }
.emotes { display: flex; justify-content: space-between; }
.emote { width: 40px; height: 40px; border: 0; border-radius: 12px; background: none; font-size: 20px; }
@media (hover: hover) { .emote:hover { background: var(--paper-2); } }
.inline-form { display: flex; gap: 7px; }

input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 15px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-size: 16px; /* 小於 16px 時 iOS 會自動放大畫面 */
}
input:focus { border-color: var(--mint); outline: 0; }
input::placeholder { color: #bdae95; }

/* ---------- 手機 ---------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(70, 90, 80, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 10;
}
.scrim.show { opacity: 1; pointer-events: auto; }

.phone {
  position: fixed;
  z-index: 11;
  right: 18px;
  bottom: 18px;
  width: 380px;
  height: min(680px, calc(100vh - 36px));
  height: min(680px, calc(100dvh - 36px)); /* 手機瀏覽器的網址列縮放時，高度跟著變 */
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 38px;
  box-shadow: 0 0 0 7px #fff, 0 14px 40px rgba(60, 50, 30, .35);
  overflow: hidden;
  transform: translateY(40px) scale(.95);
  opacity: 0;
  visibility: hidden;
  transition: transform .2s cubic-bezier(.3, 1.4, .6, 1), opacity .15s ease, visibility .2s;
}
.phone.show { transform: none; opacity: 1; visibility: visible; }

.phone-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: calc(9px + var(--safe-t)) 8px 7px;
  background: var(--mint);
  color: #fff;
}
.phone-head h2 { flex: 1; margin-left: 12px; font-size: 19px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-head .x { color: #fff; font-size: 30px; }
#phoneBack + h2 { margin-left: 0; }

.phone-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px calc(22px + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.phone-body h4 { margin-top: 3px; font-size: 14px; color: var(--ink-soft); }

.phone-body.home { gap: 4px; padding-top: 10px; }
.app-group { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }
.app-group-title { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); padding: 0 6px; }
.app-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 4px; padding: 2px 0; }
.app {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  border: 0;
  background: none;
  transition: transform .08s ease;
}
@media (hover: hover) { .app:hover { transform: translateY(-2px); } }
.app:active { transform: scale(.94); }
.app-ic-wrap { position: relative; display: block; }
.app-ic { width: 56px; height: 56px; display: block; filter: drop-shadow(0 2px 2px rgba(90, 70, 40, .18)); }
.app-name { font-size: 13px; font-weight: 600; color: var(--ink); }

.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 2px 0 var(--line);
}
.row.locked { background: var(--paper-2); }
.row.locked .row-ic { filter: grayscale(.9); opacity: .6; }
.row.done { background: #e6f5e0; }
.row.me { background: #fff3c9; }
.row.log { font-size: 14px; }
.row-ic { width: 48px; height: 48px; flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-title b { overflow-wrap: anywhere; font-weight: 600; }
.row-sub { color: var(--ink-soft); font-size: 12.5px; line-height: 1.45; }
.row-actions { display: flex; align-items: center; gap: 5px; flex: none; }
.qty { color: var(--ink-soft); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.rank { width: 22px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }
.coin-tag { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; color: var(--ink); vertical-align: -3px; }

.tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.tag { display: inline-block; padding: 0 8px; border-radius: 9px; font-size: 12px; line-height: 20px; }
.tag.hot { background: #ffe0d8; color: #b4503a; }
.tag.ok { background: #dff2d5; color: #4c7f3a; }

.banner { display: flex; align-items: center; gap: 8px; padding: 9px 13px; background: #fbe9b4; border-radius: 16px; font-size: 13.5px; line-height: 1.45; }
.banner.soft { background: var(--paper-2); }
.empty { padding: 28px 14px; text-align: center; color: var(--ink-soft); line-height: 1.6; }

.avatar-wrap { position: relative; flex: none; display: flex; }
.dot { position: absolute; right: 0; bottom: 1px; width: 13px; height: 13px; border-radius: 50%; background: #62c950; border: 2px solid #fff; }

.invite-card { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 13px; background: #e3f5ec; border-radius: 22px; }
.invite-code { margin-bottom: 7px; font-size: 27px; letter-spacing: .14em; font-weight: 600; user-select: text; -webkit-user-select: text; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--paper-2); border-radius: 999px; }
.tab { flex: 1; min-height: 38px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--ink-soft); white-space: nowrap; padding-inline: 4px; }
.tabs:has(> :nth-child(5)) .tab { font-size: 13.5px; } /* 五個以上分頁（都市島）字小一點，不換行 */
.tab.on { background: #fff; color: var(--ink); box-shadow: 0 2px 4px rgba(90, 70, 40, .14); }

.hearts { display: flex; gap: 1px; margin-top: 3px; }
.heart-ic { width: 15px; height: 15px; }

.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; }
.dex-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 5px 10px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 0 var(--line);
  text-align: center;
}
.dex-card.donated { background: #eaf6e4; }
.dex-ic { width: 54px; height: 54px; }
.dex-ic.unknown { filter: brightness(0) opacity(.22); }
.dex-name { font-size: 13px; font-weight: 600; }
.dex-note { font-size: 11px; color: var(--ink-soft); line-height: 1.3; min-height: 14px; }
.dex-note.now { color: #4c9a5c; }
.dex-note.done { color: #4c7f3a; }

.mats { display: flex; flex-wrap: wrap; gap: 3px 8px; margin-top: 2px; }
.mat { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: #bb5a44; }
.mat.ok { color: var(--ink-soft); }

.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pick-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 3px;
  border: 0;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 2px 0 var(--line);
  font-size: 13px;
}
@media (hover: hover) { .pick-item:hover { background: #fff9e4; } }
.pick-ic { width: 50px; height: 50px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 600; font-size: 14px; }
.token { padding: 11px; background: #fff; border-radius: 14px; text-align: center; font-size: 15px; letter-spacing: .04em; user-select: all; -webkit-user-select: all; overflow-wrap: anywhere; }

.avatars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; }
.avatar-choice {
  aspect-ratio: 1;
  min-height: 44px;
  padding: 2px;
  background: #fff;
  border: 0;
  border-radius: 16px;
  box-shadow: 0 2px 0 var(--line);
  transition: transform .08s ease;
}
.avatar-choice.on { background: var(--sun); box-shadow: 0 2px 0 #dfb73f; transform: translateY(-2px); }
/* v2.3.3 限定角色：粉紫色的框，看得出是特別的 */
.avatar-choice.special { box-shadow: inset 0 0 0 2px #e7a6d8; background: linear-gradient(160deg, #fbe8f6, #e6f6f1); }
.avatar-choice.special.on { background: var(--sun); box-shadow: inset 0 0 0 2px #e7a6d8, 0 2px 0 #dfb73f; }
.avatar-img { width: 100%; height: 100%; display: block; }

.swatches { display: flex; gap: 7px; flex-wrap: wrap; }
.swatch { width: 40px; height: 40px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 2px 5px rgba(90, 70, 40, .22); }
.swatch.on { outline: 3px solid var(--ink); outline-offset: 1px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 38px;
  padding: 4px 14px;
  border: 0;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
  font-size: 14px;
}
.chip.on { background: var(--sun); box-shadow: 0 2px 0 #dfb73f; }

.hud-title { font-size: 11px; color: var(--ink-soft); line-height: 1.2; margin-bottom: 3px; }

.level-card { display: flex; align-items: center; gap: 10px; padding: 11px 13px; background: #fbe9b4; border-radius: 22px; }
.ach-bar { height: 8px; margin: 4px 0 2px; background: var(--line); border-radius: 5px; overflow: hidden; }
.ach-fill { height: 100%; background: var(--mint); border-radius: 5px; transition: width .3s ease; }
.medal { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; color: #fff; font-size: 20px; }
.medal.tier0 { background: #d09a6b; }
.medal.tier1 { background: #b4bcc6; }
.medal.tier2 { background: #eec34a; }
.row.wrap { flex-wrap: wrap; }
.row.wrap .row-main { min-width: 170px; }
.row.wrap .row-actions { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 7px; }
.select {
  width: 100%;
  min-height: 44px;
  padding: 8px 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px;
  font: inherit;
  font-size: 16px;
  color: inherit;
}
input.num { flex: 1; }
.mat[class*="mat"] { line-height: 1.5; }

/* ---------- 對話框 ---------- */

.dialogue {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-b));
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 20px));
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 9px;
  z-index: 8;
}
.dialogue.show { display: flex; animation: pop-in .18s cubic-bezier(.3, 1.5, .6, 1); }
@keyframes pop-in { from { transform: translate(-50%, 16px) scale(.96); opacity: 0; } }

.dialogue-choices { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.choice {
  min-height: 42px;
  padding: 7px 21px;
  border: 0;
  border-radius: 999px;
  background: var(--paper);
  box-shadow: var(--shadow);
  font-weight: 600;
}
@media (hover: hover) { .choice:hover:not(:disabled) { background: var(--sun); } }
.choice:disabled { color: #b3a48c; cursor: not-allowed; }

.dialogue-box {
  position: relative;
  width: 100%;
  min-height: 112px;
  padding: 30px 26px 21px;
  background: var(--paper);
  border-radius: 46px 46px 40px 40px / 40px 40px 46px 46px;
  box-shadow: var(--shadow);
  cursor: pointer;
}
.dialogue-name {
  position: absolute;
  top: -12px;
  left: 28px;
  padding: 3px 18px;
  border-radius: 999px;
  background: var(--sun);
  font-weight: 600;
  transform: rotate(-3deg);
  box-shadow: 0 2px 5px rgba(90, 70, 40, .2);
}
.dialogue-text { font-size: 17px; line-height: 1.55; min-height: 52px; }
/* 島民立繪（有美術圖才出現） */
.dialogue-portrait { position: absolute; left: 10px; bottom: calc(100% - 18px); width: min(150px, 34vw); height: auto; pointer-events: none; filter: drop-shadow(0 4px 6px rgba(90, 70, 40, .2)); }
.login-logo { display: block; width: min(260px, 70vw); height: auto; margin: 0 auto; }
.login.has-art { background: var(--login-wide) center / cover no-repeat; }
@media (max-aspect-ratio: 3/4) { .login.has-art { background-image: var(--login-tall); } }
.dialogue-next {
  position: absolute;
  right: 28px;
  bottom: 11px;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-top: 11px solid var(--coral);
  border-bottom: 0;
  animation: bob-arrow .7s ease-in-out infinite;
}
@keyframes bob-arrow { 50% { transform: translateY(4px); } }

/* ---------- 浮動元件 ---------- */

.tip {
  position: fixed;
  display: none;
  flex-direction: column;
  gap: 5px;
  width: 190px;
  padding: 10px 14px;
  background: var(--paper);
  border-radius: 20px;
  box-shadow: var(--shadow);
  z-index: 4;
}
.tip.show { display: flex; }
.tip-title { display: flex; align-items: center; gap: 6px; }
.tip-time { font-size: 14px; font-variant-numeric: tabular-nums; }
.tip-note { font-size: 13px; color: #b4503a; }
.tip-note.good { color: #3f8f5a; }
.tip-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }

.reveal {
  position: fixed;
  z-index: 7;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -12px) scale(.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: max-content;
  max-width: calc(100vw - 40px);
  padding: 12px 26px 15px;
  background: var(--paper);
  border-radius: 28px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.3, 1.6, .6, 1), opacity .15s ease;
}
.reveal.show { transform: translate(-50%, 0) scale(1); opacity: 1; }
.reveal-ic { width: 96px; height: 96px; }
.reveal-title { font-size: 18px; font-weight: 600; text-align: center; }
.reveal-note { font-size: 13.5px; color: var(--ink-soft); text-align: center; }

.toast {
  position: fixed;
  top: calc(14px + var(--safe-t));
  left: 50%;
  z-index: 30;
  width: max-content;
  max-width: min(420px, calc(100vw - 28px));
  padding: 9px 18px;
  background: rgba(111, 90, 65, .95);
  color: #fff8ea;
  border-radius: 16px;
  text-align: center;
  line-height: 1.4;
  opacity: 0;
  transform: translate(-50%, -8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { background: #4e9a7e; }
.toast.bad { background: #c9664f; }

.status {
  position: fixed;
  z-index: 40;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(6px + var(--safe-t)) 12px 6px;
  background: var(--ink);
  color: #fff;
  text-align: center;
  font-size: 14px;
}

.modal-wrap {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: none;
  place-items: center;
  padding: 16px;
  background: rgba(70, 90, 80, .35);
}
.modal-wrap.show { display: grid; }
.modal {
  width: min(390px, 100%);
  max-height: 85vh;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 20px;
  background: var(--paper);
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal h3 { font-size: 19px; font-weight: 600; }
.confirm-text { line-height: 1.55; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 飛行過場 ---------- */

.flight {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  background: linear-gradient(#7ccaf0, #d8f2f6);
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
  overflow: hidden;
}
.flight.show { opacity: 1; pointer-events: auto; }
.flight-plane { position: absolute; width: 110px; height: 110px; top: 34%; left: -130px; filter: drop-shadow(0 8px 10px rgba(60, 90, 110, .3)); }
.flight.show .flight-plane { animation: fly 1.3s ease-in-out forwards; }
@keyframes fly { to { left: calc(100vw + 30px); top: 24%; } }
.flight-plane.painted { width: min(300px, 62vw); height: auto; top: 30%; left: -320px; filter: drop-shadow(0 14px 14px rgba(60, 90, 110, .22)); }
.flight.show .flight-plane.painted { animation: fly-painted 1.6s ease-in-out forwards, bob .5s ease-in-out infinite alternate; }
@keyframes fly-painted { to { left: calc(100vw + 40px); top: 22%; } }
@keyframes bob { to { translate: 0 -6px; rotate: -2deg; } }
/* 飛行過場的下方是一小片海，跟島上的海同色 */
.flight::after { content: ""; position: absolute; left: -5%; right: -5%; bottom: -6%; height: 22%; border-radius: 50% 50% 0 0 / 30% 30% 0 0; background: linear-gradient(#9fe0ee, #5fc0d8); box-shadow: inset 0 6px 0 rgba(255, 255, 255, .55); }
.flight-text { position: relative; z-index: 1; margin-top: 110px; font-size: 22px; font-weight: 600; color: #fff; text-shadow: 0 2px 5px rgba(60, 90, 110, .45); }
/* 雲：圓潤、底部有一點藍灰色的陰影，像黏土捏的（跟手繪立牌同一種質感） */
.cloud { position: absolute; background: linear-gradient(#ffffff 55%, #e6f1f7); border-radius: 999px; opacity: .96; box-shadow: inset 0 -7px 0 rgba(160, 200, 222, .35), 0 10px 18px rgba(70, 120, 150, .12); }
.cloud::before, .cloud::after { content: ""; position: absolute; background: radial-gradient(circle at 40% 35%, #ffffff 60%, #eef6fa); border-radius: 50%; z-index: -1; }
.cloud::before { width: 55%; height: 170%; left: 12%; bottom: 10%; }
.cloud::after { width: 42%; height: 130%; right: 12%; bottom: 10%; }
.c1 { width: 190px; height: 48px; left: 8%; top: 18%; }
.c2 { width: 250px; height: 60px; right: 6%; top: 58%; }
.c3 { width: 150px; height: 40px; left: 30%; top: 76%; }

/* ---------- 登入 ---------- */

.login {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: none;
  place-items: center;
  overflow-y: auto;
  padding: 16px;
}
.login.show { display: grid; }
.login-card {
  width: min(410px, 100%);
  padding: 22px 24px 16px;
  background: var(--paper);
  border-radius: 40px;
  box-shadow: 0 6px 0 rgba(150, 125, 85, .24), 0 18px 44px rgba(50, 80, 70, .3);
}
.login-card h1 { margin: 0; text-align: center; font-size: 40px; letter-spacing: .08em; color: var(--mint-dark); font-weight: 600; }
.tagline { margin: 4px 0 12px; text-align: center; color: var(--ink-soft); }
.login-card .tabs { margin-bottom: 10px; }
.invite-note { margin: 0 0 12px; padding: 9px 13px; background: #fbe9b4; border-radius: 16px; font-size: 14px; line-height: 1.45; }
.login-card form { display: flex; flex-direction: column; gap: 7px; }
.login-card .label { margin-top: 5px; }
.form-error { min-height: 20px; margin: 0; color: #bb5a44; font-size: 14px; }
.link {
  display: block;
  width: 100%;
  min-height: 44px;
  margin-top: 4px;
  border: 0;
  background: none;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 14px;
}
.fine { margin: 2px 0 0; text-align: center; font-size: 12.5px; color: var(--ink-soft); }

.no-webgl { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; padding: 30px; background: var(--paper); text-align: center; font-size: 18px; line-height: 1.6; }

/* ---------- 手機螢幕 ---------- */

@media (max-width: 560px) {
  .phone { right: 0; left: 0; bottom: 0; top: 0; width: 100%; height: 100%; border-radius: 0; box-shadow: none; }
  /* 上方資訊排成一列、縮小，讓出畫面 */
  .hud { top: calc(6px + var(--safe-t)); left: 6px; right: 6px; gap: 5px; }
  .hud-left { flex-direction: row; gap: 5px; align-items: stretch; }
  .hud-card { border-radius: 14px; }
  .clock { padding: 3px 9px 4px; justify-content: center; }
  .clock-main b { font-size: 17px; }
  .clock-period { font-size: 10.5px; }
  .clock-date { font-size: 10px; }
  .player { padding: 3px 9px 3px 4px; gap: 5px; }
  .hud-avatar { width: 28px; height: 28px; }
  .hud-info { min-width: 64px; }
  .hud-top { margin-bottom: 2px; gap: 4px; }
  .hud-top b { font-size: 12px; max-width: 64px; }
  .hud-title { display: none; }
  .lv { font-size: 10px; line-height: 15px; padding: 0 5px; }
  .xp { height: 6px; }
  .coins { padding: 4px 9px; gap: 4px; }
  .coins b { font-size: 14px; }
  .coins .ic { width: 18px; height: 18px; }
  /* 下方種子列與按鈕變小 */
  .dock { left: 6px; right: 6px; bottom: calc(6px + var(--safe-b)); gap: 5px; }
  .seed { width: 52px; border-radius: 14px; padding: 3px 1px 4px; }
  .seed-ic { width: 26px; height: 26px; }
  .seed-name { font-size: 11px; }
  .seed-count { font-size: 10px; }
  .round-btn { width: 44px; height: 44px; }
  .round-btn img { width: 26px; height: 26px; }
  .phone-btn { width: 52px; height: 52px; }
  .phone-btn img { width: 32px; height: 32px; }
  .hint, .fish-prompt { font-size: 12.5px; padding: 6px 12px; bottom: calc(84px + var(--safe-b)); }
  body.touch .hint { bottom: calc(186px + var(--safe-b)); }
  .harvest-all { bottom: calc(72px + var(--safe-b)); right: 8px; }
  .water-all { bottom: calc(122px + var(--safe-b)); right: 8px; }
  .harvest-all, .water-all { padding: 7px 12px; font-size: 13px; }
  .stick { bottom: calc(76px + var(--safe-b)); left: 10px; width: 96px; height: 96px; }
  .dialogue-text { font-size: 16px; }
  .app-grid { grid-template-columns: repeat(4, 1fr); gap: 12px 4px; padding: 6px 0; }
  .app-ic { width: 56px; height: 56px; }
  .app-name { font-size: 12.5px; }
}

/* ---------- 手機橫放：螢幕很矮 ---------- */

@media (max-height: 480px) {
  .hud-left { flex-direction: row; flex-wrap: wrap; }
  .dialogue-choices { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; }
  .dialogue-box { min-height: 0; padding: 24px 22px 18px; }
  .dialogue-text { min-height: 0; font-size: 16px; }
  .chat { left: 72px; bottom: calc(10px + var(--safe-b)); }
  .chat-log { height: 96px; }
}

@media (prefers-reduced-motion: reduce) {
  .hint, .world-label.bubble, .fish-prompt.urgent, .dialogue-next { animation: none; }
  * { transition-duration: .01ms !important; }
}


/* ---------- 我的家與流星 ---------- */

.house-bar {
  position: fixed;
  left: 50%;
  top: calc(env(safe-area-inset-top, 0px) + 84px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 12px;
  background: rgba(255, 252, 244, .94);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgba(90, 70, 40, .18);
  z-index: 6;
  max-width: calc(100vw - 24px);
  flex-wrap: wrap;
  justify-content: center;
}
.house-bar[hidden] { display: none; }
.house-bar .visit-title { display: flex; flex-direction: column; min-width: 0; }
.house-bar .sub { font-size: 11.5px; }

.wish-btn {
  position: fixed;
  right: 14px;
  top: calc(env(safe-area-inset-top, 0px) + 150px);
  z-index: 6;
  background: #2d3561;
  color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 216, 77, .35), 0 6px 16px rgba(20, 24, 60, .35);
  animation: wishPulse 1.1s ease-in-out infinite;
}
.wish-btn[hidden] { display: none; }
@keyframes wishPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }

.stars { color: #e8b93c; letter-spacing: 2px; font-size: 18px; }
.stars .off { color: #d9d2c2; }
.recipe-locked { opacity: .55; }
.room-grid { display: grid; gap: 2px; }
.style-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.style-pick .pick-item { min-width: 86px; }
.roadmap { display: flex; flex-direction: column; gap: 6px; }
.roadmap-row { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.roadmap-row b { flex: none; min-width: 44px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.roadmap-row.now b { color: #4c7f3a; }
.roadmap-row.past { opacity: .55; }

@media (max-height: 480px) {
  .house-bar { top: calc(env(safe-area-inset-top, 0px) + 60px); }
}

/* ---------- 手作材質選單（v1.9，Codex 畫的毛氈、紙張、木框）----------
   有那張圖時 <html> 會加上 skin-<名字>，沒有就照舊用上面的色塊 */
.skin-paper .phone, .skin-paper .modal, .skin-paper .hud-card, .skin-paper .chat {
  background-image: var(--skin-paper);
  background-size: 256px 256px;
}
.skin-wallpaper .phone-body:has(> .app-grid) {
  background: var(--skin-wallpaper) center top / cover no-repeat;
}
.skin-head .phone-head {
  background: var(--skin-head) center / 100% 100% no-repeat, var(--mint);
  padding-bottom: 12px;
}
.skin-card .row {
  background: none;
  border: 9px solid transparent;
  border-image: var(--skin-card) 48 fill / 14px stretch;
  border-image-outset: 4px;
  box-shadow: none;
  padding: 0 3px;
}
.skin-card .row.locked { filter: saturate(.6) brightness(.97); }
.skin-card .row.done { background: none; filter: hue-rotate(-25deg) saturate(1.1); }
.skin-btn-sun .btn:not(.ghost):not(.danger):not(.danger-ghost) {
  background: none;
  border: 0 solid transparent;
  border-width: 8px 14px;
  border-image: var(--skin-btn-sun) 40 64 fill / 13px 22px stretch;
  border-image-outset: 3px 2px;
  box-shadow: none;
  padding: 0 4px;
}
.skin-btn-sun .btn:not(.ghost):not(.danger):not(.danger-ghost):disabled { filter: grayscale(.85) opacity(.7); }
.skin-btn-cream .btn.ghost, .skin-btn-cream .choice {
  background: none;
  border: 0 solid transparent;
  border-width: 8px 14px;
  border-image: var(--skin-btn-cream) 40 64 fill / 13px 22px stretch;
  border-image-outset: 3px 2px;
  box-shadow: none;
}
.skin-btn-cream .btn.ghost { padding: 0 4px; }
.skin-btn-cream .choice { padding: 0 6px; }
.skin-btn-sun .choice:hover:not(:disabled) { border-image-source: var(--skin-btn-sun); background: none; }
.skin-dialog .dialogue-box {
  background: none;
  border: 32px solid transparent;
  border-image: var(--skin-dialog) 96 fill / 32px stretch;
  box-shadow: none;
  border-radius: 0;
  padding: 10px 12px 4px;
}
.skin-nametag .dialogue-name {
  background: none !important;
  border: 0 solid transparent;
  border-width: 8px 20px;
  border-image: var(--skin-nametag) 30 64 fill / 8px 20px stretch;
  box-shadow: none;
  padding: 0 4px;
}
.skin-modal .modal {
  background: none;
  border: 30px solid transparent;
  border-image: var(--skin-modal) 96 fill / 30px stretch;
  border-radius: 0;
  padding: 4px;
}
.skin-tabs .tabs {
  background: none;
  border: 0 solid transparent;
  border-width: 0 14px;
  border-image: var(--skin-tabs) 0 48 fill / 0 14px stretch;
}
.skin-tab-on .tab.on {
  background: none;
  border: 0 solid transparent;
  border-width: 0 12px;
  border-image: var(--skin-tab-on) 0 40 fill / 0 12px stretch;
  box-shadow: none;
}
.skin-close #phoneClose, .skin-close #chatClose, .skin-close .modal .x {
  width: 38px; height: 38px; font-size: 0;
  background: var(--skin-close) center / contain no-repeat;
}
.skin-back #phoneBack {
  width: 38px; height: 38px; font-size: 0;
  background: var(--skin-back) center / contain no-repeat;
}
.skin-leaves .phone::after {
  content: '';
  position: absolute;
  left: -10px;
  top: 44px;
  width: 84px;
  height: 42px;
  transform: rotate(-12deg);
  background: var(--skin-leaves) center / contain no-repeat;
  pointer-events: none;
  opacity: .9;
}

.skin-btn-sun .row-actions { gap: 8px; }
/* 對話框有木框時，名字牌要往上移到框上（絕對定位是從框的內側算起） */
.skin-dialog .dialogue-name { top: -46px; left: 0; }
.skin-dialog .dialogue-next { right: -4px; bottom: -14px; }
.skin-dialog .dialogue-portrait { left: -22px; bottom: calc(100% - 6px); width: min(120px, 28vw); }
.church-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 3px 1px 1px; vertical-align: middle; box-shadow: 0 0 0 1.5px #fff; }

/* ---------- 節期活動 ---------- */
.event-card { position: relative; border-radius: 20px; overflow: hidden; background: #fff8e8; box-shadow: 0 2px 0 var(--line); padding: 0 0 10px; }
.event-banner { display: block; width: 100%; height: 96px; object-fit: cover; }
.event-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 13px 2px; font-size: 17px; }
.event-card > .sub { padding: 0 13px; }
.event-thanksgiving { background: #fff1df; }
.event-advent { background: #f1ebf8; }
.event-anniversary { background: #fff6d6; }
.advent-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.advent-door { aspect-ratio: 1; border: 0; border-radius: 12px; background: #e6dcf2; color: #7a6a94; font-weight: 700; font-size: 15px; box-shadow: 0 2px 0 #cfc2e2; display: grid; place-items: center; padding: 3px; }
.advent-door.big { background: #f6e2a8; color: #8a6a2a; }
.advent-door.ready { background: #8a6fc4; color: #fff; box-shadow: 0 3px 0 #6b52a6; animation: door-glow 1.6s ease-in-out infinite; }
.advent-door.open { background: #fff; box-shadow: 0 2px 0 var(--line); }
.advent-door .ic { width: 70%; height: 70%; }
.advent-door:disabled:not(.open) { opacity: .75; }
@keyframes door-glow { 50% { transform: translateY(-2px); } }
.chip.on { background: var(--sun); }

/* 指南 */
.guide-h { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 15px; color: var(--ink); }
.guide-h-ic { width: 34px; height: 34px; object-fit: contain; flex: none; }
.guide-sec { display: flex; flex-direction: column; gap: 8px; padding: 2px 0 10px; }
.guide-lines { display: flex; flex-direction: column; gap: 7px; }
.guide-line { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.guide-ic { width: 30px; height: 30px; flex: none; object-fit: contain; margin-top: -2px; }
.guide-ic.emoji { font-size: 22px; line-height: 30px; text-align: center; }
.guide-strip-wrap { background: var(--paper-2); border-radius: 16px; padding: 8px 10px 6px; }
.guide-strip-title { font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; }
.guide-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.guide-chip { flex: none; width: 66px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.guide-chip-ic { width: 46px; height: 46px; object-fit: contain; }
.guide-chip-ic.emoji { font-size: 30px; line-height: 46px; }
.guide-chip-name { font-size: 11.5px; font-weight: 600; line-height: 1.2; }
.guide-chip-sub { font-size: 10.5px; color: var(--ink-soft); line-height: 1.2; }
.guide-sub-title { font-size: 12px; color: var(--ink-soft); margin: 6px 0 3px; }
.guide-mat .guide-line { font-size: 12.5px; }
.guide-mat .guide-ic { width: 24px; height: 24px; }
.guide-uses { display: flex; flex-wrap: wrap; gap: 4px; }
.guide-use { display: inline-flex; align-items: center; gap: 3px; padding: 2px 7px 2px 3px; background: #fff; border-radius: 10px; font-size: 11.5px; box-shadow: 0 1px 0 var(--line); }
.guide-use-ic { width: 20px; height: 20px; object-fit: contain; }
.guide-use-ic.emoji { font-size: 15px; line-height: 20px; }

/* 魔法掃帚與世界地圖 */
.broom-btn { position: fixed; right: 18px; bottom: 150px; z-index: 6; background: #c9b1ec; color: #fff; }
.broom-btn.on { background: var(--sun); color: var(--ink); }
.btn.job-chip { position: fixed; right: 18px; bottom: 206px; z-index: 6; display: flex; flex-direction: column; align-items: center; gap: 0; line-height: 1.15; background: #6fa8dc; color: #fff; min-width: 84px; }
.job-chip small { font-size: 11px; opacity: .92; font-variant-numeric: tabular-nums; }
.btn.job-chip.ready { background: var(--mint, #58b388); animation: job-pulse 1.2s ease-in-out infinite; }
@keyframes job-pulse { 50% { transform: scale(1.06); } }
.world-label.name.isle { background: rgba(253, 248, 232, .95); font-weight: 600; font-size: 13px; padding: 2px 12px; }
.world-label.name.isle.locked { background: rgba(170, 176, 180, .9); color: #fff; }
@media (max-width: 560px) { .broom-btn { bottom: 176px; right: 12px; } .btn.job-chip { bottom: 232px; right: 12px; } }
.chip.off { opacity: .5; }

/* 都市島店舖室內：客人頭上的泡泡（要的用品＋耐心條；服務中是進度條） */
.world-label.bubble.want { width: 58px; height: 52px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 3px 0 5px; }
.world-label.bubble.want img { width: 26px; height: 26px; }
.world-label.bubble.want .cbar { width: 40px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .12); overflow: hidden; }
.world-label.bubble.want .cbar i { display: block; height: 100%; background: var(--mint); border-radius: 3px; transition: width .4s linear; }
.world-label.bubble.want.mood-ok .cbar i { background: #f0c050; }
.world-label.bubble.want.mood-angry .cbar i { background: #e8705a; }
.world-label.bubble.want.mood-angry { background: #fde4df; }
.world-label.bubble.want.serving { background: #e3f6ec; }
.world-label.bubble.want.serving .cbar i { background: #58b388; }
body.in-shop .btn.job-chip { z-index: 30; }

/* v2.4.1 設定：稱號選擇（換上的稱號取代等級稱號） */
.title-choices { display: flex; flex-wrap: wrap; gap: 6px; }

/* v2.4.2 設定：角色造型（皮膚）選擇 */
.skin-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.skin-choice { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 8px; border-radius: 12px; border: 2px solid transparent; background: rgba(255, 255, 255, 0.6); font: inherit; font-size: 13px; cursor: pointer; }
.skin-choice .avatar-img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.skin-choice.on { border-color: #e2a33a; background: #fff6df; }

/* v2.4.5 漂流瓶：島上的浮動標籤＋可以點的提示 */
.world-label.bottle-tag { background: #fff8e1; color: #7a4a12; border: 2px solid #f2b84b; border-radius: 999px; padding: 3px 10px; font-weight: 700; font-size: 13px; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); animation: bottle-bob 1.6s ease-in-out infinite; }
@keyframes bottle-bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -6px; } }
.hint.tap { cursor: pointer; pointer-events: auto; text-decoration: underline; text-underline-offset: 3px; }
