:root {
  --ink: #17241f;
  --muted: #68736d;
  --paper: #f4f0e7;
  --card: #fffdf8;
  --line: #d9d3c6;
  --green: #164f3d;
  --lime: #d7ee72;
  --coral: #f07356;
  --tile: min(13vw, 68px);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--paper); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Manrope, sans-serif;
  background:
    radial-gradient(circle at 78% 16%, rgba(215,238,114,.18), transparent 24rem),
    linear-gradient(115deg, transparent 49.8%, rgba(23,36,31,.035) 50%, transparent 50.2%),
    var(--paper);
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
.grain { position: fixed; inset: 0; pointer-events: none; opacity: .09; z-index: 20; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.28'/%3E%3C/svg%3E"); }

.topbar { height: 74px; padding: 0 clamp(20px,5vw,64px); display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { color: inherit; display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font: 800 15px/1 Manrope; letter-spacing: .18em; }
.brand-mark { position: relative; width: 30px; height: 26px; display: inline-block; }
.brand-mark i { position: absolute; width: 11px; height: 11px; border: 2px solid var(--ink); transform: rotate(45deg); }
.brand-mark i:nth-child(1) { left: 0; top: 0; }.brand-mark i:nth-child(2) { left: 9px; top: 8px; }.brand-mark i:nth-child(3) { right: 0; bottom: 0; background: var(--lime); }
.top-actions { display: flex; gap: 8px; }
.icon-button { width: 40px; height: 40px; border: 1px solid var(--line); background: rgba(255,253,248,.5); border-radius: 50%; display: grid; place-items: center; color: var(--ink); font-weight: 700; cursor: pointer; transition: .2s ease; }
.icon-button:hover { border-color: var(--ink); transform: translateY(-2px); }
.icon-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; }

main { width: min(1050px, calc(100% - 36px)); margin: 0 auto; padding: 58px 0 48px; position: relative; }
.intro { text-align: center; max-width: 680px; margin: 0 auto 36px; }
.eyebrow, .dialog-kicker { font: 500 11px/1 DM Mono, monospace; letter-spacing: .14em; color: var(--muted); text-transform: uppercase; }
.eyebrow span { display: inline-block; width: 22px; height: 1px; background: var(--coral); vertical-align: middle; margin-right: 8px; }
.intro h1 { font-size: clamp(39px,6vw,68px); line-height: .99; letter-spacing: -.055em; margin: 19px 0 18px; font-weight: 700; }
.intro h1 em { color: var(--green); font-style: normal; font-weight: 500; }
.intro p { color: var(--muted); margin: 0 auto; max-width: 520px; font-size: 15px; line-height: 1.7; }

.game-shell { width: min(510px,100%); margin: 0 auto; background: rgba(255,253,248,.87); border: 1px solid var(--line); border-radius: 28px; padding: 22px clamp(16px,4vw,30px) 25px; box-shadow: 0 25px 70px rgba(31,51,42,.08); }
.game-meta { display: flex; justify-content: space-between; align-items: flex-end; padding: 0 3px 18px; }
.game-meta > div { display: flex; align-items: center; gap: 10px; }
.meta-label { font: 500 9px/1 DM Mono, monospace; color: #88918c; letter-spacing: .14em; }
#timer { font: 500 14px/1 DM Mono, monospace; }
.word-pips { display: flex; gap: 5px; }
.word-pips i { display: block; height: 7px; width: 21px; border-radius: 8px; background: #e6e1d6; transition: .35s; }
.word-pips i.on { background: var(--green); }
.board-wrap { position: relative; width: calc(var(--tile) * 5 + 32px); height: calc(var(--tile) * 5 + 32px); max-width: 100%; margin: 0 auto; user-select: none; touch-action: none; }
.board { display: grid; grid-template-columns: repeat(5,var(--tile)); grid-template-rows: repeat(5,var(--tile)); gap: 8px; position: absolute; inset: 0; justify-content: center; align-content: center; touch-action: none; -webkit-user-select: none; user-select: none; }
.tile { position: relative; z-index: 2; border: 1px solid #d7d1c5; border-radius: 14px; background: #fbf8f0; color: var(--ink); font: 600 clamp(20px,5vw,29px)/1 Manrope; cursor: pointer; box-shadow: 0 3px 0 #e3ddd1; transition: transform .12s, background .18s, color .18s, border-color .18s; }
.tile:hover:not(.used) { border-color: #9da69e; transform: translateY(-2px); }
.tile:focus-visible { outline: 3px solid var(--coral); outline-offset: 3px; z-index: 4; }
.tile.selected { background: var(--lime); border-color: #adc747; transform: scale(.94); box-shadow: none; }
.tile.used { background: var(--green); color: white; border-color: var(--green); box-shadow: none; cursor: default; }
.tile.hinted { animation: hint 1s ease 2; }
.block { border-radius: 13px; background: repeating-linear-gradient(135deg, transparent 0 8px, rgba(23,36,31,.025) 8px 9px); border: 1px dashed #ded8cc; }
@keyframes hint { 50% { box-shadow: 0 0 0 5px rgba(240,115,86,.25); border-color: var(--coral); } }
.path-layer { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; overflow: visible; }
.path-line { fill: none; stroke: var(--coral); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: .88; filter: drop-shadow(0 1px 0 rgba(255,255,255,.7)); }
.current-word { height: 54px; margin-top: 10px; display: flex; flex-direction: column; justify-content: center; align-items: center; }
#currentWord { min-height: 24px; font: 500 18px/1 DM Mono, monospace; letter-spacing: .22em; }
#currentWord:empty::before { content: attr(data-placeholder); color: #a8ada8; font-size: 11px; letter-spacing: .12em; }
#wordFeedback { font-size: 11px; color: var(--coral); margin-top: 6px; min-height: 13px; }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.text-button { border: 0; background: transparent; color: var(--muted); font-size: 12px; padding: 12px 4px; cursor: pointer; }
.text-button:hover { color: var(--ink); }
.primary-button { border: 0; border-radius: 999px; background: var(--ink); color: white; font-weight: 700; font-size: 12px; letter-spacing: .015em; padding: 14px 20px; cursor: pointer; transition: .2s ease; box-shadow: 0 5px 0 #07110d; }
.primary-button:hover { transform: translateY(-2px); background: var(--green); }
.primary-button:active { transform: translateY(2px); box-shadow: 0 2px 0 #07110d; }
.primary-button span { padding-left: 12px; }
.word-bank { text-align: center; margin: 24px auto 0; }
.word-bank > div { margin-top: 10px; display: flex; justify-content: center; gap: 8px; }
.length-chip { font: 500 12px/1 DM Mono, monospace; background: transparent; border: 1px solid #cfc8ba; border-radius: 99px; padding: 8px 13px; transition: .3s; }
.length-chip.done { background: var(--lime); border-color: var(--lime); text-decoration: line-through; color: #51601b; }
.new-puzzle { display: flex; margin: 26px auto 0; border: 0; border-bottom: 1px solid var(--ink); background: transparent; color: var(--ink); padding: 6px 2px; font-size: 12px; font-weight: 700; cursor: pointer; gap: 18px; }

footer { border-top: 1px solid var(--line); min-height: 66px; padding: 20px clamp(20px,5vw,64px); display: flex; justify-content: space-between; gap: 16px; color: #8c938f; font: 400 9px/1.5 DM Mono, monospace; letter-spacing: .08em; }

dialog { width: min(460px, calc(100% - 28px)); border: 1px solid var(--line); border-radius: 25px; color: var(--ink); background: var(--card); padding: 36px; box-shadow: 0 30px 100px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(18,29,24,.62); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 15px; right: 17px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: transparent; font-size: 21px; cursor: pointer; }
dialog h2 { margin: 12px 0 22px; font-size: 34px; letter-spacing: -.04em; }
dialog ol { padding-left: 22px; color: var(--muted); font-size: 14px; line-height: 1.55; }
dialog li { padding: 4px 0 10px 7px; } dialog li b { color: var(--ink); }
.keyboard-note { font-size: 12px; line-height: 1.55; color: var(--ink); background: #f1eddf; border-radius: 12px; padding: 11px 13px; }
.dialog-note { font-size: 11px; line-height: 1.55; color: #8b918e; border-top: 1px solid var(--line); padding-top: 15px; }
.dialog-action { width: 100%; margin-top: 12px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-grid div { border: 1px solid var(--line); border-radius: 14px; padding: 18px; text-align: center; }
.stats-grid strong { display: block; font: 500 27px/1 DM Mono, monospace; }.stats-grid span { font-size: 10px; color: var(--muted); }
.win-dialog { text-align: center; }.win-spark { font-size: 40px; color: var(--coral); margin-bottom: 10px; }.win-dialog h2 { margin-bottom: 10px; }.win-dialog p { color: var(--muted); font-size: 14px; }.solved-words { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin: 22px 0 8px; }.solved-words span { background: var(--lime); border-radius: 99px; padding: 7px 11px; font: 500 11px/1 DM Mono,monospace; }.dialog-secondary { display: block; margin: 8px auto 0; }
.toast { position: fixed; left: 50%; bottom: 25px; z-index: 100; transform: translate(-50%, 20px); background: var(--ink); color: white; border-radius: 99px; padding: 11px 18px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s; }.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 560px) {
  :root { --tile: min(15.2vw, 64px); }
  .topbar { height: 62px; }.intro { margin-bottom: 28px; }.intro p { font-size: 13px; }
  main { padding-top: 38px; width: min(100% - 22px, 1050px); }.game-shell { border-radius: 22px; padding-left: 10px; padding-right: 10px; }
  .board-wrap { width: calc(var(--tile) * 5 + 32px); height: calc(var(--tile) * 5 + 32px); }
  footer { flex-direction: column; text-align: center; }.controls { padding: 0 5px; }.primary-button { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
