/* 句子岛的样子。颜色只用这里的变量：底色和文字是 Flexoki（~/dotfiles/references/web-colors-flexoki.md），
   游戏用的六个亮色也取自 Flexoki 色板。换画风只改这一段变量和下面的「形状」几个量。 */
/* Flexoki 2.0 (c) 2023 Steph Ango, MIT. https://stephango.com/flexoki */
:root {
  color-scheme: light dark;
  --bg: #FFFCF0; --bg-2: #F2F0E5; --ui: #E6E4D9; --ui-2: #DAD8CE; --ui-3: #CECDC3; --border-input: #878580;
  --tx: #100F0F; --tx-2: #575653; --tx-3: #B7B5AC;
  --accent: #1C6C66; --on-accent: #FFFCF0; --accent-bg: #DDF1E4;
  --success: #536907; --success-bg: #EDEECF; --error: #AF3029; --error-bg: #FFE1D5; --warning: #9D4310; --warning-bg: #FFE7CE;
  --c-green: #66800B; --c-green-d: #536907; --c-yellow: #D0A215; --c-orange: #DA702C; --c-red: #D14D41; --c-blue: #4385BE; --c-purple: #8B7EC8; --c-cyan: #3AA99F;
  --line: #100F0F;
  /* 形状 */
  --r: 16px; --bw: 2px; --drop: 4px;
  --font: ui-rounded, "SF Pro Rounded", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #100F0F; --bg-2: #1C1B1A; --ui: #282726; --ui-2: #343331; --ui-3: #403E3C; --border-input: #6F6E69;
    --tx: #CECDC3; --tx-2: #9F9D96; --tx-3: #575653;
    --accent: #3AA99F; --on-accent: #100F0F; --accent-bg: #101F1D;
    --success: #879A39; --success-bg: #1A1E0C; --error: #E8705F; --error-bg: #261312; --warning: #EC8B49; --warning-bg: #27180E;
    --c-green: #879A39; --c-green-d: #66800B; --line: #403E3C;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--tx); font: 16px/1.5 var(--font); overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

#shell { display: flex; min-height: 100dvh; }
#app { flex: 1; min-width: 0; padding: calc(16px + var(--safe-t)) 16px calc(88px + var(--safe-b)); max-width: 760px; margin: 0 auto; width: 100%; }
body.full #nav { display: none; }
body.full #app { padding-bottom: calc(16px + var(--safe-b)); }

/* 导航：手机在下面，宽屏在左边 */
#nav { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--bg); border-top: var(--bw) solid var(--ui); padding: 6px 8px calc(6px + var(--safe-b)); }
#nav a { flex: 1; max-width: 140px; display: grid; justify-items: center; gap: 2px; padding: 6px; border-radius: 12px; text-decoration: none; color: var(--tx-2); font-size: 12px; font-weight: 700; }
#nav a svg { width: 26px; height: 26px; }
#nav a.on { color: var(--accent); background: var(--accent-bg); }
@media (min-width: 760px) {
  #nav { position: sticky; top: 0; bottom: auto; right: auto; height: 100dvh; width: 104px; flex-direction: column; justify-content: flex-start; gap: 8px; border-top: 0; border-right: var(--bw) solid var(--ui); padding: 24px 12px; }
  #nav a { flex: none; max-width: none; padding: 12px 6px; font-size: 13px; }
  #app { padding-bottom: 32px; padding-top: 28px; }
}

/* 按钮：圆鼓鼓，下面一条硬边，按下去会沉 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 22px; border: var(--bw) solid var(--line); border-radius: var(--r); background: var(--bg); font-weight: 800; font-size: 17px; box-shadow: 0 var(--drop) 0 var(--line); transition: transform .06s, box-shadow .06s; user-select: none; }
.btn:active:not(:disabled) { transform: translateY(var(--drop)); box-shadow: 0 0 0 var(--line); }
.btn.primary { background: var(--c-green); color: #FFFCF0; }
.btn.blue { background: var(--c-blue); color: #FFFCF0; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 15px; border-radius: 12px; }
.btn.wide { width: 100%; }
.btn:disabled { background: var(--ui); color: var(--tx-3); border-color: var(--ui-3); box-shadow: 0 var(--drop) 0 var(--ui-3); cursor: default; }
.link { background: none; border: 0; padding: 4px 6px; color: var(--accent); font-weight: 700; text-decoration: underline; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 12px; background: none; color: var(--tx-2); }
.icon-btn:hover { background: var(--ui); }
.icon-btn svg { width: 26px; height: 26px; }
.icon-btn.off { color: var(--tx-3); }
:focus-visible { outline: 3px solid var(--c-blue); outline-offset: 2px; }

.card { background: var(--bg-2); border: var(--bw) solid var(--ui-2); border-radius: var(--r); padding: 16px; }
.muted { color: var(--tx-2); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: 12px; }
.page-title { font-size: 26px; font-weight: 900; margin-bottom: 4px; }
.page-sub { color: var(--tx-2); margin-bottom: 18px; }

/* 轻提示 */
#toast { position: fixed; z-index: 30; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--tx); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 700; font-size: 15px; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); display: flex; gap: 8px; align-items: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast .link { color: var(--c-yellow); }

/* 首页 */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border-radius: 999px; background: var(--bg-2); border: var(--bw) solid var(--ui-2); font-weight: 800; white-space: nowrap; }
.chip svg { width: 20px; height: 20px; }
.chip.fire { color: var(--c-orange); }
.chip.fire.cold { color: var(--tx-3); }
.pack-pick { display: flex; align-items: center; gap: 6px; min-width: 0; height: 40px; padding: 0 12px; border-radius: 999px; border: var(--bw) solid var(--ui-2); background: var(--bg-2); font-weight: 800; }
.pack-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-pick svg { width: 16px; height: 16px; flex: none; color: var(--tx-2); }
.level { display: grid; gap: 4px; margin-bottom: 18px; }
.level .bar { height: 14px; }
.bar { height: 16px; border-radius: 999px; background: var(--ui); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--c-yellow); transition: width .5s cubic-bezier(.2, .9, .3, 1.2); }
.bar.green i { background: var(--c-green); }
.review { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; background: var(--warning-bg); border-color: var(--c-orange); }
.unit { margin-bottom: 22px; }
.unit-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-radius: var(--r); color: #FFFCF0; border: var(--bw) solid var(--line); box-shadow: 0 var(--drop) 0 var(--line); font-weight: 900; font-size: 18px; }
.unit-head small { font-weight: 700; opacity: .85; font-size: 13px; margin-left: auto; white-space: nowrap; }
.path { display: grid; justify-items: center; gap: 18px; padding: 22px 0 6px; }
.node { position: relative; width: 76px; height: 70px; border-radius: 50%; border: var(--bw) solid var(--line); box-shadow: 0 6px 0 var(--line); display: grid; place-items: center; font-weight: 900; font-size: 24px; color: #FFFCF0; transition: transform .06s, box-shadow .06s; }
.node:active:not(:disabled) { transform: translateY(6px); box-shadow: 0 0 0 var(--line); }
.node:disabled { background: var(--ui) !important; color: var(--tx-3); border-color: var(--ui-3); box-shadow: 0 6px 0 var(--ui-3); cursor: default; }
.node svg { width: 28px; height: 28px; }
.node-wrap { display: grid; justify-items: center; gap: 8px; }
.node-wrap:has(.node.next) { margin-top: 26px; }
.node-wrap .name { font-size: 13px; font-weight: 700; color: var(--tx-2); max-width: 180px; text-align: center; }
.stars { display: flex; gap: 2px; height: 18px; }
.stars svg { width: 18px; height: 18px; color: var(--ui-3); }
.stars svg.on { color: var(--c-yellow); }
.node.next::after { content: "开始"; position: absolute; top: -30px; left: 50%; translate: -50% 0; background: var(--bg); color: var(--tx); border: var(--bw) solid var(--line); border-radius: 10px; padding: 0 10px; font-size: 14px; line-height: 24px; white-space: nowrap; animation: bob 1.2s ease-in-out infinite; }
@keyframes bob { 50% { translate: -50% -5px; } }
.empty { text-align: center; padding: 40px 12px; display: grid; gap: 14px; justify-items: center; }

/* 闯关 */
.play { display: flex; flex-direction: column; min-height: calc(100dvh - 32px - var(--safe-t) - var(--safe-b)); }
.play-top { display: flex; align-items: center; gap: 8px; }
.play-top .bar { flex: 1; }
.combo { min-width: 64px; text-align: center; font-weight: 900; color: var(--c-orange); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.combo.on { opacity: 1; }
.combo.pop { animation: pop .3s; }
@keyframes pop { 40% { transform: scale(1.5) rotate(-6deg); } }
.stage { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 22px; padding: 18px 0; text-align: center; }
.zh { font-size: clamp(22px, 5vw, 34px); font-weight: 800; line-height: 1.35; }
.say { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 999px; border: var(--bw) solid var(--ui-2); background: var(--bg-2); color: var(--c-blue); font-weight: 800; font-size: 14px; }
.say svg { width: 20px; height: 20px; }
.slots { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 14px 12px; max-width: 100%; font-size: clamp(24px, 5.2vw, 38px); font-weight: 800; }
.slot { display: inline-flex; align-items: flex-end; }
.slot .punc { color: var(--tx-2); padding: 0 1px 6px; }
.slot input { width: calc(var(--n) * 0.64em + 0.5em); min-width: 1.6em; padding: 2px 0 4px; border: 0; border-bottom: 4px solid var(--ui-3); border-radius: 0; background: none; text-align: center; font-weight: 800; outline: none; caret-color: var(--c-blue); }
.slot input:focus { border-bottom-color: var(--c-blue); }
.slot.ok input { border-bottom-color: var(--c-green); color: var(--success); }
.slot.bad input { border-bottom-color: var(--c-red); color: var(--error); animation: shake .3s; }
.slot.shown input { border-bottom-color: var(--c-yellow); color: var(--warning); }
.tile-mode .slot input { cursor: pointer; caret-color: transparent; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.slots.win .slot { animation: hop .45s both; animation-delay: calc(var(--i) * 45ms); }
@keyframes hop { 40% { transform: translateY(-12px); } }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; min-height: 56px; }
.tile { min-height: 48px; padding: 0 16px; border: var(--bw) solid var(--line); border-radius: 14px; background: var(--bg); box-shadow: 0 var(--drop) 0 var(--line); font-weight: 800; font-size: 20px; transition: transform .06s, box-shadow .06s; }
.tile:active { transform: translateY(var(--drop)); box-shadow: none; }
.tile.used { visibility: hidden; }
.note { min-height: 24px; color: var(--tx-2); font-size: 15px; max-width: 34em; }
.note b { color: var(--success); }
.play-foot { display: flex; align-items: center; gap: 10px; padding-top: 8px; }
.play-foot .btn.primary, .play-foot .btn.blue { flex: 1; }
.kbd { font-size: 12px; opacity: .8; border: 1px solid currentColor; border-radius: 6px; padding: 0 6px; font-weight: 700; }
@media (pointer: coarse) { .kbd { display: none; } }
@media (max-height: 560px) { .stage { gap: 12px; padding: 8px 0; } .mascot-hide-short { display: none; } }

/* 过关 */
.result { text-align: center; display: grid; gap: 16px; justify-items: center; padding-top: min(6vh, 40px); }
.result h1 { font-size: 30px; font-weight: 900; }
.big-stars { display: flex; gap: 8px; }
.big-stars svg { width: 64px; height: 64px; color: var(--ui-3); }
.big-stars svg.on { color: var(--c-yellow); animation: starin .45s both; animation-delay: calc(var(--i) * .28s + .2s); }
@keyframes starin { from { transform: scale(0) rotate(-90deg); } 60% { transform: scale(1.3); } }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 420px; }
.stat { border: var(--bw) solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--line); }
.stat b { display: block; padding: 2px 0; color: #FFFCF0; font-size: 12px; }
.stat span { display: block; background: var(--bg); border-radius: 12px 12px 0 0; padding: 10px 0; font-size: 22px; font-weight: 900; }
.stat.xp { background: var(--c-yellow); border-color: var(--c-yellow); } .stat.xp span { color: var(--c-yellow); }
.stat.ok { background: var(--c-green); border-color: var(--c-green); } .stat.ok span { color: var(--c-green); }
.stat.cb { background: var(--c-orange); border-color: var(--c-orange); } .stat.cb span { color: var(--c-orange); }
.result .actions { display: grid; gap: 12px; width: 100%; max-width: 420px; }
.mascot { display: inline-block; line-height: 0; }
.mascot.mood-happy { animation: hop .6s 2; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 10px; animation: fall 1.6s cubic-bezier(.2, .6, .4, 1) forwards; }
@keyframes fall { to { transform: translate(var(--dx), 105vh) rotate(var(--r)); } }

/* 教材 */
.pack { display: flex; align-items: center; gap: 12px; }
.pack.cur { border-color: var(--accent); background: var(--accent-bg); }
.pack h3 { font-size: 17px; font-weight: 800; }
.badge { font-size: 12px; font-weight: 800; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); margin-left: 6px; vertical-align: 2px; }
textarea, .field { width: 100%; border: var(--bw) solid var(--border-input); border-radius: 12px; background: var(--bg); padding: 10px 12px; }
textarea { min-height: 150px; font-family: ui-monospace, Menlo, monospace; font-size: 14px; resize: vertical; tab-size: 4; }
.field { height: 48px; font-weight: 700; }
.err { color: var(--error); font-weight: 700; }
.okmsg { color: var(--success); font-weight: 700; }
pre.sample { margin: 0; padding: 10px 12px; background: var(--bg); border-radius: 12px; border: var(--bw) dashed var(--ui-3); font: 13px/1.6 ui-monospace, Menlo, monospace; overflow-x: auto; }
details > summary { cursor: pointer; font-weight: 800; }

/* 我 */
.week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 120px; }
.week div { display: grid; gap: 4px; justify-items: center; align-content: end; height: 100%; font-size: 12px; color: var(--tx-2); font-weight: 700; }
.week i { width: 100%; max-width: 36px; min-height: 4px; border-radius: 8px 8px 3px 3px; background: var(--ui-3); }
.week i.on { background: var(--c-yellow); }
.week .today { color: var(--tx); }
.switch { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--ui); }
.switch:last-child { border: 0; }
.switch input { appearance: none; width: 52px; height: 32px; border-radius: 999px; background: var(--ui-3); position: relative; transition: .15s; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #FFFCF0; transition: .15s; }
.switch input:checked { background: var(--c-green); }
.switch input:checked::after { left: 23px; }
.seg { display: inline-flex; border: var(--bw) solid var(--ui-3); border-radius: 12px; overflow: hidden; }
.seg button { border: 0; background: none; padding: 8px 12px; font-weight: 700; font-size: 14px; color: var(--tx-2); }
.seg button.on { background: var(--accent); color: var(--on-accent); }
.code { font: 800 24px/1 ui-monospace, Menlo, monospace; letter-spacing: 3px; }

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