:root{
  --bg:#fbf7f1; --card:#ffffff; --ink:#1c2230; --mute:#6b7180; --line:#e7e1d8;
  --coral:#ff5a3c; --coral-soft:#ffe6df; --plum:#6d4bd8; --plum-soft:#ece6ff;
  --r:14px; --tile:46px; --small:30px;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color:var(--ink); background:var(--bg);
}
*{box-sizing:border-box}
[hidden]{display:none!important}
html{scroll-behavior:smooth}
body{margin:0; min-height:100vh; -webkit-tap-highlight-color:transparent; line-height:1.5}
button{font:inherit; color:inherit; cursor:pointer}
a{color:var(--plum)}
.skip{position:absolute; left:-999px; top:0; background:var(--ink); color:#fff; padding:8px 12px; z-index:9}
.skip:focus{left:8px}
:focus-visible{outline:3px solid var(--plum); outline-offset:2px}

.top{position:sticky; top:0; z-index:5; display:flex; align-items:center; justify-content:space-between;
  padding:10px 16px; background:color-mix(in srgb,var(--bg) 88%,transparent); backdrop-filter:blur(8px); border-bottom:1px solid var(--line)}
.brand{display:flex; align-items:center; gap:8px; text-decoration:none; color:var(--ink); font-weight:800; font-size:22px; letter-spacing:-.02em}
.brand svg{width:28px; height:28px; fill:var(--ink)} .brand .r{fill:var(--coral)}
.tools{display:flex; gap:6px}
.icon{width:40px; height:40px; border-radius:12px; border:1px solid var(--line); background:var(--card); display:grid; place-items:center}
.icon svg{width:22px; height:22px; fill:none; stroke:var(--ink); stroke-width:2; stroke-linecap:round}
.icon .f{fill:var(--ink)}

main{max-width:520px; margin:0 auto; padding:0 14px}
.game{padding-top:12px}
.bar{display:flex; justify-content:space-between; gap:8px; flex-wrap:wrap}
.seg{display:inline-flex; background:#efe9df; border-radius:999px; padding:3px}
.seg button{border:0; background:transparent; padding:7px 14px; border-radius:999px; font-weight:700; font-size:14px; color:var(--mute)}
.seg button[aria-pressed="true"]{background:var(--card); color:var(--ink); box-shadow:0 1px 3px rgba(0,0,0,.12)}
.seg.small button{padding:7px 12px; font-size:13px}
.meta{display:flex; justify-content:space-between; align-items:center; margin:12px 2px 6px; font-weight:700; font-size:14px; color:var(--mute)}
.chips{display:flex; gap:6px}
.chip{background:var(--card); border:1px solid var(--line); border-radius:999px; padding:2px 10px; font-size:13px}
.chip b{color:var(--ink)}

.board{position:relative; background:var(--card); border:1px solid var(--line); border-radius:22px; padding:14px 0 16px;
  box-shadow:0 10px 30px -18px rgba(28,34,48,.35)}
/* ladder rails */
.board::before,.board::after{content:""; position:absolute; top:12px; bottom:12px; width:4px; border-radius:4px; background:#f1ebe2}
.board::before{left:calc(50% - 2*var(--tile) - 34px)} .board::after{right:calc(50% - 2*var(--tile) - 34px)}
.ladder{list-style:none; margin:0; padding:0; display:flex; flex-direction:column; align-items:center; gap:6px; max-height:46vh; overflow-y:auto; scrollbar-width:none; position:relative; z-index:1}
.ladder::-webkit-scrollbar{display:none}
.row{display:flex; gap:6px}
.tile{width:var(--small); height:var(--small); border-radius:8px; display:grid; place-items:center; font-weight:800; text-transform:uppercase;
  font-size:15px; background:#f6f2eb; color:var(--ink); border:0}
.tile.chg{background:var(--coral-soft); color:#b4321b}
.row.start .tile{background:var(--ink); color:#fff}
.row.cur .tile{width:var(--tile); height:var(--tile); font-size:24px; border-radius:12px; background:var(--card); border:2px solid var(--line)}
.row.cur .tile.match{background:var(--plum-soft); border-color:#cfc2ff; color:var(--plum)}
.row.cur .tile.sel{border-color:var(--coral); box-shadow:0 0 0 4px var(--coral-soft); transform:translateY(-2px)}
.row.cur .tile{transition:transform .12s, box-shadow .12s}
.row.cur.start .tile{background:var(--ink); color:#fff; border-color:var(--ink)}
.row.cur.start .tile.sel{border-color:var(--coral)}
.row.won .tile{background:var(--plum); color:#fff; border-color:var(--plum)}
.row.pop{animation:pop .28s ease-out}
.row.shake{animation:shake .35s}
@keyframes pop{from{transform:scale(.85); opacity:.3} to{transform:none; opacity:1}}
@keyframes shake{20%,60%{transform:translateX(-6px)} 40%,80%{transform:translateX(6px)}}
.gap{display:flex; flex-direction:column; align-items:center; gap:4px; margin:10px 0; position:relative; z-index:1}
.gap span{width:5px; height:5px; border-radius:50%; background:#d9d1c4}
.goal{display:flex; justify-content:center; gap:6px; position:relative; z-index:1}
.goal .tile{width:var(--tile); height:var(--tile); font-size:24px; border-radius:12px; background:transparent; border:2px dashed var(--coral); color:var(--coral)}
.goal .tile.hit{border-style:solid; background:var(--plum-soft); border-color:#cfc2ff; color:var(--plum)}
.board.done .gap,.board.done .goal{display:none}
.goal-label{font-size:11px; letter-spacing:.12em; text-transform:uppercase; color:var(--mute); text-align:center; margin:6px 0 0; font-weight:700; position:relative; z-index:1}

.msg{min-height:24px; text-align:center; margin:10px 0 6px; font-weight:600; font-size:14px; color:var(--mute)}
.msg.bad{color:#c2341b} .msg.good{color:var(--plum)}
.actions{display:flex; justify-content:center; gap:8px; flex-wrap:wrap; margin-bottom:10px}
.btn{border:1px solid var(--line); background:var(--card); border-radius:999px; padding:9px 16px; font-weight:700; font-size:14px; text-decoration:none; color:var(--ink); display:inline-flex; align-items:center; justify-content:center; gap:4px}
.btn small{color:var(--mute); font-weight:700}
.btn.primary{background:var(--ink); color:#fff; border-color:var(--ink)}
.btn.wide{width:100%; margin-top:8px}
.btn:disabled{opacity:.4; cursor:default}
.btn:active,.key:active{transform:scale(.96)}

.kbd{display:flex; flex-direction:column; gap:7px; user-select:none; padding-bottom:6px}
.krow{display:flex; justify-content:center; gap:5px}
.key{flex:1; max-width:42px; height:48px; border:0; border-radius:10px; background:#ece6dc; font-weight:800; font-size:16px; text-transform:uppercase; touch-action:manipulation}
.key.wide{max-width:64px; flex:1.5; font-size:13px}
.key.goal-letter{background:var(--plum-soft); color:var(--plum)}
.kbd.off .key{opacity:.35}

.ad-slot{margin:18px 0; min-height:100px; border:1.5px dashed #d6cfc3; border-radius:var(--r); display:grid; place-items:center; color:#a39c90; font-size:12px; letter-spacing:.04em; text-transform:uppercase; background:repeating-linear-gradient(45deg,transparent 0 10px,#f4efe7 10px 20px)}
.ad-slot.small{min-height:60px; margin:14px 0 0}

.content{padding:8px 4px 8px}
.content h1{font-size:26px; line-height:1.2; letter-spacing:-.02em; margin:18px 0 8px}
.content h2{font-size:19px; margin:26px 0 8px}
.lead{font-size:16px}
.steps{padding-left:20px} .steps li{margin:6px 0}
.example{background:var(--card); border:1px solid var(--line); border-radius:var(--r); padding:10px 14px}
.example p{margin:4px 0}
.ex{font-weight:800; letter-spacing:.04em; color:var(--ink)} .ex span{font-weight:600; color:var(--mute); letter-spacing:0}
.ex.small{font-size:13px; text-align:center}
.score{border-collapse:collapse; width:100%; background:var(--card); border-radius:var(--r); overflow:hidden; border:1px solid var(--line)}
.score th,.score td{padding:8px 12px; text-align:left; border-bottom:1px solid var(--line); font-size:14px}
details{background:var(--card); border:1px solid var(--line); border-radius:12px; padding:10px 14px; margin:8px 0}
summary{font-weight:700; cursor:pointer}
details p{margin:8px 0 2px; color:#3a4150}

.fine{max-width:520px; margin:10px auto 0; padding:18px 18px 34px; border-top:1px solid var(--line); color:#8a8f9a; font-size:11px; line-height:1.55; text-align:center}
.fine nav{margin-bottom:8px; font-size:12px} .fine a{color:#6b7180}

dialog{border:0; border-radius:24px; padding:22px 20px 18px; width:min(92vw,420px); max-height:90vh; color:var(--ink); background:var(--card); box-shadow:0 30px 80px -20px rgba(0,0,0,.45)}
dialog::backdrop{background:rgba(28,34,48,.45); backdrop-filter:blur(2px)}
dialog h2{margin:0 0 6px; text-align:center; font-size:26px; letter-spacing:-.02em}
.close{position:absolute; top:10px; right:10px} .close button{border:0; background:#f2ede5; width:34px; height:34px; border-radius:50%}
.r-emoji{font-size:44px; text-align:center; margin:4px 0 0}
.r-sub{text-align:center; color:var(--mute); margin:0 0 8px; font-weight:600}
.r-path{text-align:center; font-weight:800; letter-spacing:.04em; font-size:13px; margin:0 0 10px; text-transform:uppercase}
.r-share{background:#f7f3ec; border-radius:12px; padding:10px 12px; font-size:13px; line-height:1.35; white-space:pre-wrap; margin:0 0 12px; font-family:ui-monospace,Menlo,monospace}
.r-buttons{display:flex; gap:8px} .r-buttons .btn{flex:1}
.r-stats{display:grid; grid-template-columns:repeat(4,1fr); gap:6px; margin:14px 0 4px; text-align:center}
.stat b{display:block; font-size:22px} .stat span{font-size:11px; color:var(--mute); text-transform:uppercase; letter-spacing:.05em}
.r-next{text-align:center; color:var(--mute); font-size:13px; margin:8px 0 0}
.tiny{font-size:12px; color:var(--mute); text-align:center}
.dist{margin-top:12px} .dist div{display:flex; align-items:center; gap:8px; font-size:13px; margin:4px 0}
.dist i{display:block; height:18px; border-radius:6px; background:var(--plum); min-width:18px; color:#fff; font-style:normal; font-size:11px; padding:0 6px; line-height:18px; text-align:right}
.dist label{width:56px; color:var(--mute)}
#i-img{width:100%; border-radius:14px; margin:6px 0 12px; border:1px solid var(--line)}
.confetti{position:absolute; inset:0; pointer-events:none; overflow:hidden; border-radius:24px}
.confetti i{position:absolute; top:-10px; width:8px; height:12px; border-radius:2px; animation:fall 1.6s ease-in forwards}
@keyframes fall{to{transform:translateY(520px) rotate(540deg); opacity:0}}

.toast{position:fixed; white-space:nowrap; left:50%; bottom:24px; transform:translateX(-50%); background:var(--ink); color:#fff; padding:10px 16px; border-radius:999px; font-weight:700; font-size:14px; z-index:20; box-shadow:0 8px 24px rgba(0,0,0,.25)}
.page{max-width:680px; margin:0 auto; padding:10px 18px 30px}
.page h1{font-size:28px; letter-spacing:-.02em}
@media (max-width:370px){ :root{--tile:42px; --small:28px} .key{height:46px} .seg button{padding:7px 11px} }
@media (prefers-reduced-motion:reduce){ *{animation:none!important; transition:none!important; scroll-behavior:auto!important} }
