/* Word Ladder: a rope ladder up a sandstone cliff. */
:root {
  --sky: #cfe6ee; --sky-2: #eaf3f6; --stone: #d9c3a3; --stone-2: #c4a77f; --stone-3: #b08c62; --rope: #6b4a2b; --plank: #c99a63; --plank-2: #a97a48; --carve: #4a2f14; --flag: #d1462f; --sel: #ffe27a;
  --bg: var(--stone); --surface: #f2e6d2; --surface-2: #e4d3b6; --ink: #2f2113; --ink-2: #6e5637; --line: #b9a07c; --ok: #3e8f5c; --warn: #d9a521; --bad: #c2412d; --info: #2f6f8f; --accent: var(--rope); --accent-ink: #fff2dc;
  --font-display: "Bricolage Grotesque", "Rubik", system-ui, sans-serif; --font-ui: "Rubik", "Inter", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --sky: #1a2a3d; --sky-2: #0f1a28; --stone: #2a2118; --stone-2: #3a2d20; --stone-3: #4a3a2a; --plank: #8a6339; --plank-2: #6b4a2b; --carve: #f5e6cf; --sel: #7a6420; --bg: var(--stone); --surface: #3a2d20; --surface-2: #4a3a2a; --ink: #f5e6cf; --ink-2: #c6ad8b; --line: #5a4834; --accent: #c99a63; --accent-ink: #2f2113; } }
:root[data-theme="dark"] { --sky: #1a2a3d; --sky-2: #0f1a28; --stone: #2a2118; --stone-2: #3a2d20; --stone-3: #4a3a2a; --plank: #8a6339; --plank-2: #6b4a2b; --carve: #f5e6cf; --sel: #7a6420; --bg: var(--stone); --surface: #3a2d20; --surface-2: #4a3a2a; --ink: #f5e6cf; --ink-2: #c6ad8b; --line: #5a4834; --accent: #c99a63; --accent-ink: #2f2113; }
body { background: linear-gradient(var(--sky-2), var(--sky) 28%, var(--stone) 42%, var(--stone-2)); background-attachment: fixed; }
.screen { gap: 14px; max-width: 520px; margin-inline: auto; }
.topbar { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.screen-title { font-size: 1.9rem; font-weight: 800; margin-left: 6px; }
.btn { font-weight: 700; } .cta { font-size: 1.15rem; min-height: 52px; font-family: var(--font-display); font-weight: 800; }
.hero { text-align: center; padding-top: 4px; } .title { font-size: clamp(2.4rem, 11vw, 3.4rem); font-weight: 800; letter-spacing: -.02em; } .tagline { color: var(--ink-2); margin-top: 4px; font-weight: 500; }
.demo { display: flex; flex-direction: column-reverse; align-items: center; gap: 6px; margin-bottom: 8px; position: relative; padding: 6px 0; }
.demo::before, .demo::after { content: ""; position: absolute; top: 0; bottom: 0; width: 4px; background: repeating-linear-gradient(var(--rope) 0 6px, var(--plank-2) 6px 9px); border-radius: 2px; } .demo::before { left: calc(50% - 74px); } .demo::after { left: calc(50% + 70px); }
.plank { display: inline-block; width: 128px; padding: 4px 0; background: linear-gradient(var(--plank), var(--plank-2)); border-radius: 4px; font-family: var(--font-display); font-weight: 800; letter-spacing: .28em; color: var(--carve); text-shadow: 0 1px 0 rgb(255 255 255 / .35); box-shadow: 0 2px 0 var(--rope); }
.plank.top { background: var(--flag); color: #fff; text-shadow: none; }
.streak-pill { display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 12px; border-radius: var(--r-pill); background: var(--surface); color: var(--warn); font-weight: 700; box-shadow: var(--shadow-1); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mode { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; min-height: 66px; border-radius: 12px; background: var(--surface); color: var(--ink); text-align: left; box-shadow: var(--shadow-1); border: 2px solid transparent; }
.mode b { font-family: var(--font-display); font-size: 1.15rem; font-weight: 800; } .mode span { color: var(--ink-2); font-size: .8rem; line-height: 1.2; } .mode[aria-pressed="true"] { border-color: var(--rope); }
.seg-line { display: flex; background: var(--surface); border-radius: var(--r-pill); padding: 3px; box-shadow: var(--shadow-1); }
.seg-line button { flex: 1; height: 42px; border-radius: var(--r-pill); color: var(--ink-2); font-weight: 700; } .seg-line button[aria-checked="true"] { background: var(--rope); color: var(--accent-ink); }
.home-actions { display: flex; gap: 8px; } .home-actions .cta { flex: 2; } .home-actions > .btn:not(.cta) { flex: 1; background: var(--surface); box-shadow: var(--shadow-1); }

/* Play */
.screen[data-screen="play"] { height: 100dvh; min-height: 0; overflow: hidden; gap: 6px; }
.hud-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 800; white-space: nowrap; } .hud-note { color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.cliff { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 6px 0 4px; --w: min(100%, 340px); }
.cliff::before, .cliff::after { content: ""; position: absolute; top: 34px; bottom: 0; width: 6px; border-radius: 3px; background: repeating-linear-gradient(var(--rope) 0 7px, var(--plank-2) 7px 10px); box-shadow: 1px 0 0 rgb(0 0 0 / .15); } .cliff::before { left: calc(50% - var(--w) / 2 + 8px); } .cliff::after { right: calc(50% - var(--w) / 2 + 8px); }
.summit { display: flex; align-items: center; gap: 8px; width: var(--w); justify-content: center; margin-bottom: 6px; }
.flag { width: 0; height: 0; border-left: 18px solid var(--flag); border-top: 9px solid transparent; border-bottom: 9px solid transparent; position: relative; } .flag::before { content: ""; position: absolute; left: -22px; top: -12px; width: 3px; height: 30px; background: var(--rope); }
.target { display: flex; gap: 5px; } .target span { width: 34px; height: 38px; border-radius: 6px; background: var(--flag); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; display: inline-flex; align-items: center; justify-content: center; text-transform: uppercase; }
.ladder { flex: 1 1 auto; min-height: 0; width: var(--w); display: flex; flex-direction: column-reverse; justify-content: flex-start; gap: 6px; overflow: hidden; padding: 0 22px; mask-image: linear-gradient(transparent, #000 18%); }
.rung { display: flex; justify-content: center; gap: 5px; padding: 5px 8px; background: linear-gradient(var(--plank), var(--plank-2)); border-radius: 6px; box-shadow: 0 3px 0 var(--rope), 0 6px 10px rgb(0 0 0 / .2); flex: 0 0 auto; }
.rung span { width: 30px; height: 32px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; text-transform: uppercase; color: var(--carve); text-shadow: 0 1px 0 rgb(255 255 255 / .35); }
.rung span.changed { color: #fff; text-shadow: none; background: var(--rope); border-radius: 4px; } .rung[data-hint="true"] { outline: 2px dashed var(--warn); }
.rung.anim-in { animation: climb .35s var(--ease-spring); } @keyframes climb { from { transform: translateY(24px); opacity: 0; } }
.rung.current { width: var(--w); margin: 6px 22px 0; padding: 6px 8px; z-index: 1; } .rung.current button { width: clamp(38px, 11vw, 48px); height: 50px; border-radius: 6px; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; color: var(--carve); text-transform: uppercase; background: rgb(255 255 255 / .12); transition: background var(--t-fast), transform var(--t-fast); }
.rung.current button[aria-pressed="true"] { background: var(--sel); transform: translateY(-2px); box-shadow: 0 3px 0 var(--rope); } .rung.current.anim-shake { animation: shake-x var(--t-slow); }
.play-msg { text-align: center; min-height: 1.3em; color: var(--ink-2); font-weight: 600; font-size: .95rem; }
.tools { display: flex; justify-content: center; gap: 8px; } .tool { min-height: 44px; padding: 0 16px; background: var(--surface); box-shadow: var(--shadow-1); } .tool:disabled { opacity: .45; }
hg-keyboard { padding-bottom: env(safe-area-inset-bottom); } .key { background: var(--surface); box-shadow: var(--shadow-1); height: 46px; }
@media (min-width: 640px) { .screen[data-screen="play"] { max-width: 600px; } }

/* Result */
.result-verdict { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 2.8rem); text-align: center; font-weight: 800; line-height: 1.05; } .result-sub { text-align: center; color: var(--ink-2); font-weight: 500; }
.stars { display: flex; justify-content: center; gap: 6px; } .stars .icon { width: 32px; height: 32px; color: var(--line); } .stars .icon[data-on="true"] { color: var(--warn); fill: var(--warn); animation: pop var(--t-slow) var(--ease-spring) both; animation-delay: calc(var(--i) * 140ms); }
.path { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-family: var(--font-display); font-weight: 800; text-transform: uppercase; } .path span { padding: 3px 8px; border-radius: 6px; background: var(--surface-2); } .path span[data-hint="true"] { outline: 2px dashed var(--warn); } .path span:last-child { background: var(--flag); color: #fff; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; } .result-actions .cta { grid-column: 1 / -1; }
