/* Daily Puzzle: "paper and ink, a quiet morning" (design pack section 8). Words are the graphics: a big dark letter on a
   white tile with a thin line, three feedback colours, Rubik for both languages. Direction is set ONCE on <html dir> per
   language; no component sets direction; only inset-inline / margin-inline below. Nothing flashes, nothing moves unless the
   player did something; prefers-reduced-motion and the setting both turn the flips off.
   Trade-dress distance (docs/names-and-trade-dress.md, research 20.10.2026): our tile shape (two 16 px corners, two 4 px
   corners), a shape mark on every coloured tile (● right spot, ▬ in the word, ○ not in the word), keys never filled with
   the feedback colour (a thin bar under the letter on the default key), no sunflower yellow anywhere. Colours stay. */
:root {
  --paper: #FAF7F0; --ink: #1F2A3A; --tile: #FFFFFF; --line: #CFC8BA; --key: #E9E4D9; --dim: #6E7784; --panel: #FFFFFF;
  --hit: #3B9C6B; --near: #D9A23A; --miss: #8A8F98; --accent: #2D6FA3; --streak: #D96A3B; --on-hit: #FFFFFF; --on-near: #1F2A3A; --on-miss: #FFFFFF;
  --focus: #2D6FA3; --scrim: rgba(31, 42, 58, .55);
  --tile-r: 16px; --r: 10px;
  color-scheme: light;
}
/* night: the same board on blue-grey night, not black; TV is always night */
:root[data-theme="dark"], html.tv {
  --paper: #141A24; --ink: #F3EEE4; --tile: #232D3B; --line: #3C4858; --key: #2A3442; --dim: #A2ACBA; --panel: #1D2633;
  --accent: #5FA3DC; --focus: #5FA3DC; --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141A24; --ink: #F3EEE4; --tile: #232D3B; --line: #3C4858; --key: #2A3442; --dim: #A2ACBA; --panel: #1D2633;
    --accent: #5FA3DC; --focus: #5FA3DC; --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { background: var(--paper); color: var(--ink); font-family: Rubik, Heebo, "Segoe UI", Arial, sans-serif; font-weight: 500; font-size: 16px; line-height: 1.4; -webkit-text-size-adjust: 100%; }
body { background: var(--paper); overflow-x: hidden; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
h1, h2, h3, p { margin: 0; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
:focus { outline: none; }
[data-f]:focus-visible, html.tv [data-f]:focus { outline: 4px solid var(--focus); outline-offset: 3px; border-radius: var(--r); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#app { min-height: 100%; display: flex; flex-direction: column; padding: max(8px, env(safe-area-inset-top, 0px)) max(14px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)); max-width: 520px; margin: 0 auto; }
.screen { display: flex; flex-direction: column; flex: 1; gap: 12px; }

/* top bar: ≡ · title · ? / ⚙ */
.bar { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.bar h1 { flex: 1; text-align: center; font-size: 20px; font-weight: 700; }
.ibtn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--r); font-size: 22px; color: var(--ink); }
.ibtn:active { background: var(--key); }
.status { text-align: center; color: var(--dim); font-size: 15px; min-height: 20px; }

/* home: date + streak, three cards, archive, more games */
.dateline { display: flex; justify-content: center; align-items: baseline; gap: 10px; font-size: 17px; }
.dateline .streak { color: var(--streak); font-weight: 700; }
.dateline .perfect { color: var(--hit); font-weight: 700; }
.cards { display: flex; flex-direction: column; gap: 10px; }
.card { display: flex; align-items: center; gap: 14px; text-align: start; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 14px 16px; min-height: 76px; width: 100%; }
.card .mark { width: 40px; height: 40px; flex: none; border-radius: var(--tile-r) 4px var(--tile-r) 4px; display: grid; place-items: center; font-weight: 800; font-size: 20px; color: var(--on-hit); background: var(--hit); }
.card .mark.q { background: #E97E62; } .card .mark.s { background: var(--accent); }
.card .mark.soon { background: var(--key); color: var(--dim); }
.card b { display: block; font-size: 19px; font-weight: 700; }
.card small { display: block; color: var(--dim); font-size: 14px; margin-top: 2px; }
.card .state { margin-inline-start: auto; color: var(--dim); font-weight: 700; white-space: nowrap; }
.card.next { border-color: var(--accent); animation: breathe 2s ease-in-out infinite; }
.card.soon { opacity: .75; cursor: default; }
@keyframes breathe { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.08); } } /* <= 1 Hz, 8 % (pack section 9) */
html.rm .card.next { animation: none; }
.row2 { display: flex; gap: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 10px 18px; border-radius: 12px; background: var(--key); color: var(--ink); font-weight: 700; font-size: 16px; }
.btn.primary { background: var(--ink); color: var(--paper); }
html.tv .btn.primary, :root[data-theme="dark"] .btn.primary { background: var(--accent); color: #fff; }
.btn.wide { width: 100%; }
.more { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; text-align: start; width: 100%; }
.more img { width: 48px; height: 48px; border-radius: 10px; flex: none; }
.more .t { flex: 1; min-width: 0; }
.more .t small { display: block; color: var(--dim); font-size: 13px; }
.more .t b { display: block; font-size: 15px; }
.more .go { color: var(--accent); font-weight: 700; white-space: nowrap; }
.eyebrow { color: var(--dim); font-size: 13px; font-weight: 700; margin-top: 6px; }

/* the board: 6 x 5 tiles, one letter per tile, our tile shape (two 16 px corners, two 4 px corners), 2 px line, no shadow */
.hint { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; background: var(--ink); color: var(--paper); border-radius: var(--r); padding: 8px 12px; font-size: 14px; line-height: 1.35; }
.hint span { display: block; }
.board { display: grid; grid-template-columns: 1fr; gap: 6px; align-self: center; width: min(100%, 330px); }
.row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.tile { aspect-ratio: 1; display: grid; place-items: center; background: var(--tile); border: 2px solid var(--line); border-radius: var(--tile-r) 4px var(--tile-r) 4px; font-weight: 800; font-size: clamp(22px, 7.5vw, 32px); line-height: 1; position: relative; transition: transform .3s; transform-style: preserve-3d; }
.tile.filled { border-color: var(--dim); }
.tile.hit { background: var(--hit); border-color: var(--hit); color: var(--on-hit); }
.tile.near { background: var(--near); border-color: var(--near); color: var(--on-near); }
.tile.miss { background: var(--miss); border-color: var(--miss); color: var(--on-miss); }
.tile.flip { animation: flip .3s ease-in-out both; animation-delay: var(--d, 0s); }
@keyframes flip { 0% { transform: rotateX(0); } 50% { transform: rotateX(90deg); } 100% { transform: rotateX(0); } }
.tile.hop { animation: hop .35s ease-out both; animation-delay: var(--d, 0s); }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
html.rm .tile.flip, html.rm .tile.hop { animation: none; }
.row.shake { animation: shake .25s ease-in-out; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
html.rm .row.shake { animation: none; }
/* a shape mark on every coloured tile (trade-dress distance, and it helps colour-blind players): ● right spot, ▬ in the word,
   ○ not in the word. The "marks on tiles" setting makes them large. */
.tile.hit::after, .tile.near::after, .tile.miss::after { position: absolute; top: 3px; inset-inline-end: 5px; font-size: 9px; line-height: 1; opacity: .9; font-weight: 400; }
.tile.hit::after { content: "●"; } .tile.near::after { content: "▬"; } .tile.miss::after { content: "○"; }
html.marks .tile.hit::after, html.marks .tile.near::after, html.marks .tile.miss::after { font-size: 14px; top: 2px; }

/* keyboard: rows of any length; the widest row is 10 keys, so a key is (360 - 8 - 27) / 10 = 32.5 px at 360 */
.kbd { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; margin-top: auto; margin-left: calc(-1 * max(14px, env(safe-area-inset-left, 0px))); margin-right: calc(-1 * max(14px, env(safe-area-inset-right, 0px))); } /* the keyboard spans the whole width, so a key is (360 - 8 - 27) / 10 = 32.5 px */
.kbd .krow { display: flex; justify-content: center; gap: 3px; }
.key { flex: 0 0 calc((100% - 27px) / 10); height: 46px; display: grid; place-items: center; background: var(--key); border-radius: 6px; font-weight: 700; font-size: 20px; line-height: 1; color: var(--ink); }
.key.act { font-size: 22px; }
.key:active { filter: brightness(.9); }
/* keys keep the default fill; the feedback is a thin bar under the letter (never a fully coloured key) */
.key.hit { box-shadow: inset 0 -5px 0 var(--hit); } .key.near { box-shadow: inset 0 -5px 0 var(--near); } .key.miss { box-shadow: inset 0 -5px 0 var(--miss); color: var(--dim); }
html.marks .key.hit::after { content: " ●"; font-size: 9px; } html.marks .key.near::after { content: " ▬"; font-size: 9px; } html.marks .key.miss::after { content: " ○"; font-size: 9px; }

/* overlays: result, pause, rules, settings, confirm */
.ov { position: fixed; inset: 0; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); background: var(--scrim); overflow-y: auto; z-index: 20; }
.sheet { width: min(100%, 420px); background: var(--panel); color: var(--ink); border-radius: 18px; padding: 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.sheet h2 { font-size: 22px; font-weight: 700; text-align: center; }
.sheet p { color: var(--dim); text-align: center; }
.sheet .word { font-size: 26px; font-weight: 800; letter-spacing: 0; color: var(--ink); }
.marksrow { display: flex; flex-direction: column; gap: 4px; align-items: center; margin: 4px 0; }
.marksrow div { display: flex; gap: 4px; }
.marksrow i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--miss); display: block; box-sizing: border-box; }
.marksrow i.hit { background: var(--hit); border-color: var(--hit); } .marksrow i.near { background: var(--near); border-color: var(--near); }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu .btn { justify-content: center; }
.setrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 6px 12px; border-radius: 12px; background: var(--key); width: 100%; text-align: start; font-size: 15px; }
.setrow .val { color: var(--accent); font-weight: 700; white-space: nowrap; }
.setrow .val::before { content: "‹ "; } .setrow .val::after { content: " ›"; }
.setrow.plain .val::before, .setrow.plain .val::after { content: ""; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 14px; }
.links button, .links a { color: var(--accent); text-decoration: underline; font-weight: 700; }
.small { font-size: 13px; color: var(--dim); text-align: center; }
#toast { position: fixed; left: 50%; top: 18%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-weight: 700; z-index: 30; max-width: 90vw; text-align: center; pointer-events: none; }
html.tv #toast { font-size: 22px; padding: 14px 22px; }
.qr { width: 180px; height: 180px; background: #fff; padding: 8px; border-radius: 8px; margin: 0 auto; }
.qr svg { width: 100%; height: 100%; display: block; }
.sheet h3 { font-size: 17px; font-weight: 700; margin-top: 4px; }
.sheet .lic { font-size: 13px; text-align: start; line-height: 1.45; overflow-wrap: anywhere; }
/* statistics: streak / best / perfect days, then per puzzle: played, solved %, the distribution as thin lines (not blocks) */
.stats { display: flex; flex-direction: column; gap: 10px; }
.statrow { display: flex; justify-content: center; gap: 8px; }
.statrow > div { flex: 1; min-width: 0; background: var(--key); border-radius: 12px; padding: 8px 6px; text-align: center; }
.statrow b { display: block; font-size: 24px; font-weight: 800; line-height: 1.1; }
.statrow small { display: block; color: var(--dim); font-size: 12px; margin-top: 2px; }
.dist { display: flex; flex-direction: column; gap: 4px; }
.dbar { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.dbar .k { width: 16px; text-align: center; font-weight: 700; color: var(--dim); }
.dbar .bar { flex: 1; position: relative; height: 18px; display: flex; align-items: center; }
.dbar .bar i { display: block; height: 6px; min-width: 6px; border-radius: 3px; background: var(--accent); }
.dbar .bar em { font-style: normal; color: var(--dim); margin-inline-start: 8px; font-size: 13px; }
/* TV result: the card in the left column, the QR code on the right (no share sheet on a TV) */
.resqr { display: none; }

/* ===== TV (form=tv): a 960x540 frame scaled to the screen, content inside the 5 % overscan margins, help bar at the bottom ===== */
html.tv, html.tv body { overflow: hidden; }
html.tv { font-size: 18px; } /* nothing under 17 px in the 540 frame */
html.tv .eyebrow, html.tv .more small, html.tv .small, html.tv .links { font-size: 17px; } html.tv .more b { font-size: 19px; } html.tv .card .state { font-size: 18px; }
html.tv #app { max-width: none; padding: 0; width: 960px; height: 540px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(var(--tvscale, 1)); transform-origin: center; }
html.tv .frame { position: absolute; inset: 0; padding: 27px 48px 60px; display: flex; flex-direction: column; } /* 5 % margins; 60 leaves room for the help bar */
html.tv #help { position: absolute; left: 48px; right: 48px; bottom: 27px; height: 28px; display: flex; justify-content: center; gap: 22px; color: var(--dim); font-size: 17px; white-space: nowrap; }
html.tv #help b { color: var(--ink); font-weight: 700; margin-inline-end: 6px; }
html.tv .screen { flex-direction: row; gap: 28px; }
html.tv .bar { position: absolute; top: 27px; left: 48px; right: 48px; height: 44px; }
html.tv .bar h1 { font-size: 24px; text-align: start; }
html.tv .ibtn { font-size: 26px; }
html.tv .status { font-size: 19px; }
/* TV home: the list of puzzles (focus 1-5), a panel (6), the gear in the corner (7) */
html.tv .homecol { width: 420px; display: flex; flex-direction: column; gap: 10px; margin-top: 54px; }
html.tv .cards { gap: 8px; }
html.tv .card { padding: 10px 14px; min-height: 60px; border-radius: 12px; }
html.tv .card b { font-size: 20px; } html.tv .card small { font-size: 17px; }
html.tv .row2 .btn { font-size: 18px; min-height: 48px; }
html.tv .panel { flex: 1; margin-top: 54px; background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
html.tv .panel h2 { font-size: 24px; } html.tv .panel p { font-size: 18px; color: var(--dim); }
html.tv .panel .more { margin-top: auto; }
/* the other game's English tagline is long: two lines for the name + tagline, one for the by-line, so the card stays inside the panel */
html.tv .more .t b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
html.tv .more .t small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* TV Five: two columns (board 290 + keyboard), keys 42x46, 32 px letters on 56 px tiles */
html.tv .playcol { display: flex; flex-direction: column; margin-top: 46px; gap: 8px; width: 280px; }
html.tv .board { width: 270px; gap: 5px; } html.tv .tile { font-size: 30px; } /* 50 px tiles: six rows + the status line fit the 453 px inside the margins and the help bar */
html.tv .hint { font-size: 17px; }
html.tv .kbdcol { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; margin-top: 50px; }
html.tv .kbd { gap: 8px; padding: 0; margin: 0; }
html.tv .key { flex: 0 0 42px; height: 46px; font-size: 24px; border-radius: 8px; }
html.tv .key.act { flex-basis: 150px; font-size: 20px; }
html.tv .krow.actions { margin-top: 6px; gap: 10px; }
html.tv .sheet { width: 560px; font-size: 19px; } html.tv .sheet h2 { font-size: 28px; } html.tv .sheet p { font-size: 19px; }
html.tv .btn { font-size: 19px; min-height: 52px; } html.tv .setrow { font-size: 19px; min-height: 52px; }
html.tv .sheet:has(.resqr) { display: grid; grid-template-columns: 1fr 170px; gap: 16px; width: 640px; align-items: center; }
html.tv .res { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
html.tv .resqr { display: flex; flex-direction: column; gap: 8px; align-items: center; }
html.tv .resqr .qr { width: 150px; height: 150px; padding: 6px; }
html.tv .marksrow i { width: 14px; height: 14px; } html.tv .marksrow { gap: 3px; }
html.tv .stats { flex-direction: row; gap: 18px; } html.tv .stats > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
html.tv .statrow small { font-size: 17px; } html.tv .dbar { font-size: 17px; } html.tv .dbar .bar em { font-size: 17px; }
html.tv .sheet .lic { font-size: 17px; }
html.tv .sheet:has(.stats) { width: 760px; }
