:root {
  --bg: #eef3e4;
  --bg-2: #dfe9d2;
  --surface: #fbfdf5;
  --ink: #17261f;
  --ink-soft: #46574d;
  --line: #cfdcc2;
  --teal: #0f6a52;
  --teal-ink: #ffffff;
  --teal-soft: #d4ebdf;
  --brass: #9a6410;
  --brass-soft: #f8e6bd;
  --coral: #b23a22;
  --coral-soft: #fbe3da;
  --focus: #1d5fd1;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(23, 38, 31, .06), 0 10px 28px -14px rgba(23, 38, 31, .3);
  --font: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* pond palette */
  --water-top: #8ccfc6;
  --water-mid: #4fa3a6;
  --water-deep: #2f7d88;
  --water-glint: rgba(255, 255, 255, .45);
  --ripple: rgba(255, 255, 255, .55);
  --pad: #5fae43;
  --pad-light: #8fd067;
  --pad-edge: #3b7d2b;
  --pad-under: rgba(8, 48, 52, .32);
  --reed: #4f8d3a;
  --reed-dark: #35662a;
  --cattail: #7a4d2a;
  --frog: #69c046;
  --frog-dark: #3f8c2c;
  --frog-belly: #e6f6c3;
  --frog-eye: #ffffff;
  --frog-pupil: #13201a;
  --frog-cheek: #f39a9a;
  --lotus: #f6a9c6;
  --lotus-dark: #e06f9b;
  --lotus-centre: #f7d65a;
  --chip: #fffdf6;
  --chip-ink: #17261f;
  --label-bg: rgba(255, 253, 246, .92);
  --glass: rgba(251, 253, 245, .9);
  --glass-line: rgba(255, 255, 255, .7);
  --glass-shadow: 0 10px 30px -12px rgba(10, 50, 52, .45);
}

[data-theme="dark"] {
  --bg: #0d1520;
  --bg-2: #142233;
  --surface: #152131;
  --ink: #eef3ee;
  --ink-soft: #b5c3bc;
  --line: #2b3d52;
  --teal: #5ad6a8;
  --teal-ink: #062018;
  --teal-soft: #163a31;
  --brass: #f2c14e;
  --brass-soft: #3a3020;
  --coral: #ff9478;
  --coral-soft: #3d2420;
  --focus: #8fb6ff;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 12px 32px -14px rgba(0, 0, 0, .85);

  --water-top: #1d3d57;
  --water-mid: #15304a;
  --water-deep: #0b1b2c;
  --water-glint: rgba(190, 215, 255, .22);
  --ripple: rgba(170, 200, 255, .32);
  --pad: #2f7a3e;
  --pad-light: #4c9e58;
  --pad-edge: #1c4d27;
  --pad-under: rgba(0, 0, 0, .45);
  --reed: #24552f;
  --reed-dark: #183d21;
  --cattail: #4b301b;
  --frog: #55a73d;
  --frog-dark: #2f6e24;
  --frog-belly: #c9e3a5;
  --frog-cheek: #d97c86;
  --lotus: #e7a2c0;
  --lotus-dark: #c4628d;
  --chip: #f4f7ef;
  --chip-ink: #13201a;
  --label-bg: rgba(16, 28, 42, .9);
  --glass: rgba(14, 25, 38, .9);
  --glass-line: rgba(140, 180, 220, .22);
  --glass-shadow: 0 10px 30px -12px rgba(0, 0, 0, .8);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
html { -webkit-text-size-adjust: 100%; background: var(--water-mid); }
body {
  position: fixed; inset: 0;
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--teal); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute; left: 8px; top: -80px; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px;
}
.skip:focus { top: calc(env(safe-area-inset-top) + 8px); }

/* ---------- The whole game is the pond ---------- */
.game { position: fixed; inset: 0; overflow: hidden; outline: none; }
.pond {
  position: absolute; inset: 0; overflow: hidden; isolation: isolate;
  background-color: var(--water-mid);
  background-image:
    radial-gradient(90% 60% at 18% 8%, var(--water-glint), transparent 60%),
    radial-gradient(70% 50% at 85% 95%, rgba(0, 0, 0, .12), transparent 70%),
    linear-gradient(180deg, var(--water-top), var(--water-mid) 50%, var(--water-deep));
}
.pond-deco { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.pond-light {
  position: absolute; inset: -30% -30%;
  background-image:
    radial-gradient(closest-side, rgba(255, 255, 255, .15), transparent),
    radial-gradient(closest-side, rgba(255, 255, 255, .11), transparent);
  background-size: 320px 140px, 420px 180px;
  background-position: 0 0, 160px 70px;
  animation: drift 30s linear infinite;
}
.moon-glint { display: none; }
.ripple-ring {
  position: absolute; width: 110px; height: 32px; border-radius: 50%;
  border: 1.5px solid var(--ripple); opacity: 0;
  animation: ring 7s ease-out infinite;
}
.ripple-ring.r1 { left: 10%; top: 26%; }
.ripple-ring.r2 { left: 60%; top: 18%; animation-delay: 2.2s; }
.ripple-ring.r3 { left: 34%; top: 70%; animation-delay: 4.1s; }
.ripple-ring.r4 { left: 82%; top: 58%; animation-delay: 1.3s; }
.ripple-ring.r5 { left: 22%; top: 46%; animation-delay: 5.2s; }
.ripple-ring.r6 { left: 72%; top: 38%; animation-delay: 3.3s; }
.reeds { position: absolute; bottom: -8px; height: min(36vh, 280px); aspect-ratio: 80 / 210; z-index: 3; }
.reeds-left { left: -18px; }
.reeds-left2 { left: max(4vw, 34px); height: min(22vh, 170px); }
.reeds-right { right: -18px; transform: scaleX(-1); }
.reeds-right2 { right: max(5vw, 38px); height: min(20vh, 150px); transform: scaleX(-1); }
.reeds-top { top: calc(var(--top-h, 64px) - 30px); bottom: auto; right: -22px; height: min(20vh, 150px); transform: scale(-1, -1); opacity: .85; }
.reed-blade { fill: var(--reed); }
.reed-blade.dark { fill: var(--reed-dark); }
.reed-stem { stroke: var(--reed-dark); stroke-width: 2.5; fill: none; }
.cattail { fill: var(--cattail); }
.reeds .sway { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 5s ease-in-out infinite; }
.reeds .sway.s2 { animation-duration: 6.4s; animation-delay: -2s; }
.deco-pad { position: absolute; width: clamp(48px, 7vw, 96px); aspect-ratio: 2 / 1; opacity: .85; }
.deco-pad.d1 { left: 4%; top: 20%; }
.deco-pad.d2 { right: 8%; top: 24%; width: clamp(40px, 5vw, 72px); }
.deco-pad.d3 { left: 44%; top: 15%; width: clamp(34px, 4vw, 56px); opacity: .7; }
.deco-pad.d4 { left: 9%; top: 74%; }
.deco-pad.d5 { right: 14%; top: 70%; width: clamp(44px, 6vw, 84px); }
.deco-pad.d6 { left: 30%; top: 86%; width: clamp(36px, 4.5vw, 64px); opacity: .7; }
.deco-pad.d7 { left: 62%; top: 82%; width: clamp(40px, 5vw, 70px); }
.deco-lotus { position: absolute; width: clamp(26px, 3vw, 40px); aspect-ratio: 60 / 44; }
.deco-lotus.l1 { left: calc(9% + 18px); top: calc(74% - 14px); }
.deco-lotus.l2 { right: calc(8% + 10px); top: calc(24% - 16px); }
.firefly { display: none; }
[data-theme="dark"] .pond-light { opacity: .35; }
[data-theme="dark"] .moon-glint {
  display: block; position: absolute; right: 18%; top: 22%; width: 220px; height: 34px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(230, 240, 255, .4), transparent);
  animation: shimmer 5s ease-in-out infinite;
}
[data-theme="dark"] .firefly {
  display: block; position: absolute; width: 5px; height: 5px; border-radius: 50%;
  background: #ffe680; box-shadow: 0 0 10px 3px rgba(255, 220, 90, .65);
  animation: firefly 7s ease-in-out infinite, flicker 2.3s ease-in-out infinite;
  z-index: 4;
}
.firefly.f1 { left: 7%; top: 28%; }
.firefly.f2 { left: 24%; top: 16%; animation-delay: -2s, -1s; }
.firefly.f3 { left: 52%; top: 22%; animation-delay: -4s, -.4s; }
.firefly.f4 { left: 76%; top: 34%; animation-delay: -1s, -1.6s; }
.firefly.f5 { left: 91%; top: 18%; animation-delay: -5s, -.8s; }
.firefly.f6 { left: 42%; top: 40%; animation-delay: -3s, -2s; }
.firefly.f7 { left: 14%; top: 62%; animation-delay: -6s, -1.2s; }
.firefly.f8 { left: 66%; top: 66%; animation-delay: -2.5s, -.2s; }
.firefly.f9 { left: 86%; top: 74%; animation-delay: -4.5s, -1.8s; }
.firefly.f10 { left: 34%; top: 78%; animation-delay: -1.5s, -.6s; }

/* each pond view (one for the daily, two in Battle) */
.ponds { position: absolute; inset: 0; z-index: 2; }
.pond-view {
  --pad-w: 130px; --pad-h: 62px; --frog-w: 76px; --tile-fs: .95rem; --label-fs: .76rem;
  position: absolute; inset: 0; overflow: hidden;
}
.game[data-mode="battle"] .pond-view { right: auto; bottom: auto; }
.battle-side .is-cpu { border-left: 3px solid var(--glass-line); background: rgba(0, 20, 40, .07); }
.battle-stack .is-you { border-top: 3px solid var(--glass-line); }
.battle-stack .is-cpu { background: rgba(0, 20, 40, .07); }
.pond-tag {
  position: absolute; z-index: 6; left: calc(env(safe-area-inset-left) + 12px); top: 6px; margin: 0;
  font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  background: var(--glass); color: var(--ink); padding: 2px 10px; border-radius: 999px; box-shadow: var(--glass-shadow);
}
.battle-side .pond-tag { top: calc(var(--top-h, 60px) + 6px); }
.is-cpu .pond-tag { color: var(--brass); }
/* the computer's frog is a golden toad */
.is-cpu { --frog: #e0a23a; --frog-dark: #a96f17; --frog-belly: #fbecc4; }
[data-theme="dark"] .is-cpu { --frog: #c98d2c; --frog-dark: #8a5a12; --frog-belly: #ecd7a4; }

.pond-scroll {
  position: absolute; inset: 0; z-index: 2;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  outline: none;
}
.pond-scroll::-webkit-scrollbar { display: none; }
.pond-scroll:focus-visible { box-shadow: inset 0 0 0 3px var(--focus); }
.pond-strip {
  position: relative; height: 100%;
  width: var(--strip-w, 100%); min-width: 100%;
  transform-origin: 0 0;
  transform: translate3d(var(--zx, 0px), var(--zy, 0px), 0) scale(var(--zoom, 1));
  transition: transform .9s cubic-bezier(.3, .8, .3, 1);
}
.pads { list-style: none; margin: 0; padding: 0; }
.no-anim, .no-anim * { transition: none !important; }

/* pads, joints and the finish are placed by the layout code through --x / --y */
.pad-node, .finish, .joint {
  position: absolute; left: 0; top: 0;
  transform: translate3d(var(--x, 0px), var(--y, 0px), 0);
  transition: transform .55s cubic-bezier(.3, .85, .3, 1), opacity .3s;
}
.pad-node, .finish { min-width: var(--pad-w); height: var(--pad-h); }
.finish { min-width: calc(var(--pad-w) * 1.18); height: calc(var(--pad-h) * 1.12); }
.pad {
  position: relative; width: 100%; height: 100%; padding: 0 calc(var(--pad-w) * .12);
  display: flex; align-items: center; justify-content: center;
  transform-origin: 50% 70%;
}
.pad-svg { position: absolute; inset: -6% -3% -3%; width: 106%; height: 109%; overflow: visible; }
.pad-under { fill: var(--pad-under); }
.pad-edge { fill: var(--pad-edge); }
.pad-top { fill: var(--pad); }
.pad-shine { fill: var(--pad-light); opacity: .55; }
.pad-vein { stroke: var(--pad-light); stroke-width: 1.3; opacity: .7; fill: none; }
.tile {
  position: relative; z-index: 2;
  display: inline-flex; align-items: center; justify-content: center;
  margin-top: calc(var(--pad-h) * .36); padding: .15em .75em;
  border-radius: 999px; border: 2px solid rgba(0, 0, 0, .14);
  background: var(--chip); color: var(--chip-ink);
  font-size: var(--tile-fs); font-weight: 750; letter-spacing: .05em; text-transform: uppercase;
  white-space: nowrap;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
}
.tile-start { background: var(--teal); color: var(--teal-ink); border-color: transparent; }
.tile-target { background: var(--brass-soft); color: var(--ink); border: 2px solid var(--brass); }
.pad-target .bloom { transform: scale(1); }
.finish.is-new .pad { animation: pad-rise .7s cubic-bezier(.2, .9, .3, 1.25) both; }
.finish.is-new .end-flag { animation: fade-up .5s ease-out .3s both; }
.pad-node.is-new .pad { animation: pad-rise .62s cubic-bezier(.2, .9, .3, 1.25) both; }
.pad-node.is-sinking { opacity: 0; transition-delay: .25s; }
.pad-node.is-sinking .pad { animation: pad-sink .42s ease-in both; }
.pad-node.is-fade .pad { animation: fade-in .25s ease-out both; }
.splash {
  position: absolute; left: 50%; top: 62%; width: 130%; height: 70%;
  margin-left: -65%; border-radius: 50%; border: 2px solid var(--ripple); opacity: 0; pointer-events: none;
}
.pad-node.is-new .splash { animation: splash .9s ease-out both; }
.bloom { position: absolute; z-index: 1; width: 24%; max-width: 34px; aspect-ratio: 60 / 44; left: 8%; top: -4%; transform: scale(0); transform-origin: 50% 90%; }
.is-celebrating .bloom { animation: bloom .6s cubic-bezier(.2, .9, .3, 1.3) both; animation-delay: var(--bloom-delay, 0ms); }
.is-bloomed .bloom { transform: scale(1); }

.finish .lotus { position: absolute; z-index: 1; width: 40%; max-width: 60px; aspect-ratio: 60 / 44; right: 0; top: -36%; transform-origin: 50% 90%; }
.end-flag {
  position: absolute; bottom: calc(100% + 18px); left: 50%; transform: translateX(-50%);
  white-space: nowrap;
  font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .12em;
  background: var(--chip); color: var(--chip-ink); padding: 1px 9px; border-radius: 999px;
  transition: opacity .3s;
}
.finish.is-reached .end-flag { opacity: 0; }
.tile-end { background: var(--brass-soft); color: var(--ink); border: 2px dashed var(--brass); }
.finish.is-reached .tile-end { border-style: solid; }
.is-celebrating .lotus, .is-bloomed .lotus { animation: lotus-open 1s ease-out both; }
.petal { fill: var(--lotus); stroke: var(--lotus-dark); stroke-width: 1; }
.petal.back { fill: var(--lotus-dark); }
.lotus-centre { fill: var(--lotus-centre); }

/* link labels float on the water between pads (centred on --x / --y) */
.joint { z-index: 2; pointer-events: auto; }
.joint-label {
  display: block; transform: translate(-50%, -50%);
  white-space: nowrap; max-width: calc(var(--pad-w) * 1.7);
  overflow: hidden; text-overflow: ellipsis;
  background: var(--label-bg); color: var(--ink);
  padding: 2px 9px 3px; border-radius: 12px;
  border: 1.5px solid var(--teal);
  font-size: var(--label-fs); font-weight: 650; line-height: 1.2; text-align: center;
}
.joint-assoc .joint-label { border-color: var(--brass); border-style: dashed; }
.joint-loose .joint-label { border-style: dotted; }
.joint-label .joint-strength { display: block; font-size: .84em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.joint-loose .joint-strength { color: var(--brass); }
.is-portrait .joint-label { max-width: calc(var(--step, 80px) - 4px); padding: 1px 6px 2px; }
.joint.is-new .joint-label { animation: fade-up .5s ease-out both; animation-delay: .25s; }
.joint.is-sinking { opacity: 0; }

/* the frog */
.frog {
  position: absolute; left: 0; top: 0; z-index: 5;
  width: var(--frog-w); height: calc(var(--frog-w) * .92);
  transform: translate3d(var(--fx, 0px), var(--fy, 0px), 0);
  transform-origin: 50% 100%;
  will-change: transform;
}
.frog-svg { width: 100%; height: 100%; overflow: visible; display: block; }
.frog-skin { fill: var(--frog); }
.frog-shade { fill: var(--frog-dark); }
.frog-belly { fill: var(--frog-belly); transform-box: fill-box; transform-origin: 50% 70%; animation: breathe 2.6s ease-in-out infinite; }
.frog-eye { fill: var(--frog-eye); }
.frog-pupil { fill: var(--frog-pupil); }
.frog-glint { fill: #fff; }
.frog-lid { fill: var(--frog); transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); animation: blink 4.6s infinite; }
.frog-mouth { fill: none; stroke: var(--frog-pupil); stroke-width: 2.4; stroke-linecap: round; }
.frog-mouth-open { fill: #b0404f; opacity: 0; }
.frog-cheek { fill: var(--frog-cheek); opacity: .55; }
.frog-shadow { fill: rgba(0, 0, 0, .2); }
.frog-inner { width: 100%; height: 100%; transform-origin: 50% 100%; }
.frog.is-no .frog-inner { animation: head-shake .55s ease-in-out; }
.frog.is-happy .frog-inner { animation: hop-happy .7s ease-in-out 2; }
.frog.is-croaked .frog-inner { animation: hop-happy 1.6s ease-in-out infinite; }
.frog.is-happy .frog-mouth, .frog.is-croaked .frog-mouth { opacity: 0; }
.frog.is-happy .frog-mouth-open, .frog.is-croaked .frog-mouth-open { opacity: 1; }
.croak {
  position: absolute; left: 50%; top: -34px; z-index: 6; translate: -50% 0;
  background: var(--chip); color: var(--chip-ink);
  font-size: .85rem; font-weight: 800; padding: 3px 11px; border-radius: 14px;
  box-shadow: 0 3px 10px -4px rgba(0, 0, 0, .4);
  white-space: nowrap; opacity: 0; transform: scale(.4); transform-origin: 50% 100%;
}
.frog.is-croaking .croak { animation: croak 2.2s ease-out forwards; }
.frog.is-croaked .croak { opacity: 1; transform: none; }
.frog.is-cheering .croak { animation: cheer 1.2s ease-out both; }
.landing {
  position: absolute; width: calc(var(--pad-w) * .9); height: calc(var(--pad-h) * .5);
  margin-left: calc(var(--pad-w) * -.45); margin-top: calc(var(--pad-h) * -.25);
  border-radius: 50%; border: 2px solid var(--ripple); pointer-events: none; z-index: 1;
  animation: splash .8s ease-out both;
}
.pad-ghost {
  position: absolute; left: 0; top: 0; width: calc(var(--pad-w) * .7); height: calc(var(--pad-h) * .7); z-index: 1; pointer-events: none;
  transform: translate3d(var(--x, 0px), var(--y, 0px), 0);
}
.pad-ghost .pad-svg { inset: 0; width: 100%; height: 100%; animation: ghost .9s ease-in-out both; transform-origin: 50% 70%; }

/* ---------- Floating glass UI ---------- */
.topbar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px 16px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 14px) 8px calc(env(safe-area-inset-left) + 14px);
  background: var(--glass);
  border-bottom: 1px solid var(--glass-line);
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { border-radius: 9px; display: block; flex: 0 0 auto; }
.brand-text { min-width: 0; }
.brand-name { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; line-height: 1.1; }
.brand-sub { margin: 1px 0 0; color: var(--ink-soft); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub strong { color: var(--ink); }
.board-head { display: flex; align-items: center; justify-content: center; gap: 8px 14px; min-width: 0; flex-wrap: wrap; }
.board-title { margin: 0; font-size: 1.02rem; font-weight: 650; white-space: nowrap; }
.word-chip { display: inline-block; padding: 0 9px; border-radius: 999px; font-weight: 750; letter-spacing: .02em; text-transform: uppercase; font-size: .9rem; }
.start-chip { background: var(--teal-soft); color: var(--ink); }
.end-chip { background: var(--brass-soft); color: var(--ink); }
.scoreline { display: flex; gap: 5px; margin: 0; }
.scoreline div { min-width: 50px; text-align: center; padding: 1px 6px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); }
.scoreline dt { font-size: .62rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); line-height: 1.3; }
.scoreline dd { margin: 0; font-weight: 750; font-size: 1rem; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tools { display: flex; gap: 6px; justify-content: flex-end; }
.tool-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; min-width: 40px; padding: 0 11px;
  border: 1.5px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--ink); font: inherit; font-size: .85rem; cursor: pointer;
}
.tool-btn:hover { border-color: var(--teal); }
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: inline; }
[data-theme="dark"] .icon-moon { display: none; }
@media (max-width: 1180px) {
  .tool-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .tool-btn { padding: 0; width: 40px; }
}

.dock {
  position: absolute; z-index: 20; left: 50%;
  bottom: calc(var(--kb, 0px) + env(safe-area-inset-bottom) + 26px);
  transform: translateX(-50%);
  width: min(600px, calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  padding: 10px 12px 10px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  backdrop-filter: blur(12px) saturate(1.3);
  display: flex; flex-direction: column; gap: 6px;
}
.kb-open .dock { bottom: calc(var(--kb, 0px) + 8px); }
.feedback { margin: 0; text-align: center; font-size: .9rem; line-height: 1.35; }
.feedback:empty { display: none; }
.feedback.is-error { color: var(--coral); background: var(--coral-soft); border-radius: 12px; padding: 6px 10px; }
.feedback.is-ok { color: var(--teal); font-weight: 600; }
.entry { margin: 0; }
.entry-label { display: block; text-align: center; font-weight: 650; font-size: .9rem; margin: 0 0 4px; }
.entry-row { display: flex; gap: 8px; }
.entry input {
  flex: 1; min-width: 0; min-height: 46px; padding: 6px 14px;
  border: 2px dashed var(--line); border-radius: 14px; background: var(--bg); color: var(--ink);
  font: inherit; font-size: 1.1rem; font-weight: 650; text-align: center;
}
.entry input:focus { border-style: solid; border-color: var(--teal); outline: none; box-shadow: 0 0 0 4px var(--teal-soft); }
.entry input.shake { animation: shake .32s ease-in-out; border-color: var(--coral); }
.entry-hint { margin: 5px 0 0; text-align: center; color: var(--ink-soft); font-size: .78rem; }
.btn {
  min-height: 44px; padding: 0 18px; border-radius: 14px; border: 2px solid transparent;
  font: inherit; font-weight: 750; cursor: pointer;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--teal); color: var(--teal-ink); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-quiet:hover:not(:disabled) { border-color: var(--ink-soft); }
.btn-danger { color: var(--coral); }
.btn-danger-solid { background: var(--coral); color: #fff; }
.actions, .done-actions { display: flex; justify-content: center; gap: 8px; }
.actions .btn { min-height: 38px; padding: 0 16px; font-size: .9rem; }
.corner-credit {
  position: absolute; z-index: 15; margin: 0;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 4px);
  max-width: calc(100% - 16px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: .68rem; color: var(--ink); background: var(--glass); padding: 1px 8px; border-radius: 999px;
}
.kb-open .corner-credit { display: none; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--teal); text-decoration: underline; cursor: pointer; }

/* ---------- Result overlay ---------- */
.result-overlay {
  position: absolute; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  width: min(560px, calc(100% - 20px));
  max-height: calc(100% - var(--top-h, 64px) - 24px - env(safe-area-inset-bottom));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 18px 18px 16px;
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 22px;
  box-shadow: var(--glass-shadow), 0 0 0 1px rgba(0, 0, 0, .04);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  backdrop-filter: blur(14px) saturate(1.3);
  outline: none;
  animation: card-in .45s cubic-bezier(.2, .9, .3, 1.1) both;
}
@media (min-width: 980px) {
  .result-overlay { left: auto; right: calc(env(safe-area-inset-right) + 18px); transform: none; bottom: auto; top: calc(var(--top-h, 64px) + 16px); width: 430px; max-height: calc(100% - var(--top-h, 64px) - 32px); }
}
.result-close {
  position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.result-title { margin: 0 44px 0; text-align: center; font-size: 1.45rem; letter-spacing: -.01em; }
.result-score { margin: 2px 0 12px; text-align: center; font-weight: 650; color: var(--teal); }
.result-score.is-revealed { color: var(--coral); }
.result-grid { display: grid; gap: 8px; }
.result-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.result-block h3, .share h3 { margin: 0 0 3px; font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); }
.chain-line { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.chain-line .arrow { color: var(--ink-soft); padding: 0 .3em; font-weight: 400; }
.par-tag { text-transform: none; letter-spacing: 0; font-weight: 650; color: var(--brass); }
.share { margin-top: 12px; }
.share-preview {
  margin: 4px 0 10px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 1rem; line-height: 1.5; white-space: pre-wrap;
}
.share-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.share-status { color: var(--teal); font-weight: 650; }
.share-fallback { display: block; margin-top: 10px; font-size: .9rem; }
.share-fallback textarea { width: 100%; margin-top: 6px; font-family: var(--mono); font-size: .95rem; border-radius: 10px; padding: 8px; background: var(--bg); color: var(--ink); border: 1px solid var(--line); }
.next-up { text-align: center; margin: 12px 0 0; color: var(--ink-soft); }
.next-up strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.result-foot { margin: 10px 0 0; text-align: center; }

/* ---------- Dialogs ---------- */
.sheet {
  width: min(540px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  padding: 0; border: 1.5px solid var(--line); border-radius: 22px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgba(8, 20, 18, .55); }
.sheet-inner { padding: 20px 22px 22px; }
.sheet h2 { margin: 0 0 8px; font-size: 1.35rem; }
.sheet h2:focus, .sheet h3:focus { outline: none; }
.sheet h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); margin: 16px 0 8px; }
.sheet form { margin-top: 16px; display: flex; justify-content: flex-end; }
.sheet-actions { gap: 10px; }
.help-frog { float: right; width: 74px; height: 68px; margin: -6px 0 6px 10px; }
.help-frog svg { width: 100%; height: 100%; display: block; }
.demo { list-style: none; padding: 10px 8px; margin: 12px 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 2px; border-radius: 16px; background: linear-gradient(180deg, var(--water-top), var(--water-mid)); }
.demo .tile { margin: 0; font-size: .82rem; padding: 2px 10px; }
.demo-joint { font-size: .74rem; font-weight: 650; padding: 1px 7px; border-radius: 10px; background: var(--label-bg); color: var(--ink); border: 1.5px solid var(--teal); }
.demo-assoc { border-color: var(--brass); border-style: dashed; }
.rules { padding-left: 1.2em; margin: 8px 0 0; }
.rules li { margin: 4px 0; }
.key-compound, .key-assoc { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .85em; font-weight: 650; border: 1.5px solid var(--teal); color: var(--teal); }
.key-assoc { border-color: var(--brass); border-style: dashed; color: var(--ink); }
.small { font-size: .82rem; color: var(--ink-soft); }
.foot-credit { font-size: .78rem; }
.stat-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 8px 0 0; }
.stat-tiles div { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 8px 4px; text-align: center; }
.stat-tiles dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat-tiles dd { margin: 0; font-size: 1.4rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.bars { list-style: none; margin: 0; padding: 0; }
.bars li { display: grid; grid-template-columns: 6.5rem 1fr; align-items: center; gap: 8px; margin: 5px 0; font-size: .9rem; }
.bar { display: block; height: 22px; border-radius: 6px; background: var(--teal); color: var(--teal-ink); font-weight: 700; font-size: .8rem; text-align: right; padding: 1px 8px; min-width: 26px; width: var(--w, 0%); }
.bar.is-zero { background: var(--line); color: var(--ink); }
.bar.is-today { outline: 2px solid var(--brass); outline-offset: 1px; }

/* ---------- Phones: portrait ---------- */
@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; grid-template-areas: "brand tools" "head head"; padding-bottom: 6px; gap: 4px 8px; }
  .brand { grid-area: brand; }
  .tools { grid-area: tools; gap: 4px; }
  .board-head { grid-area: head; justify-content: space-between; flex-wrap: nowrap; }
  .brand-name { font-size: 1.08rem; }
  .brand-mark { width: 30px; height: 30px; }
  .board-title { font-size: .92rem; }
  .word-chip { font-size: .8rem; padding: 0 7px; }
  .scoreline div { min-width: 42px; padding: 0 4px; }
  .mini-best { display: none; }
  .tool-btn { min-height: 38px; width: 38px; min-width: 38px; }
  .entry-hint { display: none; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 440px) {
  .mini-stats { display: none; }
}
@media (max-width: 380px) {
  .scoreline dt { letter-spacing: .02em; }
  .brand-sub { font-size: .74rem; }
}
/* ---------- Phones: landscape (short screens) ---------- */
@media (max-height: 500px) {
  .topbar { grid-template-columns: auto 1fr auto; grid-template-areas: "brand head tools"; padding-top: calc(env(safe-area-inset-top) + 4px); padding-bottom: 4px; }
  .board-head { justify-content: center; }
  .brand-name { font-size: 1rem; }
  .brand-sub { font-size: .7rem; }
  .mini-stats { display: none; }
  .brand-mark { width: 28px; height: 28px; }
  .tool-btn { min-height: 36px; width: 36px; min-width: 36px; }
  .dock { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 6px 8px; bottom: calc(var(--kb, 0px) + env(safe-area-inset-bottom) + 6px); width: min(720px, calc(100% - 20px - env(safe-area-inset-left) - env(safe-area-inset-right))); }
  .feedback { flex: 1 0 100%; font-size: .82rem; }
  .feedback.is-error { padding: 3px 8px; }
  .entry { flex: 1; }
  .entry-label, .entry-hint { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .entry input { min-height: 40px; }
  .btn { min-height: 40px; }
  .corner-credit { display: none; }
  .result-overlay { max-height: calc(100% - 16px); top: 8px; bottom: auto; width: min(560px, calc(100% - 20px)); }
}

/* ---------- Motion ---------- */
@keyframes pad-rise {
  0% { transform: translateY(26px) scale(.25, .15); opacity: 0; }
  45% { opacity: 1; }
  70% { transform: translateY(-4px) scale(1.08, 1.04); }
  100% { transform: none; opacity: 1; }
}
@keyframes pad-sink { 0% { transform: none; opacity: 1; } 100% { transform: translateY(24px) scale(.3, .2); opacity: 0; } }
@keyframes ghost {
  0% { transform: translateY(24px) scale(.2); opacity: 0; }
  40% { transform: translateY(4px) scale(.7); opacity: .65; }
  55% { transform: translateY(6px) scale(.68) rotate(-4deg); opacity: .6; }
  100% { transform: translateY(26px) scale(.2); opacity: 0; }
}
@keyframes splash { 0% { transform: scale(.2); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
@keyframes ring { 0% { transform: scale(.3); opacity: 0; } 15% { opacity: .9; } 100% { transform: scale(1.8); opacity: 0; } }
@keyframes drift { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-320px, 50px, 0); } }
@keyframes sway { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(3deg); } }
@keyframes shimmer { 0%, 100% { opacity: .55; transform: scaleX(1); } 50% { opacity: .9; transform: scaleX(1.12); } }
@keyframes firefly { 0%, 100% { transform: translate(0, 0); } 33% { transform: translate(18px, -12px); } 66% { transform: translate(-10px, 10px); } }
@keyframes flicker { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06, 1.1); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(0); } 95% { transform: scaleY(1); } }
@keyframes head-shake { 0%, 100% { transform: none; } 20% { transform: rotate(-9deg); } 45% { transform: rotate(8deg); } 70% { transform: rotate(-5deg); } }
@keyframes hop-happy { 0%, 100% { transform: none; } 30% { transform: translateY(-16%) scale(.95, 1.08); } 55% { transform: translateY(0) scale(1.1, .9); } }
@keyframes cheer { 0% { opacity: 0; transform: scale(.4); } 15% { opacity: 1; transform: scale(1.08); } 25%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: none; } }
@keyframes pop { 0% { opacity: 0; transform: scale(.4); } 30% { opacity: 1; transform: scale(1.12); } 60%, 100% { opacity: 1; transform: none; } }
@keyframes croak { 0% { opacity: 0; transform: scale(.4); } 15% { opacity: 1; transform: scale(1.08); } 25%, 100% { opacity: 1; transform: none; } }
@keyframes bloom { from { transform: scale(0) rotate(-20deg); } to { transform: scale(1); } }
@keyframes lotus-open { 0% { transform: scale(.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-up { from { opacity: 0; } to { opacity: 1; } }
@keyframes card-in { from { opacity: 0; translate: 0 24px; } to { opacity: 1; translate: 0 0; } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@media (prefers-reduced-motion: reduce) {
  /* No jumps, rises, pans or ambient motion: just simple fades. */
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .pad-node.is-fade .pad, .joint.is-new .joint-label, .result-overlay { animation: fade-in .25s ease-out both !important; }
  .frog.is-croaked .croak, .frog.is-croaking .croak { opacity: 1; transform: none; }
  .is-celebrating .bloom { transform: scale(1); }
  .battle-result, .battle-setup { animation: fade-in .25s ease-out both !important; }
}

/* ---------- Start screen ---------- */
.home {
  position: absolute; inset: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  overflow-y: auto;
}
.home-inner {
  width: min(400px, 100%); text-align: center;
  padding: 22px 22px 24px; border-radius: 28px;
  background: var(--glass); border: 1px solid var(--glass-line); box-shadow: var(--glass-shadow);
  -webkit-backdrop-filter: blur(12px) saturate(1.3); backdrop-filter: blur(12px) saturate(1.3);
  animation: card-in .5s cubic-bezier(.2, .9, .3, 1.1) both;
}
.home-frog { display: block; width: 104px; height: 94px; margin: 0 auto 4px; }
.home-frog svg { width: 100%; height: 100%; display: block; }
.home-frog .frog-belly, .help-frog .frog-belly { animation: breathe 2.6s ease-in-out infinite; }
.home-title { margin: 0; font-size: clamp(2rem, 7vw, 2.8rem); letter-spacing: -.03em; line-height: 1.05; }
.home-title:focus { outline: none; }
.home-sub { margin: 6px 0 18px; color: var(--ink-soft); }
.home-buttons { display: grid; gap: 12px; }
.home-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 66px; padding: 8px 18px; border-radius: 20px; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--line);
  box-shadow: 0 3px 0 rgba(0, 0, 0, .1);
  transition: transform .15s, border-color .15s;
}
.home-btn:hover { border-color: var(--teal); transform: translateY(-1px); }
.home-btn:active { transform: translateY(1px); }
.home-btn-name { font-size: 1.3rem; font-weight: 800; letter-spacing: -.01em; }
.home-btn-note { font-size: .85rem; color: var(--ink-soft); }
.home-daily { background: var(--teal); color: var(--teal-ink); border-color: transparent; }
.home-daily .home-btn-note { color: inherit; opacity: .9; }
.home-battle { background: var(--brass-soft); border-color: var(--brass); }
.home-howto { min-height: 52px; }
.home-howto .home-btn-name { font-size: 1.05rem; }

/* ---------- Mode bits in the top bar ---------- */
.home-link { flex: 0 0 auto; }
.title-arrow { padding: 0 .35em; color: var(--ink-soft); }
.game:not([data-mode="daily"]) .only-daily, .game:not([data-mode="battle"]) .only-battle { display: none; }
.game.is-setup .board-head { display: none; }
.battle-result .chain-line { overflow-wrap: break-word; }
.battle-actions .btn { padding: 0 14px; }
.game[data-mode="battle"] .mini-stats { display: none; }
.leg-lines { margin: 0; padding-left: 1.4em; display: grid; gap: 3px; }
.leg-lines li::marker { color: var(--ink-soft); font-weight: 700; }
.leg-lines .chain-line { display: inline; }
.leg-lines .par-tag { font-size: .85rem; white-space: nowrap; }
.par-tag.is-revealed { color: var(--coral); }
.howto { padding-left: 1.2em; margin: 4px 0 0; font-size: 1.05rem; }
.howto li { margin: 6px 0; }

/* ---------- Battle ---------- */
.card {
  position: absolute; z-index: 30;
  background: var(--glass); border: 1px solid var(--glass-line); border-radius: 22px;
  box-shadow: var(--glass-shadow), 0 0 0 1px rgba(0, 0, 0, .04);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  outline: none;
}
.battle-setup {
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px)); max-height: calc(100% - var(--top-h, 64px) - 24px); overflow-y: auto;
  margin-top: calc(var(--top-h, 64px) / 2);
  padding: 18px 18px 20px; text-align: center;
  animation: card-in .45s cubic-bezier(.2, .9, .3, 1.1) both;
}
.battle-setup h2 { margin: 0; font-size: 1.6rem; }
.battle-setup h2:focus { outline: none; }
.setup-sub { margin: 4px 0 14px; color: var(--ink-soft); }
.level-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.level-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-height: 84px; padding: 10px 8px; border-radius: 18px; cursor: pointer;
  font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--line);
}
.level-btn:hover { border-color: var(--teal); }
.level-name { font-size: 1.15rem; font-weight: 800; }
.level-note { font-size: .8rem; color: var(--ink-soft); }
.level-record { font-size: .78rem; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
.race-count {
  position: absolute; z-index: 32; left: 50%; top: 38%; margin: 0; transform: translate(-50%, -50%);
  min-width: 140px; padding: 8px 26px; border-radius: 999px; text-align: center; pointer-events: none;
  font-size: clamp(2.4rem, 9vw, 4.5rem); font-weight: 850; letter-spacing: -.02em;
  background: var(--glass); color: var(--ink); box-shadow: var(--glass-shadow);
}
.race-count.is-pop { animation: pop .5s ease-out both; }
.result-overlay.battle-result {
  left: 50%; right: auto; transform: translateX(-50%); top: auto;
  bottom: calc(env(safe-area-inset-bottom) + 14px);
  width: min(560px, calc(100% - 20px));
  max-height: calc(100% - var(--top-h, 64px) - 28px);
  padding: 16px 18px;
}
.battle-result .result-title { margin: 0; }
.battle-record { text-align: center; margin: 10px 0 0; color: var(--ink-soft); font-size: .9rem; }
.battle-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 12px; }
.battle-side .dock { left: 25%; width: min(560px, calc(50% - 20px)); }
.battle-side .feedback { font-size: .84rem; }
.game[data-mode="battle"] .entry-hint { display: none; }
@media (max-height: 500px) {
  .battle-side .dock { width: calc(50% - 16px); }
  .battle-setup { padding: 12px; }
  .level-btn { min-height: 64px; padding: 6px; }
  .setup-sub { margin-bottom: 8px; }
  .result-overlay.battle-result { top: calc(var(--top-h, 46px) + 4px); bottom: auto; max-height: calc(100% - var(--top-h, 46px) - 8px); padding: 10px 14px; }
  .battle-result .chain-line { font-size: .86rem; }
  .battle-result .result-block { padding: 6px 10px; }
  .battle-record { margin-top: 6px; }
  .battle-actions { margin-top: 8px; }
  .battle-result .result-grid { grid-template-columns: 1fr 1fr 1fr; }
  .home-inner { padding: 14px 18px; }
  .home-frog { width: 64px; height: 58px; }
  .home-sub { margin-bottom: 10px; }
  .home-buttons { grid-template-columns: 1fr 1fr 1fr; }
}
@media (max-width: 760px) {
  .game[data-mode="battle"] .miss-tile { display: none; }
  .battle-result .result-block { padding: 6px 10px; }
  .battle-result .chain-line { font-size: .9rem; }
}

/* The hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }
