:root {
  --ink: #253332;
  --muted: #76807e;
  --paper: #f7f4ed;
  --card: #fffdfa;
  --mint: #74b9a6;
  --mint-dark: #438d7b;
  --mint-soft: #dcefe9;
  --line: #e6e3db;
  --shadow: 0 18px 45px rgba(54, 65, 62, .10);
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Avenir Next", "Segoe UI", sans-serif;
  --font-display: "Avenir Next", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: #e8ece9; color: var(--ink); font-family: var(--font-ui); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button, .board { touch-action: manipulation; }
button:focus-visible { outline: 3px solid rgba(71, 151, 130, .3); outline-offset: 2px; }

.app-shell { width: min(100%, 430px); min-height: 100dvh; margin: 0 auto; background: var(--paper); position: relative; overflow: hidden; padding-bottom: 92px; box-shadow: 0 0 70px rgba(30, 45, 40, .1); }
.topbar { height: calc(67px + env(safe-area-inset-top)); padding: calc(13px + env(safe-area-inset-top)) 21px 8px; display: flex; align-items: center; justify-content: space-between; }
.icon-button, .streak-pill, .close-button { border: 0; background: none; cursor: pointer; }
.icon-button { width: 38px; height: 38px; padding: 8px; }
.icon-button svg, .streak-pill svg { fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.brand { display: flex; align-items: center; gap: 9px; font: 800 20px/1 var(--font-display); letter-spacing: -.7px; }
.brand-mark { width: 20px; height: 21px; display: flex; align-items: flex-end; gap: 2px; transform: rotate(-4deg); }
.brand-mark i { width: 5px; background: var(--mint); border-radius: 4px; display: block; }
.brand-mark i:nth-child(1) { height: 13px; transform: rotate(-18deg); }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 14px; transform: rotate(18deg); }
.streak-pill { display: flex; align-items: center; gap: 3px; height: 36px; padding: 0 11px 0 8px; border: 1px solid #e4dfd6; border-radius: 999px; background: rgba(255,255,255,.55); font-weight: 700; }
.streak-pill svg { width: 20px; stroke: #ed866d; fill: #f7b19e; stroke-width: 1.5; }

main { padding: 18px 21px 25px; }
.puzzle-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.eyebrow { margin: 0 0 5px; color: var(--mint-dark); font-size: 10px; font-weight: 800; letter-spacing: 1.7px; }
h1, h2 { font-family: var(--font-display); }
h1 { margin: 0; font-size: 27px; line-height: 1.1; letter-spacing: -1px; }
.difficulty-button { display: flex; align-items: center; gap: 6px; height: 33px; padding: 0 10px; border: 1px solid #dedbd3; border-radius: 10px; background: #fffdfa; font-size: 11px; font-weight: 700; cursor: pointer; box-shadow: 0 2px 4px rgba(31,45,41,.03); }
.difficulty-button svg { width: 13px; fill: none; stroke: currentColor; stroke-width: 2; }
.difficulty-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mint); }
.progress-wrap { margin: 18px 1px 14px; }
.progress-copy { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: 11px; font-weight: 600; }
.progress-track { height: 5px; background: #e5e3dc; border-radius: 99px; overflow: hidden; }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--mint); transition: width .45s cubic-bezier(.2,.8,.2,1); }

.board-card { padding: 15px; border: 1px solid rgba(216,214,205,.8); background: var(--card); border-radius: 20px; box-shadow: var(--shadow); }
.board { --size: 8; display: grid; grid-template-columns: repeat(var(--size), 1fr); aspect-ratio: 1; user-select: none; touch-action: none; position: relative; }
.cell { position: relative; display: grid; place-items: center; border: 0; background: transparent; padding: 0; font: 700 clamp(14px, 4.7vw, 20px)/1 var(--font-display); cursor: pointer; z-index: 1; }
.cell::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; background: transparent; transform: scale(.5); z-index: -1; transition: transform .13s ease, background .13s ease; }
.cell.preview::before { transform: scale(1); background: #e3f0ec; }
.cell.found { color: #235f53; }
.cell.found::before { transform: scale(1); background: var(--mint-soft); }
.cell.hinted::before { animation: hintPulse 1s ease 2; }
.cell.pop { animation: cellPop .35s cubic-bezier(.2, 1.5, .4, 1) both; }

.word-section { margin-top: 19px; }
.section-label { display: flex; justify-content: space-between; color: #8a918f; font-size: 9px; font-weight: 800; letter-spacing: 1.25px; }
.word-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px 11px; margin-top: 11px; }
.word { position: relative; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; text-transform: capitalize; transition: opacity .25s ease, color .25s ease; }
.word::before { content: ""; width: 5px; height: 5px; flex: 0 0 5px; border-radius: 50%; background: #c7cbc8; transition: .25s; }
.word.done { color: #929a97; opacity: .72; text-decoration: line-through; text-decoration-thickness: 1px; }
.word.done::before { background: var(--mint); transform: scale(1.25); }
.actions { display: grid; grid-template-columns: 1fr 1.55fr; gap: 10px; margin-top: 19px; }
.actions button, .trial-button { height: 47px; border-radius: 14px; cursor: pointer; font-weight: 700; transition: transform .12s ease, filter .12s ease; }
.actions button:active, .trial-button:active { transform: scale(.97); }
.hint-button { border: 1px solid #dad8d0; background: #fffdfa; display: flex; align-items: center; justify-content: center; gap: 7px; }
.hint-button svg { width: 18px; fill: none; stroke: var(--mint-dark); stroke-width: 1.8; }
.hint-button span { display: grid; place-items: center; width: 20px; height: 20px; margin-left: 2px; background: #edf0ec; border-radius: 50%; font-size: 10px; }
.new-button, .trial-button { border: 0; color: white; background: var(--ink); }
.how-to-play { margin-top: 25px; padding: 20px 18px; border-top: 1px solid var(--line); }
.instruction-kicker { margin: 0 0 5px; color: var(--mint-dark); font-size: 9px; font-weight: 800; letter-spacing: 1.5px; }
.how-to-play h2 { margin: 0; font-size: 18px; letter-spacing: -.45px; }
.how-to-play ol { margin: 13px 0 0; padding-left: 22px; color: var(--muted); font-size: 11px; line-height: 1.55; }
.how-to-play li { padding-left: 3px; }
.how-to-play li + li { margin-top: 6px; }

.woven-tools { margin-top: 16px; padding: 6px; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 5px; border: 1px solid var(--line); border-radius: 15px; background: #ecebe5; }
.woven-tool { min-height: 45px; padding: 5px 8px; display: flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 11px; color: #7e8985; background: transparent; font-size: 11px; font-weight: 700; }
.woven-tool svg { width: 18px; height: 18px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.woven-tool:first-child svg { fill: currentColor; stroke: none; }
.woven-tool.active { color: var(--mint-dark); background: var(--card); box-shadow: 0 2px 8px rgba(38,53,49,.08); }

.overlay, .celebration { position: fixed; inset: 0; z-index: 20; display: flex; justify-content: center; align-items: flex-end; background: rgba(21,32,30,.36); backdrop-filter: blur(3px); animation: fadeIn .2s ease; }
.overlay[hidden], .celebration[hidden] { display: none; }
.sheet { width: min(100%, 430px); padding: 10px 22px calc(28px + env(safe-area-inset-bottom)); background: var(--paper); border-radius: 27px 27px 0 0; animation: sheetUp .35s cubic-bezier(.16,1,.3,1); box-shadow: 0 -16px 40px rgba(21,32,30,.15); }
.sheet-handle { width: 39px; height: 4px; margin: 0 auto 22px; border-radius: 9px; background: #d4d2ca; }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; }
.sheet h2 { margin: 0; font-size: 24px; letter-spacing: -.8px; }
.close-button { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: #ebe9e3; font-size: 24px; font-weight: 300; line-height: 1; }
.level-options { display: grid; gap: 10px; margin-top: 22px; }
.level-card { min-height: 68px; padding: 10px 14px; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; border: 1px solid #dedbd3; border-radius: 16px; background: #fffdfa; text-align: left; cursor: pointer; transition: transform .12s, border-color .12s; }
.level-card:active { transform: scale(.985); }
.level-card b, .level-card small { display: block; }
.level-card b { font: 700 15px var(--font-display); }
.level-card small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.level-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 13px; font-weight: 800; }
.level-icon.mint { background: #def0e9; color: #4c907e; }
.level-icon.blue { background: #e1ebf0; color: #597e8f; }
.level-icon.coral { background: #f5e1d9; color: #b86c54; }
.radio { width: 17px; height: 17px; border: 2px solid #c9cecb; border-radius: 50%; }
.plus-tag { padding: 4px 7px; color: #8f682a; background: #f5e8c7; border-radius: 6px; font-size: 8px; font-weight: 800; letter-spacing: 1px; }
.free-note { margin: 17px 0 0; color: var(--muted); text-align: center; font-size: 10px; }

.install-copy { margin: 13px 0 19px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.install-action { width: 100%; padding: 12px; display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 17px; background: #fffdfa; text-align: left; cursor: pointer; }
.install-action:active { transform: scale(.985); }
.install-action b, .install-action small { display: block; }
.install-action b { font-size: 13px; }
.install-action small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.install-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 13px; background: var(--mint-soft); }
.install-icon .brand-mark { transform: scale(.8); }
.install-arrow { color: var(--muted); font-size: 27px; font-weight: 300; }
.offline-ready { margin-top: 12px; padding: 13px 15px; display: flex; gap: 12px; align-items: center; border-radius: 15px; background: #e8f1ed; text-align: left; }
.offline-ready > span { width: 27px; height: 27px; display: grid; place-items: center; color: white; background: var(--mint); border-radius: 50%; font-weight: 800; }
.offline-ready p { margin: 0; }
.offline-ready b, .offline-ready small { display: block; }
.offline-ready b { color: var(--mint-dark); font-size: 11px; }
.offline-ready small { margin-top: 2px; color: var(--muted); font-size: 9px; }

.sheet.paywall { position: relative; text-align: center; padding-top: 38px; }
.floating { position: absolute; top: 17px; right: 18px; }
.premium-orbit { width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff8dd, #ecd7a9); display: grid; place-items: center; position: relative; color: #9c7130; font-size: 34px; box-shadow: 0 12px 35px rgba(168,124,57,.18); }
.premium-orbit i { position: absolute; width: 8px; height: 8px; background: #7bb8a8; border-radius: 50%; }
.premium-orbit i:first-of-type { top: 3px; right: 5px; }
.premium-orbit i:last-of-type { bottom: 8px; left: 0; transform: scale(.6); }
.paywall h2 { font-size: 29px; line-height: 1.15; }
.paywall-sub { width: 88%; margin: 12px auto 19px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.benefits { display: grid; gap: 12px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: #fffdfa; text-align: left; }
.benefits div { display: flex; align-items: center; gap: 12px; }
.benefits div > span { width: 34px; color: var(--mint-dark); font: 700 22px var(--font-display); text-align: center; }
.benefits p { margin: 0; }
.benefits b, .benefits small { display: block; }
.benefits b { font-size: 12px; }
.benefits small { margin-top: 2px; color: var(--muted); font-size: 10px; }
.trial-button { width: 100%; margin-top: 17px; }
.price-note { margin: 9px 0 0; color: var(--muted); font-size: 9px; }
.restore-button { margin-top: 13px; border: 0; background: none; color: var(--muted); font-size: 10px; text-decoration: underline; }

.toast { position: fixed; z-index: 50; left: 50%; bottom: 95px; padding: 10px 16px; color: white; background: rgba(36,50,48,.94); border-radius: 99px; font-size: 11px; font-weight: 700; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .25s ease; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.celebration { align-items: center; padding: 20px; }
.celebration-card { width: min(350px, 100%); padding: 35px 30px 29px; text-align: center; background: var(--paper); border-radius: 25px; box-shadow: 0 25px 70px rgba(22,34,31,.25); animation: winIn .5s cubic-bezier(.2,1.4,.4,1); }
.celebration-card h2 { margin: 0; font-size: 26px; }
.celebration-card > p:not(.eyebrow) { color: var(--muted); font-size: 13px; }
.celebration-card .new-button { width: 100%; height: 47px; margin-top: 10px; border-radius: 14px; }
.win-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 18px; color: white; background: var(--mint); border-radius: 50%; font-size: 28px; box-shadow: 0 9px 24px rgba(78,151,132,.3); }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes winIn { from { transform: scale(.82); opacity: 0; } }
@keyframes cellPop { 50% { transform: scale(1.18); } }
@keyframes hintPulse { 0%,100% { background: transparent; transform: scale(.5); } 50% { background: #f5dca6; transform: scale(1); } }

@media (min-width: 431px) {
  body { padding: 16px 0; }
  .app-shell { min-height: calc(100dvh - 32px); border-radius: 28px; }
}

@media (max-height: 750px) {
  main { padding-top: 6px; }
  .topbar { height: 56px; padding-top: 8px; }
  .progress-wrap { margin: 12px 1px 10px; }
  .board-card { padding: 11px; }
  .word-section { margin-top: 13px; }
  .actions { margin-top: 13px; }
}
