:root {
  color-scheme: light;
  --bg: #f7f4e8;
  --surface: #fffcf4;
  --ink: #1c3843;
  --muted: #47616a;
  --teal: #166072;
  --teal-dark: #114a5b;
  --rule: #dcdcca;
  --coral: #a34138;
  --sand: #f6e4ba;
  --green: #dbeacf;
  --blue: #d2e9ec;
  --pink: #f3dcd7;
  --lilac: #eae1ed;
  font-family: "PingFang TC", "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; color: var(--ink); background: var(--bg); padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; }
button { color: inherit; font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
button, a { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 4px; }
h1, h2, h3, p { margin: 0; }
img { max-width: 100%; display: block; }

.top, main { width: min(100% - 3rem, 1080px); margin-inline: auto; }
.top {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  min-height: 78px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--rule);
}
.brand { display: inline-flex; align-items: center; gap: .64rem; font-size: 1.08rem; font-weight: 900; text-decoration: none; }
.brand img { border-radius: 12px; }
.offline {
  display: inline-flex; align-items: center; gap: .38rem; min-height: 44px; border: 1px solid var(--rule);
  background: var(--surface); border-radius: 99px; padding: .45rem .85rem; color: var(--muted); font-size: .82rem; font-weight: 800;
}
.offline span { font-size: .6rem; color: var(--coral); }
.offline.ready { background: var(--green); border-color: transparent; color: var(--ink); }
.offline.ready span { color: #2e7555; }
.eyebrow { display: flex; gap: .48rem; align-items: center; color: var(--teal); font-size: .82rem; font-weight: 900; letter-spacing: .09em; }
.route-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--coral); }
.route-line { width: 23px; border-top: 1px dashed currentColor; }

.hero { display: grid; align-items: center; grid-template-columns: .9fr 1.1fr; padding-block: clamp(2.2rem, 5vw, 4.5rem); gap: clamp(1rem, 4vw, 4rem); }
.hero h1 { font-size: clamp(2.5rem, 6vw, 4.25rem); letter-spacing: -.07em; line-height: 1.13; margin-block: .9rem 1.05rem; font-weight: 900; }
.hero h1 span { color: var(--teal); }
.hero-copy { color: var(--muted); line-height: 1.8; font-size: clamp(.94rem, 1.8vw, 1.1rem); }
.hero-button { margin-top: 1.4rem; }
.hero-button span { padding-inline-start: .7rem; font-weight: 500; }
.hero-art { width: 100%; border-radius: 36px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 50px;
  border: 1px solid transparent; border-radius: 14px; padding: .55rem 1rem;
  text-decoration: none; font-size: .95rem; line-height: 1.3; font-weight: 850; text-align: center;
}
.primary { color: #fffdf4; background: var(--teal); }
.primary:hover:not(:disabled) { background: var(--teal-dark); }
.secondary { background: var(--surface); border-color: var(--rule); }
.secondary:hover:not(:disabled), .secondary[aria-pressed="true"] { background: var(--blue); border-color: var(--teal); }

.selection { padding-bottom: 2.8rem; }
.selection header { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; margin-bottom: 1.15rem; }
.selection h2 { margin-top: .3rem; font-size: clamp(1.65rem, 3.5vw, 2.2rem); letter-spacing: -.05em; }
.mini-count { color: var(--muted); font-size: .8rem; white-space: nowrap; padding-bottom: .35rem; }
.games { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; }
.tile-listen { --tile: var(--green); }
.tile-surf { --tile: var(--lilac); }
.tile-feed { --tile: var(--blue); }
.tile-say { --tile: var(--lilac); }
.tile-count { --tile: var(--sand); }
.tile-match { --tile: var(--pink); }
.tile-japanese { --tile: var(--blue); }
.game { display: block; min-width: 0; text-decoration: none; border-radius: 18px; background: var(--surface); border: 1px solid var(--rule); overflow: hidden; }
.tile-picture { position: relative; display: grid; place-items: center; background: var(--tile); min-height: 108px; aspect-ratio: 1.65; }
.tile-picture img { width: 62%; max-width: 145px; height: auto; transition: transform .2s ease; }
.game:hover .tile-picture img { transform: translateY(-4px) rotate(-5deg); }
.game-number { position: absolute; top: .62rem; left: .7rem; color: var(--muted); font-size: .70rem; font-weight: 900; letter-spacing: .12em; }
.tile-description { min-height: 109px; padding: .75rem .7rem; position: relative; }
.tag { color: var(--teal); font-weight: 850; font-size: .74rem; }
.tile-description h3 { font-size: clamp(.91rem, 1.65vw, 1.1rem); letter-spacing: -.05em; margin-top: .22rem; }
.tile-description p { font-size: .76rem; color: var(--muted); line-height: 1.6; margin-top: .2rem; padding-inline-end: .7rem; }
.tile-arrow { position: absolute; right: .57rem; top: .69rem; color: var(--teal); font-size: .85rem; }
.at-home {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: 1rem 1.2rem; margin-bottom: 1.8rem; background: var(--lilac); border-radius: 18px;
}
.at-home h2 { margin-block: .2rem; font-size: 1.4rem; }
.at-home p:last-child { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.at-home .button { flex: none; }
footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: .76rem; padding-block: 1.3rem 2.3rem; }

dialog { border: 1px solid var(--rule); border-radius: 22px; background: var(--surface); color: var(--ink); max-width: min(540px, 100% - 2rem); padding: 1.5rem; }
dialog::backdrop { background: #1c384388; }
dialog h2 { margin-block: .4rem .75rem; font-size: 1.6rem; padding-inline-end: 2rem; }
dialog p, dialog li { line-height: 1.65; }
dialog ol { padding-inline-start: 1.4rem; }
dialog li + li { margin-top: .5rem; }
.close { float: right; border: 1px solid var(--rule); border-radius: 12px; background: var(--bg); min-width: 44px; min-height: 44px; font-size: 1.4rem; }
.privacy { color: var(--muted); font-size: .82rem; text-align: center; padding: 1rem .3rem .4rem; }
.credits { color: var(--muted); font-size: .8rem; margin-top: .45rem; }
.credits > summary { cursor: pointer; padding-block: .65rem; }

.activity { width: min(100%, 840px); padding-block: 1rem 3rem; margin-inline: auto; }
.back { display: inline-flex; min-height: 45px; align-items: center; color: var(--teal); font-weight: 850; text-decoration: none; margin-bottom: .35rem; }
.back:hover { text-decoration: underline; }
.activity-head { display: flex; align-items: center; justify-content: space-between; gap: .4rem; background: var(--tile); border-radius: 22px; padding: clamp(1rem, 3vw, 1.7rem); margin-bottom: 1.1rem; }
.activity-head h1 { font-size: clamp(1.78rem, 5vw, 3.2rem); line-height: 1.15; margin-block: .28rem .63rem; letter-spacing: -.06em; }
.activity-head p:last-child { color: var(--muted); line-height: 1.6; }
.activity-head img { width: clamp(65px, 17vw, 150px); }
.inline-message { color: var(--coral); text-align: center; font-size: .9rem; min-height: 1.4rem; }
.ear { display: grid; place-items: center; color: var(--teal); background: var(--surface); width: 2.8rem; height: 2.8rem; border-radius: 50%; }
.animal-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .8rem; }
.animal { border: 1px solid var(--rule); border-radius: 21px; background: var(--surface); min-height: 184px; padding-block: 1rem; display: grid; justify-items: center; align-content: center; }
.animal img { width: min(88%, 180px); }
.animal strong { font-size: clamp(1.2rem, 4vw, 1.7rem); }
.small-zhuyin { font-size: 1rem; color: var(--teal); }
.animal .ear { margin-top: .55rem; background: var(--bg); }
.animal-turtle.chosen { background: var(--green); border-color: var(--teal); }
.animal-fish.chosen { background: var(--sand); border-color: var(--teal); }
.animal-shark.chosen { background: var(--blue); border-color: var(--teal); }

.surf-board, .feed-board, .say-board, .count-board, .match-board { border: 1px solid var(--rule); border-radius: 20px; padding: clamp(.8rem, 3vw, 1.7rem); background: var(--surface); }
.lesson-tabs { display: flex; gap: .5rem; align-items: center; }

.pronunciation-actions { display: flex; gap: .55rem; justify-content: center; flex-wrap: wrap; }
.practice-status { min-height: 2.4rem; padding-top: .65rem; color: var(--muted); font-size: .92rem; line-height: 1.55; text-align: center; }
.tone-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .4rem; }
.tone-button { flex-direction: column; padding-inline: .2rem; gap: .12rem; }
.tone-button strong { font-size: clamp(1.04rem, 4vw, 1.5rem); }
.tone-button span { font-size: .75rem; }
.surf-heading { display: flex; align-items: baseline; justify-content: space-between; gap: .5rem; padding: .85rem 0 .5rem; }
.surf-heading h2 { font-size: clamp(1.45rem, 5vw, 2.2rem); letter-spacing: .02em; }
.surf-heading span { color: var(--muted); font-size: .84rem; }
.surf-sea { display: block; width: 100%; border-radius: 16px; margin-bottom: .9rem; background: var(--blue); }
.surf-ripples, .surf-guide, .surf-trail { fill: none; stroke-linecap: round; }
.surf-ripples { stroke: var(--surface); stroke-width: 1.5; }
.surf-guide { stroke: var(--teal); stroke-opacity: .72; stroke-dasharray: 4 5; stroke-width: 2.5; }
.surf-trail { stroke: var(--coral); stroke-width: 3; }
.surfboard { fill: var(--coral); }
.feed-counter { display: flex; justify-content: space-between; gap: .45rem; align-items: center; color: var(--teal); }
.feed-counter span { background: var(--blue); border-radius: 99px; padding: .3rem .65rem; font-weight: 850; }
.feed-turtle { display: grid; place-items: center; margin-bottom: .45rem; }
.feed-turtle img { width: clamp(85px, 20vw, 140px); }
.feed-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; margin-top: 1rem; }
.fish-answer { display: grid; grid-template-columns: 1fr; justify-items: center; padding: .55rem; border: 2px solid var(--rule); border-radius: 16px; background: var(--sand); }
.fish-answer:nth-child(2) { background: var(--pink); }
.fish-answer img { width: clamp(60px, 14vw, 108px); }
.fish-answer strong { font-size: clamp(1.2rem, 5vw, 2rem); }
.fish-answer.fed-fish { background: var(--green); border-color: var(--teal); }
.say-picture { display: grid; place-items: center; padding: .5rem; border-radius: 16px; background: var(--blue); }
.say-picture img { width: clamp(125px, 36vw, 260px); }
.say-board h2 { margin-block: .55rem 1rem; text-align: center; font-size: clamp(1.6rem, 6vw, 2.85rem); }

.count-board header, .match-controls { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.count-board header { font-weight: 800; color: var(--muted); }
.count-board header strong { color: var(--teal); font-size: 1.6rem; }
.turtles { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .55rem; padding-block: .85rem; min-height: 160px; }
.count-turtle { display: grid; aspect-ratio: 1.12; place-items: center; position: relative; min-height: 56px; border-radius: 15px; border: 1px solid var(--rule); background: var(--bg); }
.count-turtle[aria-pressed="true"] { background: var(--green); border-color: var(--teal); }
.count-turtle span:not(:empty) { position: absolute; left: .3rem; top: .3rem; border-radius: 50%; background: var(--teal); color: var(--surface); display: grid; place-items: center; width: 1.5rem; height: 1.5rem; font-size: .78rem; font-weight: 900; }
.count-turtle img { width: 95%; }
.count-footer { min-height: 50px; display: flex; align-items: center; gap: .5rem; justify-content: space-between; color: var(--muted); }

.match-status { margin-block: .9rem .65rem; color: var(--teal); font-weight: 850; }
.deck { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; }
.match-card { min-height: 60px; position: relative; aspect-ratio: 1.3; display: grid; place-items: center; border-radius: 14px; background: var(--teal); color: var(--surface); border: 2px solid transparent; }
.match-card img { visibility: hidden; width: 90%; max-height: 100%; object-fit: contain; }
.card-back { position: absolute; color: var(--blue); font-size: clamp(1.45rem, 6vw, 2.5rem); font-weight: 900; }
.match-card.face { background: var(--sand); border-color: var(--rule); }
.match-card.face .card-back { visibility: hidden; }
.match-card.face img { visibility: visible; }
.match-card.matched { background: var(--green); border-color: var(--teal); }

.phrases { display: grid; gap: .65rem; }
.phrase { display: grid; grid-template-columns: 78px 1fr auto; gap: 1rem; align-items: center; text-align: left; background: var(--surface); border-radius: 14px; border: 1px solid var(--rule); padding: .5rem 1rem; min-height: 74px; }
.phrase:hover { border-color: var(--teal); }
.phrase strong, .phrase small { display: block; }
.phrase strong { font-size: clamp(1.15rem, 3.5vw, 1.6rem); }
.phrase small { color: var(--muted); margin-top: .2rem; }
.phrase .ear { background: var(--blue); }
@media (max-width: 770px) {
  .hero-art { border-radius: 25px; }
}
@media (max-width: 540px) {
  .top, main { width: min(100% - 1.75rem, 1080px); }
  .top { min-height: 66px; }
  .hero { grid-template-columns: 1fr; padding-block: 1.6rem 2.2rem; }
  .hero-art { border-radius: 21px; }
  .games { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-description { min-height: 101px; }
  .at-home { padding: .85rem; }
  .turtles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .animal-grid { gap: .35rem; }
  .animal { min-height: 132px; border-radius: 14px; }
  .animal .ear { width: 2rem; height: 2rem; margin-top: .3rem; }
  .animal img { width: 96%; }
  .deck { gap: .37rem; }
  .match-card { border-radius: 10px; }
  .phrase { grid-template-columns: 48px 1fr auto; gap: .5rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
