:root {
  --ink: #2b2350;
  --ink2: #5b5480;
  --paper: #fbf6ec;
  --card: #ffffff;
  --line: #e8e0d0;
  --accent: #ff7a3d;
  --accent2: #ffb347;
  --good: #23a26d;
  --bad: #d9475b;
  --tile: #ffffff;
  --tile-edge: #d3bf96;     /* bridges */
  --sel: #3355d6;           /* letters in the current selection */
  --sel-ink: #ffffff;
  --valid: #1c9a5b;         /* selection spells an unfound word */
  --dup: #8d88a8;           /* selection is an already-found word */
  --hl: #ffcf6b;            /* soft highlight (tabs, logo, falling letter) */
  --radius: 14px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); }
body { min-height: 100vh; -webkit-tap-highlight-color: transparent; }
#app { max-width: 520px; margin: 0 auto; padding: 14px 14px calc(24px + env(safe-area-inset-bottom)); }
.hidden { display: none !important; }
h3 { margin: 0 0 10px; font-size: 16px; }
h3 small { font-weight: 400; color: var(--ink2); }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 15px; color: var(--ink);
  background: var(--card); border: 2px solid var(--ink); border-radius: 999px;
  padding: 9px 16px; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  transition: transform .06s, box-shadow .06s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.big { font-size: 18px; padding: 12px 22px; }
.btn.small { font-size: 13px; padding: 5px 12px; box-shadow: 0 2px 0 var(--ink); }
.btn.ghost { border: none; box-shadow: none; background: transparent; font-size: 20px; padding: 6px 10px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 14px 0; }

/* ---------- home ---------- */
.masthead { text-align: center; margin: 10px 0 16px; }
.logo { margin: 0; font-size: 52px; letter-spacing: 2px; display: flex; justify-content: center; gap: 4px; }
.logo span {
  display: inline-grid; place-items: center; width: 1.05em; height: 1.1em;
  background: var(--tile); border: 3px solid var(--ink); border-radius: 12px;
  box-shadow: 0 4px 0 var(--ink); font-size: .72em;
  animation: wob 2.8s ease-in-out infinite;
}
.logo span:nth-child(2n) { background: var(--hl); animation-delay: -.7s; }
.logo span:nth-child(3n) { animation-delay: -1.4s; }
@keyframes wob { 0%,100% { transform: rotate(-4deg) translateY(0); } 50% { transform: rotate(4deg) translateY(-3px); } }
.tag { color: var(--ink2); margin: 14px auto 0; max-width: 360px; line-height: 1.35; }

.card {
  background: var(--card); border: 2px solid var(--ink); border-radius: var(--radius);
  padding: 14px; margin: 12px 0; box-shadow: 0 4px 0 var(--ink);
}
.kicker { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink2); font-weight: 700; }
.today-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.today-title { font-size: 24px; font-weight: 800; }
.me-line { margin-top: 8px; color: var(--ink2); font-size: 14px; min-height: 1em; }
.me-line b { color: var(--ink); }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { font: inherit; font-weight: 700; font-size: 13px; border: 2px solid var(--line); background: none;
  color: var(--ink2); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.tab.on { border-color: var(--ink); color: var(--ink); background: var(--hl); }

.lb { font-size: 14px; }
.lb table { width: 100%; border-collapse: collapse; }
.lb td, .lb th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.lb th { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink2); }
.lb td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.lb th.n { text-align: right; }
.lb tr.me td { background: #fff1d6; }
.lb .rk { width: 28px; color: var(--ink2); }
.lb .empty { color: var(--ink2); text-align: center; padding: 16px 0; }
.foot { text-align: center; color: var(--ink2); font-size: 12px; margin-top: 18px; }

/* ---------- game ---------- */
#game { user-select: none; -webkit-user-select: none; }
.hud { display: flex; align-items: center; gap: 10px; }
.hud-mid { flex: 1; text-align: center; }
.clock { font-weight: 800; font-size: 22px; font-variant-numeric: tabular-nums; }
.hud-score { min-width: 72px; text-align: right; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hud-score small { display: block; font-size: 11px; color: var(--ink2); font-weight: 700; }

.word-line { height: 48px; position: relative; display: grid; place-items: center; margin: 4px 0; }
.current { font-size: 28px; font-weight: 800; letter-spacing: 3px; text-transform: uppercase; }
.current.good { color: var(--valid); }
.current.dup { color: var(--dup); }
.flash { position: absolute; font-size: 20px; font-weight: 800; pointer-events: none; opacity: 0; white-space: nowrap; }
.flash.show { animation: flash 1s ease-out; }
.flash.good { color: var(--good); }
.flash.bad { color: var(--bad); }
.flash.meh { color: var(--ink2); }
@keyframes flash { 0% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-26px) scale(1); } }

.grid-wrap, .mini-board { position: relative; width: 100%; max-width: 420px; max-height: 58vh; margin: 0 auto; touch-action: none;
  container-type: inline-size; }
.mini-board { max-width: 240px; margin: 14px auto 4px; touch-action: auto; }
.bridges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.bridges line { stroke: var(--tile-edge); stroke-width: 15; stroke-linecap: round; stroke-dasharray: 24 0;
  transform-box: fill-box; transform-origin: center; }
.bridges line.gone { visibility: hidden; }
/* bridge crumbles: flashes, cracks into pieces, drops and fades */
.bridges line.crumble { animation: crumble .5s ease-in forwards; }
@keyframes crumble {
  0%   { stroke: var(--accent); }
  35%  { stroke: var(--accent); stroke-dasharray: 18 6; transform: translateY(0); opacity: 1; }
  100% { stroke: var(--tile-edge); stroke-dasharray: 3 21; transform: translateY(26px); opacity: 0; }
}
.trailline { fill: none; stroke: var(--sel); stroke-width: 20; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }

.tile {
  position: absolute; transform: translate(-50%, -50%) rotate(var(--rot, 0deg));
  width: calc(100cqw / var(--cols) * .58); height: calc(100cqw / var(--cols) * .58);
  display: grid; place-items: center; border-radius: 22%;
  background: var(--tile); border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink);
  font-weight: 800; font-size: calc(100cqw / var(--cols) * .34); text-transform: uppercase;
  transition: transform .1s, background .1s, color .1s;
  cursor: pointer; z-index: 1;
}
.mini-board .tile { border-width: 2px; box-shadow: 0 2px 0 var(--ink); cursor: default; }
.tile.sel { background: var(--selc, var(--sel)); color: var(--sel-ink); border-color: #142266; }
.tile.head { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1.12);
  box-shadow: 0 4px 0 #142266, 0 0 0 5px rgba(51, 85, 214, .28); z-index: 2; }
.mini-board .tile.sel { transform: translate(-50%, -50%) rotate(var(--rot, 0deg)); }
.tile.cheer { animation: cheer .34s ease-out both; }
@keyframes cheer {
  0%   { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1); }
  40%  { transform: translate(-50%, -68%) rotate(0deg) scale(1.22); background: var(--valid); color: #fff; border-color: #0d5532; }
  100% { transform: translate(-50%, -50%) rotate(var(--rot)) scale(1); background: var(--valid); color: #fff; border-color: #0d5532; }
}
.confetti-layer { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 40; pointer-events: none; }

.banner { position: absolute; left: 50%; top: 42%; z-index: 6; pointer-events: none; text-align: center;
  background: var(--valid); color: #fff; border: 3px solid var(--ink); border-radius: 18px; box-shadow: 0 5px 0 var(--ink);
  text-shadow: 0 1px 2px rgba(0,0,0,.35);
  padding: 8px 22px 10px; animation: banner 1.05s cubic-bezier(.2,.9,.3,1) both; white-space: nowrap; }
.banner .praise { font-size: 15px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; opacity: .9; }
.banner .bword { font-size: min(clamp(28px, 9cqw, 46px), calc(125cqw / var(--len, 6))); font-weight: 900; letter-spacing: 3px; text-transform: uppercase; line-height: 1.1; }
.banner .extras { font-size: 15px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: #d9ffe9; margin-top: 2px; }
.banner.big { background: linear-gradient(135deg, #ff7a3d, #e0457b); }
.banner.big .bword { font-size: min(clamp(32px, 11cqw, 56px), calc(125cqw / var(--len, 6))); letter-spacing: 2px; }
.banner.huge { background: linear-gradient(135deg, #6c4bd8, #e0457b, #ff7a3d); }
@keyframes banner {
  0%   { transform: translate(-50%, -50%) scale(.3) rotate(-8deg); opacity: 0; }
  18%  { transform: translate(-50%, -50%) scale(1.12) rotate(2deg); opacity: .78; }
  30%  { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
  75%  { transform: translate(-50%, -60%) scale(1); opacity: .72; }
  100% { transform: translate(-50%, -110%) scale(.9); opacity: 0; }
}
#nfound { display: inline-block; }
#nfound.bump { animation: bump .5s; color: var(--valid); }
@keyframes bump { 30% { transform: scale(1.45); } }
.tile.gone, .tile.gone.wobble { visibility: hidden; pointer-events: none; animation: none; }
/* orphaned letter: hops, then tumbles away */
.tile.falling, .tile.falling.wobble { animation: fall .6s cubic-bezier(.4,-0.3,.8,.6) both; pointer-events: none; }
@keyframes fall {
  0%   { transform: translate(-50%, -50%) rotate(var(--rot)); opacity: 1; }
  25%  { transform: translate(-50%, -75%) rotate(-10deg) scale(1.12); opacity: 1; background: var(--hl); }
  100% { transform: translate(-50%, 90%) rotate(50deg) scale(.3); opacity: 0; }
}
.tile.wobble { animation: tilewob .45s ease-in-out; }
@keyframes tilewob { 25% { transform: translate(-50%, -50%) rotate(-12deg); } 50% { transform: translate(-50%, -50%) rotate(9deg); } 75% { transform: translate(-50%, -50%) rotate(-5deg); } }
.grid-wrap.cleared::after { content: "Cleared!"; position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 44px; font-weight: 900; color: var(--accent); animation: pop .6s; }

.controls { display: flex; justify-content: space-between; align-items: center; margin: 14px 4px 6px; gap: 8px; }
.hint { color: var(--ink2); font-size: 12px; }
.center { text-align: center; }

.list-col h3 { margin-bottom: 6px; }
.slotrow { margin: 8px 0; }
.slotlen { font-size: 12px; font-weight: 700; color: var(--ink2); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.slotlen span { color: var(--ink); margin-left: 4px; }
.slots { display: flex; flex-wrap: wrap; gap: 5px; }
.slot { font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 14px; letter-spacing: 2px; text-transform: uppercase;
  border: 2px dashed var(--line); border-radius: 8px; padding: 2px 7px; color: #c9bda5; }
.slot.got { border: 2px solid var(--good); color: var(--ink); background: #eafaf2; }
.slot.hint { border-color: var(--accent2); color: var(--ink); }
.slot.new { animation: slotnew 1.4s ease-out; }
@keyframes slotnew { 0% { transform: scale(.3); box-shadow: 0 0 0 0 rgba(28,154,91,.7); }
  25% { transform: scale(1.25); background: var(--valid); color: #fff; }
  60% { box-shadow: 0 0 0 10px rgba(28,154,91,0); } }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.15); } }

@media (min-width: 860px) {
  #app:has(#game:not(.hidden)) { max-width: 940px; }
  .game-body { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start; }
  .list-col { margin-top: 56px; }
}

/* ---------- results ---------- */
.res-top { text-align: center; }
.wordlist { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--card); border: 2px solid var(--good); border-radius: 999px; padding: 3px 10px; cursor: pointer;
  font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; }
.chip.miss { border: 2px dashed var(--bad); color: var(--ink2); }
.chip.bonus { border-color: var(--line); color: var(--ink2); }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(30, 24, 60, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.sheet { position: relative; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius);
  box-shadow: 0 6px 0 var(--ink); width: min(440px, 100%); max-height: 88vh; overflow-y: auto; padding: 18px; }
.sheet .close { position: absolute; top: 6px; right: 6px; }
.sheet h2 { margin: 0 0 10px; }
.sheet p { line-height: 1.4; }
.sheet input[type=text] { font: inherit; font-size: 17px; width: 100%; padding: 10px 12px; border: 2px solid var(--ink);
  border-radius: 10px; background: #fff; margin: 4px 0 10px; }
.sheet .err { color: var(--bad); min-height: 1.2em; font-size: 14px; }
.sheet .key { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: #fff; border: 2px dashed var(--line);
  padding: 8px; border-radius: 8px; word-break: break-all; user-select: all; }
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stats-grid div { background: #fff; border: 2px solid var(--line); border-radius: 10px; text-align: center; padding: 8px 4px; }
.stats-grid b { display: block; font-size: 24px; }
.stats-grid span { font-size: 11px; color: var(--ink2); text-transform: uppercase; letter-spacing: .8px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin-top: 6px; }
.spark div { flex: 1; background: var(--accent2); border-radius: 3px 3px 0 0; min-height: 2px; }
.score-table { width: 100%; font-size: 14px; border-collapse: collapse; }
.score-table td { padding: 3px 6px; border-bottom: 1px solid var(--line); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(80px); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-weight: 700; transition: transform .25s; z-index: 60; pointer-events: none; }
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-height: 700px) {
  .word-line { height: 40px; }
  .current { font-size: 24px; }
  .grid-wrap { width: min(100%, 360px); }
}

/* ---------- charts & numbers ---------- */
h4 { margin: 16px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink2); }
h4 small { text-transform: none; letter-spacing: 0; font-weight: 400; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis { stroke: #cfc6b4; stroke-width: 1; }
.chart .grid { stroke: #ece5d6; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .ytick, .chart .xtick { font-size: 9px; fill: var(--ink2); font-family: inherit; }
.chart .bar { fill: var(--sel); }
.chart .bar.me { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--sel); stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--sel); stroke: #fff; stroke-width: 2; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .dot, .chart .hit:hover { fill: rgba(51, 85, 214, .08); }
.rates { display: grid; gap: 3px; }
.rate { display: grid; grid-template-columns: 110px 1fr 38px; align-items: center; gap: 8px; font-size: 12px; }
.rate .rl { font-weight: 700; text-transform: uppercase; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; }
.rate .rb { position: relative; height: 10px; background: #f1ebdf; border-radius: 0 4px 4px 0; overflow: hidden; }
.rate .rb em { position: absolute; top: -1px; bottom: -1px; width: 3px; margin-left: -1px; background: var(--accent); }
.rate .rb i { display: block; height: 100%; background: var(--sel); border-radius: 0 4px 4px 0; }
.rate .rv { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink2); }
table.facts { width: 100%; font-size: 13px; border-collapse: collapse; }
table.facts td { padding: 5px 4px; border-bottom: 1px solid var(--line); }
table.facts td:first-child { color: var(--ink2); }
table.facts td:last-child { text-align: right; font-weight: 700; }
.stats-grid div[data-tip] { cursor: help; }
.tip { position: absolute; z-index: 80; transform: translate(-50%, -100%); background: var(--ink); color: #fff; font-size: 12px;
  padding: 5px 9px; border-radius: 8px; pointer-events: none; opacity: 0; transition: opacity .1s; white-space: nowrap; }
.tip.show { opacity: 1; }
#resTimeline:empty { display: none; }

/* ---------- stats carousel ---------- */
.car-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.car-head h3 { margin: 0; text-align: center; flex: 1; }
.car-arrow { border: 0; background: none; font: 700 24px/1 inherit; color: var(--ink); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }
.car-arrow:hover:not(:disabled) { background: #f1ebdf; }
.car-arrow:disabled { opacity: .2; cursor: default; }
.car-view { overflow: hidden; touch-action: pan-y; transition: height .25s; outline: none; cursor: grab; }
.car-view.dragging { cursor: grabbing; }
.car-track { display: flex; align-items: flex-start; transition: transform .3s cubic-bezier(.2,.8,.3,1); will-change: transform; }
.pane { flex: 0 0 100%; min-width: 0; box-sizing: border-box; padding: 0 2px; }
.dots { display: flex; justify-content: center; gap: 2px; margin-top: 8px; }
.dots button { width: 24px; height: 24px; border: 0; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; }
.dots button::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #d8cfbd; transition: background .2s, transform .2s; }
.dots button.on::after { background: var(--sel); transform: scale(1.25); }

/* ---------- responsive ---------- */
@media (min-width: 900px) {
  #app:has(#home:not(.hidden)), #app:has(#results:not(.hidden)) { max-width: 980px; }
  #results .mini-board { max-width: 300px; }
  .home-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 22px; align-items: start; }
}
@media (max-width: 380px) {
  #app { padding-left: 8px; padding-right: 8px; }
  .stats-grid { gap: 5px; }
  .stats-grid b { font-size: 18px; }
  .rate { grid-template-columns: 86px 1fr 34px; gap: 5px; }
  .row-btns .btn { padding-left: 10px; padding-right: 10px; }
}
/* phones in landscape: board and word list side by side */
@media (orientation: landscape) and (max-height: 520px) {
  #app:has(#game:not(.hidden)) { max-width: 900px; }
  .game-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 40%); gap: 14px; align-items: start; }
  .grid-wrap { max-height: 72vh; max-width: 72vh; }
  .list-col { max-height: 80vh; overflow: auto; }
}

/* ---------- themed puzzles ---------- */
.theme-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.theme-row:first-child { border-top: 0; }
.theme-emoji { font-size: 28px; width: 36px; text-align: center; }
.theme-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.theme-txt span { font-size: 12px; color: var(--ink2); }

/* ---------- last attempt status line ---------- */
.last-try { text-align: center; font-size: 13px; color: var(--ink2); min-height: 18px; margin: -2px 0 4px; }
.last-try b { color: var(--ink); letter-spacing: .5px; }
.last-try.good span { color: var(--valid); font-weight: 700; }
.last-try.bad span { color: #c0392b; font-weight: 700; }
.last-try.meh span { color: var(--dup); font-weight: 700; }

/* ---------- no text selection (drags and taps shouldn't highlight text) ---------- */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, [contenteditable] { -webkit-user-select: text; user-select: text; }

/* ---------- shared header: big on home, compact elsewhere; logo = home ---------- */
.logo-wrap { margin: 0; }
button.logo { border: 0; background: none; padding: 0; margin: 0 auto; font: inherit; font-weight: 900; color: var(--ink); cursor: pointer; }
.masthead.compact { margin: 0 0 8px; }
.masthead.compact .logo { font-size: 28px; gap: 2px; }
.masthead.compact .logo span { border-width: 2px; border-radius: 7px; box-shadow: 0 2px 0 var(--ink); animation: none; }
.masthead.compact .tag { display: none; }
.hud-side { min-width: 72px; }
/* stats inside the daily card */


/* puzzle-kind colors (validated: CVD-safe, >=3:1 on white) */
:root { --k-daily: #2f52d4; --k-theme: #eb7a2a; --k-practice: #14958a; }
.chart .bar.k-daily, .chart .dot.k-daily { fill: var(--k-daily); }
.chart .bar.k-theme, .chart .dot.k-theme { fill: var(--k-theme); }
.chart .bar.k-practice, .chart .dot.k-practice { fill: var(--k-practice); }
.chart .line.neutral { stroke: #cfc6b4; stroke-width: 1.5; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--ink2); margin: 0 0 2px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend i.k-daily { background: var(--k-daily); } .legend i.k-theme { background: var(--k-theme); } .legend i.k-practice { background: var(--k-practice); }

/* ---------- header bar: home (left) · logo (middle) · settings (right) ---------- */
.mast-bar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 6px; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; padding: 0; cursor: pointer;
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px; box-shadow: 0 3px 0 var(--ink); color: var(--ink);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.masthead:not(.compact) #homeBtn { visibility: hidden; }   /* already home */
.masthead.compact .icon-btn { width: 38px; height: 38px; border-radius: 10px; box-shadow: 0 2px 0 var(--ink); }
.masthead.compact .icon-btn svg { width: 21px; height: 21px; }
.set-sec { border-top: 2px dashed var(--line); margin-top: 14px; padding-top: 4px; }
.mast-bar button.logo { font-size: 46px; }
.masthead.compact .mast-bar button.logo { font-size: 30px; }
@media (max-width: 380px) { .mast-bar button.logo { font-size: 38px; } .masthead.compact .mast-bar button.logo { font-size: 26px; } }
.icon-btn svg { stroke-width: 2; }
.me-line:empty { display: none; }

/* game-mode badge: daily / themed / practice, in the kind colors */
.mode-badge { display: inline-block; padding: 3px 12px; border-radius: 999px; color: #fff; font-weight: 800;
  font-size: 14px; letter-spacing: .02em; text-transform: none; margin-bottom: 2px; max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode-badge.k-daily { background: var(--k-daily); }
.mode-badge.k-theme { background: #c25e12; }
.mode-badge.k-practice { background: #0f7a71; }
.chart .bar.k-crowd { fill: #cfc7b8; }
.chart .bar.k-you { fill: var(--ink); }

/* ---------- size buttons: every puzzle comes as 4x4 and 5x5, side by side ---------- */
.size-btns { display: inline-flex; gap: 8px; flex: none; }
.btn.size { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
  min-width: 62px; padding: 5px 8px 6px; font-size: 15px; box-shadow: 0 2px 0 var(--ink); }
.btn.size span { font-size: 11px; font-weight: 700; letter-spacing: .02em; opacity: .92; white-space: nowrap; }
.today-btns .btn.size { min-width: 76px; padding: 8px 12px 9px; font-size: 19px; box-shadow: 0 4px 0 var(--ink); }
.today-btns .btn.size span { font-size: 12.5px; }
.lb-size { margin: 10px 0 2px; }
.lb-size:first-child { margin-top: 0; }
.qr { width: min(260px, 70vw); margin: 10px auto; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: #fff; }
.qr svg { display: block; width: 100%; height: auto; }
.me-line a { color: inherit; font-weight: 700; }

/* ---------- header: bigger logo, one-line tagline (short screens shouldn't scroll) ---------- */
.mast-bar button.logo { font-size: 54px; }
.masthead { margin: 6px 0 10px; }
.tag { margin: 6px auto 0; font-size: 14px; max-width: none; }
@media (max-width: 380px) { .mast-bar button.logo { font-size: 44px; } }
@media (max-height: 640px) { .tag { display: none; } }
.name-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.name-row input { flex: 1 1 150px; min-width: 0; width: auto; margin: 0; }
.name-row .btn { flex: none; }

/* login QR with a copy-link button beside it */
.qr-wrap { display: flex; justify-content: center; align-items: flex-end; gap: 10px; margin: 10px 0; }
.qr-wrap .qr { margin: 0; width: min(210px, 60vw); }
.qr-wrap .qr-copy { flex: none; width: 40px; height: 40px; }
.qr-wrap .qr-copy svg { width: 20px; height: 20px; }

/* stats by board size: 5x5 and 4x4 as two series; a size switch on the "today" panes */
.chart .dot.k-s5 { fill: var(--k-daily); } .chart .dot.k-s4 { fill: var(--k-theme); }
.chart .dot { stroke: var(--card, #fff); stroke-width: 1.5; }
.chart .line.k-s5 { stroke: var(--k-daily); } .chart .line.k-s4 { stroke: var(--k-theme); }
.chart .slabel { font-size: 10px; font-weight: 800; }
.chart .slabel.k-s5 { fill: var(--k-daily); } .chart .slabel.k-s4 { fill: var(--k-theme); }
.legend i.k-s5 { background: var(--k-daily); } .legend i.k-s4 { background: var(--k-theme); }
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; margin: 0 0 8px; }
.seg button { font: inherit; font-size: 12px; font-weight: 700; padding: 3px 12px; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.seg button.on { background: var(--ink); color: #fff; }

/* a puzzle finished since the home screen was last drawn: its button turns from orange to done with a bounce */
.btn.size.just-done { position: relative; animation: justDone 1.2s .35s cubic-bezier(.3, 1.5, .5, 1) backwards; }
.btn.size.just-done::after { content: ""; position: absolute; inset: -3px; border-radius: inherit; border: 3px solid var(--accent);
  opacity: 0; pointer-events: none; animation: justRing 1s .7s ease-out backwards; }
@keyframes justDone {
  0%, 20% { background: var(--accent); color: #fff; transform: scale(1); }
  45% { background: var(--accent); color: #fff; transform: scale(1.25) rotate(-4deg); }
  65% { transform: scale(.94) rotate(2deg); }
  100% { transform: scale(1); }
}
@keyframes justRing { 0% { opacity: .9; transform: scale(1); } 100% { opacity: 0; transform: scale(1.7); } }
@media (prefers-reduced-motion: reduce) { .btn.size.just-done, .btn.size.just-done::after { animation: none; } }

/* teaser for the themed puzzle that opens next */
.theme-row.soon .theme-emoji, .theme-row.soon .theme-txt { opacity: .6; }
.soon-tag { flex: none; font-size: 12px; font-weight: 800; color: var(--accent); white-space: nowrap; }

/* a practice button coming back as a new puzzle after its celebration */
.btn.size.pop-in { animation: pop .45s ease-out; }
@media (prefers-reduced-motion: reduce) { .btn.size.pop-in { animation: none; } }

/* back from an archive game: the Browse button dances */
.btn.dance { animation: dance 1.2s .35s cubic-bezier(.3, 1.5, .5, 1) backwards; }
@keyframes dance {
  0% { transform: scale(1); }
  25% { transform: scale(1.3) rotate(-8deg); background: var(--accent); color: #fff; }
  50% { transform: scale(1.15) rotate(7deg); background: var(--accent); color: #fff; }
  75% { transform: scale(1.05) rotate(-4deg); }
  100% { transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) { .btn.dance { animation: none; } }

/* a point beyond the top of a robustly scaled chart: pinned to the edge, hollow */
.chart .dot.over { fill: var(--card, #fff); stroke-width: 2; }
.chart .dot.over.k-s5 { fill: var(--card, #fff); stroke: var(--k-daily); } .chart .dot.over.k-s4 { fill: var(--card, #fff); stroke: var(--k-theme); }

/* finds over time: the longest word(s) */
.chart .dot.long { fill: var(--accent); stroke: var(--card, #fff); stroke-width: 1.5; }
.chart .dotlabel { font-size: 9px; font-weight: 800; fill: var(--ink); letter-spacing: .5px; }

/* ---------- Fravelous logo: 9 tiles must fit between the header buttons on a phone;
   room above them for the kangaroo that hops along the tiles ---------- */
.mast-bar button.logo { position: relative; gap: 3px; padding-top: .6em;
  font-size: clamp(19px, calc((100vw - 165px) / 7.9), 54px); }
.masthead.compact .mast-bar button.logo { padding-top: .5em; font-size: clamp(17px, calc((100vw - 170px) / 7.9), 26px); }
.logo .roo { position: absolute; left: 0; top: 0; font-style: normal; font-size: .62em; line-height: 1;
  transform-origin: 50% 100%; pointer-events: none; will-change: transform; }
.mast-bar .logo span, .masthead.compact .mast-bar .logo span {
  border-width: max(1.5px, .08em); border-radius: .3em; box-shadow: 0 max(1.5px, .1em) 0 var(--ink); }

/* results: the game's numbers in their own card (right column on wide screens) */
.stats-grid.res-metrics { grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); margin-bottom: 2px; }
/* one column (narrow): board, numbers, your words, missed words, then the rest */
@media (max-width: 899px) {
  #results .home-cols { display: flex; flex-direction: column; }
  #results .col-a, #results .col-b { display: contents; }
  #results .res-top { order: 1; } #resMetrics { order: 2; } #resWordsCard { order: 3; } #resMissedCard { order: 4; }
  #resSaveCard { order: 5; } #resSolveCard { order: 6; } #resBoardCard { order: 7; } #resCrowdCard { order: 8; }
}

/* solve-time distribution (results card and the home stats pane) */
.chart .kde.k-s5 { fill: var(--k-daily); opacity: .18; } .chart .kde.k-s4 { fill: var(--k-theme); opacity: .18; }
.chart.solve .line { fill: none; stroke-width: 2; }
.chart .rug { stroke-width: 1.5; opacity: .6; } .chart .rug.k-s5 { stroke: var(--k-daily); } .chart .rug.k-s4 { stroke: var(--k-theme); }
.chart .you { fill: var(--ink); } .chart .you-line { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 2 3; }
.chart rect.hit { fill: transparent; }
#resWordsCard h4 { margin-top: 14px; }

/* results: the hovered word, on the timeline and among the chips */
.chart .dot.hl { r: 7px; fill: var(--sel); stroke: var(--ink); stroke-width: 2; }
#resFound .chip.hl { background: var(--sel); color: #fff; }
