:root {
  --paper: #F7F3E8;
  --sea: #183B56;
  --teal: #568F9A;
  --gold: #E9B85B;
  --seal: #B84A3A;
  --ok: #2f7d5b;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 17px;
  line-height: 1.6;
  color: var(--sea);
  background: var(--sea);
}
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  position: relative;
  max-width: 520px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper) center / cover no-repeat;
  transition: background-image .4s;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  flex-direction: column;
  gap: 14px;
}
.screen.active { display: flex; animation: fadeIn .35s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.panel {
  background: rgba(247, 243, 232, .94);
  border-radius: var(--radius);
  padding: 20px 18px;
  box-shadow: 0 6px 24px rgba(24, 59, 86, .18);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel.center { text-align: center; align-items: center; }
h2 { margin: 0; font-size: 22px; line-height: 1.35; }
p { margin: 0; }
.small, .note { font-size: 15px; color: #3d5a70; }
.story { font-size: 18px; }

/* 按钮：最小 48px 点击区域 */
.btn {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 2px solid var(--sea);
  border-radius: 999px;
  background: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .1s, background .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--sea); color: var(--paper); }
.btn.ghost { background: transparent; border-color: var(--teal); color: var(--sea); }
.btn:focus-visible, .opt:focus-visible, .icon-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.icon-btn {
  min-width: 48px; min-height: 48px;
  border: 0; border-radius: 50%;
  background: rgba(247, 243, 232, .9);
  font-size: 22px; cursor: pointer;
}
.sound-btn { position: absolute; z-index: 5; top: calc(10px + var(--safe-top)); right: 10px; }

/* 首页 */
.home-top { text-align: center; padding-top: 28px; }
.logo { width: 76px; height: 76px; object-fit: cover; border-radius: 50%; background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.game-title { margin: 10px 0 0; color: var(--paper); text-shadow: 0 2px 8px rgba(24,59,86,.7); line-height: 1.2; }
.game-title span { display: block; font-size: 40px; letter-spacing: 4px; }
.game-title small { display: block; font-size: 20px; letter-spacing: 6px; margin-top: 6px; }
.swallow { width: 220px; align-self: center; filter: drop-shadow(0 6px 10px rgba(24,59,86,.25)); }
.swallow.small { width: 84px; flex: none; }
.swallow-float { animation: float 3s ease-in-out infinite; margin-top: auto; }
@keyframes float { 50% { transform: translateY(-10px); } }
.home-panel { text-align: center; }
.lead { font-size: 17px; }
.slogan { color: var(--seal); font-weight: 700; letter-spacing: 2px; }
/* 难度卡片 */
.diff-list { display: flex; flex-direction: column; gap: 12px; }
.diff-card {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 4px 12px;
  align-items: center;
  width: 100%;
  padding: 14px;
  border: 2px solid var(--c, var(--teal));
  border-radius: var(--radius);
  background: #fff;
  text-align: left;
  cursor: pointer;
}
.diff-card img { grid-row: span 3; width: 64px; height: 64px; object-fit: contain; }
.diff-card b { font-size: 19px; }
.diff-card .rec { font-size: 13px; color: #fff; background: var(--seal); border-radius: 6px; padding: 1px 6px; margin-left: 6px; vertical-align: 2px; }
.diff-card span { font-size: 15px; }
.diff-card em { font-style: normal; font-size: 14px; color: var(--c); font-weight: 700; }

/* HUD */
.hud { background: rgba(247,243,232,.94); border-radius: var(--radius); padding: 10px 14px; padding-right: 64px; }
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.hud-level { font-weight: 700; }
.tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--sea); color: var(--paper); white-space: nowrap; }
.dots { display: flex; gap: 6px; list-style: none; margin: 6px 0 0; padding: 0; }
.dots li { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--teal); }
.dots li.done { background: var(--teal); }
.dots li.guided { background: var(--gold); border-color: var(--gold); }
.dots li.now { border-color: var(--seal); transform: scale(1.2); }
.mini-tower { display: flex; flex-direction: column-reverse; gap: 2px; }
.mini-tower i { display: block; width: 18px; height: 7px; border-radius: 2px; background: #c9c2b0; }
.mini-tower i.on { background: var(--gold); box-shadow: 0 0 8px var(--gold); }

/* 海燕陪伴 */
.buddy { display: flex; align-items: flex-end; gap: 8px; }
.buddy .swallow { transition: transform .3s; }
.buddy .swallow.bounce { animation: bounce .5s; }
@keyframes bounce { 40% { transform: translateY(-12px) rotate(-6deg); } }
.bubble {
  position: relative;
  flex: 1;
  background: #fff;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(24,59,86,.15);
}

/* 题目卡片 */
.card { background: rgba(247,243,232,.96); border-radius: var(--radius); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 6px 24px rgba(24,59,86,.18); }
.q-type { font-size: 13px; color: var(--teal); font-weight: 700; letter-spacing: 1px; }
.q-text { font-size: 18px; font-weight: 600; }
.q-note { font-size: 14px; color: #5b6f7e; }
.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid #cfd8dc;
  border-radius: 12px;
  background: #fff;
  text-align: left;
  font-size: 17px;
  line-height: 1.5;
  cursor: pointer;
}
.opt.sel { border-color: var(--sea); background: #e8eef2; }
.opt.right { border-color: var(--ok); background: #e3f3ea; }
.opt.wrong { border-color: var(--seal); background: #fbe9e6; animation: shake .3s; }
.opt.dim { opacity: .4; }
.opt.glow { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(233,184,91,.4); }
.opt:disabled { cursor: default; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.pair-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair-cols .opts { gap: 8px; }
.pair-cols .opt { text-align: center; font-size: 16px; padding: 10px 6px; }
.opt.matched { border-color: var(--ok); background: #e3f3ea; color: #2b5a45; }

.order-line { min-height: 56px; padding: 10px; border: 2px dashed var(--teal); border-radius: 12px; background: #fff; font-size: 18px; }
.order-line:empty::before { content: "依次点击下方词块组成句子"; color: #8aa0ad; font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .opt { width: auto; min-width: 64px; text-align: center; }

.clues { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.clues li { background: #fff; border-left: 4px solid var(--gold); border-radius: 6px; padding: 6px 10px; animation: fadeIn .3s; }

.hint-box { background: #fff7e3; border: 1px solid var(--gold); border-radius: 12px; padding: 10px 12px; font-size: 15px; }
.hint-box b { color: #8a5d0b; }
.actions { display: flex; gap: 10px; }
.actions .btn { flex: 1; min-height: 48px; font-size: 16px; }
.link-btn { background: none; border: 0; color: var(--teal); text-decoration: underline; font-size: 15px; min-height: 44px; cursor: pointer; }

.feedback { font-weight: 700; }
.feedback.ok { color: var(--ok); }
.feedback.bad { color: var(--seal); }
.explain { font-size: 15px; background: #fff; border-radius: 10px; padding: 8px 10px; }

/* 灯塔 */
.tower { display: flex; flex-direction: column; align-items: center; margin: 10px 0; }
.tower .lamp { width: 34px; height: 30px; border-radius: 50% 50% 4px 4px; background: #9aa5ab; transition: all .6s; }
.tower .seg { height: 36px; margin-top: 3px; background: #c9c2b0; border-radius: 3px; transition: all .6s; }
.tower .s3 { width: 46px; } .tower .s2 { width: 58px; } .tower .s1 { width: 70px; }
.tower .base { width: 100px; height: 12px; margin-top: 3px; border-radius: 4px; background: var(--sea); }
.tower .seg.on { background: var(--gold); box-shadow: 0 0 18px var(--gold); }
.tower.lit .lamp { background: #fff3c4; box-shadow: 0 0 30px 12px var(--gold); }

/* 通关 */
.my-line { font-size: 19px; font-weight: 700; color: var(--sea); background: #fff; border-radius: 12px; padding: 10px 14px; border: 2px solid var(--gold); }
.badge { width: 120px; height: 120px; object-fit: contain; }
.title-name { font-size: 20px; font-weight: 700; color: var(--seal); }
.lottery { width: 100%; background: var(--sea); color: var(--paper); border-radius: 12px; padding: 12px; }
.lottery .small { color: #d5e2ea; }
.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 15px; }
.card-out img { width: 100%; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,.2); -webkit-touch-callout: default; }

#clubInfo { display: flex; flex-direction: column; gap: 10px; }
#clubInfo h3 { margin: 6px 0 0; font-size: 17px; color: var(--seal); }
#clubInfo .qr { width: 180px; align-self: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
