/* Hallmark · macrostructure: interactive word game · theme: Almanac · tone: quiet editorial · anchor hue: leaf green
 * nav: N6 Newspaper masthead · footer: Ft2 Inline single line · enrichment: none
 * audience: casual mobile players · use: solve a five-letter puzzle · typography: Cyrillic-ready pairing
 * Hallmark · pre-emit critique: P5 H4 E3 S5 R5 V4 · visual browser verification unavailable */
@import url('./tokens.css');
:root { --ad-height: 0px; }
html { scroll-padding-bottom: var(--ad-height); }
#modal { max-height: calc(100dvh - var(--ad-height) - 40px); margin-bottom: calc(var(--ad-height) + 20px); }
body { padding-bottom: var(--ad-height); }
* { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
html { background: var(--color-paper); color: var(--color-ink); color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }
body { font-family: var(--font-body); font-size: var(--text-base); line-height: 1.5; -webkit-tap-highlight-color: var(--color-transparent); }
button, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; white-space: normal; }
button:disabled { cursor: default; opacity: .5; }
:is(button, a, select, textarea, summary, [tabindex="0"]):focus-visible { outline: 2px solid var(--color-focus-outer); outline-offset: 2px; box-shadow: 0 0 0 2px var(--color-focus-inner); }
button { transition: transform var(--dur-micro) var(--ease-out); }
button:active:not(:disabled) { transform: scale(.96); }
button, h1, h2, h3 { font-style: normal; }
button, h1, h2, p { -webkit-text-size-adjust: 100%; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: clip; }
.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; display: block; }
.app-shell { --shell-inline: 24px; --viewport-chrome: 688px; max-width: 680px; margin: 0 auto; min-height: 100svh; padding: max(8px, env(safe-area-inset-top)) max(var(--shell-inline), env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(var(--shell-inline), env(safe-area-inset-left)); display: flex; flex-direction: column; }
.masthead { flex: 0 0 auto; }
.utility-bar { display: flex; align-items: center; justify-content: space-between; min-height: 48px; border-bottom: 1px solid var(--color-line); gap: 8px; }
.edition { font-size: var(--text-xs); letter-spacing: .035em; color: var(--color-muted); display: flex; align-items: center; gap: 9px; }
.mini-mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 2px; transform: rotate(-8deg); }
.mini-mark i { width: 7px; height: 7px; border: 1px solid var(--color-accent); border-radius: 1px; }
.mini-mark i:first-child, .mini-mark i:last-child { background: var(--color-accent); }
.toolbar { display: flex; align-items: center; gap: 2px; }
.toolbar-divider { height: 20px; width: 1px; background: var(--color-line); margin: 0 8px; }
.language-picker { display: flex; align-items: center; font-size: var(--text-xs); color: var(--color-muted); }
.language-picker button { border: 0; background: none; padding: 0; min-width: 44px; height: 44px; color: var(--color-muted); font-weight: 500; }
.language-picker button[aria-pressed="true"] { color: var(--color-ink); font-weight: 700; }
.language-picker button:hover { color: var(--color-accent); }
.icon-button { border: 0; padding: 0; background: var(--color-transparent); width: 44px; height: 44px; display: grid; place-items: center; border-radius: var(--radius-md); flex-shrink: 0; }
.icon-button:hover { background: var(--color-key); }
.title-block { text-align: center; padding: var(--space-sm) 0; }
h1 { font-family: var(--font-display); font-size: 48px; font-weight: 700; letter-spacing: -.045em; line-height: 1; margin: 0; overflow-wrap: anywhere; min-width: 0; }
.title-dot { color: var(--color-accent); }
.title-block p { font-size: var(--text-sm); margin: var(--space-xs) 0 0; color: var(--color-muted); line-height: 1.5; }
.mode-tabs { display: flex; gap: 30px; justify-content: center; border-bottom: 1px solid var(--color-line); }
.mode-tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 var(--space-xs) var(--space-sm); border: 0; border-bottom: 2px solid var(--color-transparent); background: none; font-size: var(--text-sm); color: var(--color-muted); }
.mode-tabs button.active { border-color: var(--color-accent); color: var(--color-accent); font-weight: 600; }
.mode-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.infinity { font-size: var(--text-lg); line-height: 1; }
.game { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 440px; margin: 0 auto; }
.game-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-xs) 12px; padding-top: 12px; font-size: var(--text-xs); line-height: 1.5; color: var(--color-muted); font-variant-numeric: tabular-nums; }
#attempt-label { white-space: nowrap; }
.board-area { display: grid; place-items: center; container-type: inline-size; flex: 1 0 auto; padding: 12px 0 var(--space-xs); }
/* Tile size depends on the viewport, never on transient messages or keyboard content.
   Short screens scroll naturally rather than reduce the 40px readability floor. */
.board { --tile-gap: 6px; --tile: clamp(40px, min(calc((100svh - var(--viewport-chrome) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 6), calc((100cqw - var(--tile-gap) * 4) / 5)), 58px); display: flex; flex-direction: column; gap: var(--tile-gap); user-select: none; border-radius: var(--radius-sm); }
.guess-row { display: flex; gap: var(--tile-gap); }
.tile { width: var(--tile); height: var(--tile); display: flex; align-items: center; justify-content: center; position: relative; border: 1.5px solid var(--color-line); border-radius: var(--radius-sm); font-size: clamp(24px, calc(var(--tile) * .5), 30px); font-weight: 600; line-height: 1; }
.tile.filled { border-color: var(--color-line-strong); }
.tile-letter { transform: translateY(-2px); }
.tile.active-cell { border-color: var(--color-accent); box-shadow: inset 0 0 0 1px var(--color-accent); }
.guess-row.current .tile { background: var(--color-surface); }
.tile.correct, .example-tile.correct, .swatch.correct, .result-square.correct { background: var(--color-correct); color: var(--color-correct-ink); border-color: var(--color-correct); }
.tile.present, .example-tile.present, .swatch.present, .result-square.present { background: var(--color-present); color: var(--color-present-ink); border-color: var(--color-present); }
.tile.absent, .example-tile.absent, .swatch.absent, .result-square.absent { background: var(--color-absent); color: var(--color-absent-ink); border-color: var(--color-absent); }
.tile-mark { position: absolute; bottom: 2px; right: 3px; font-size: 12px; line-height: 1; font-weight: 700; }
.tile.reveal { animation: reveal var(--dur-short) var(--ease-out) both; animation-delay: calc(var(--col) * 65ms); }
@keyframes reveal { from { opacity: .2; transform: scaleY(.5); } to { opacity: 1; transform: scaleY(1); } }
.message-area { min-height: 56px; flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: var(--space-xs) 0; }
#game-message { margin: 0; font-size: var(--text-sm); line-height: 1.4; color: var(--color-muted); }
#game-message.error { color: var(--color-error); }
.text-button { border: 0; background: none; color: var(--color-accent); padding: 8px 0; font-size: var(--text-sm); text-decoration: underline; text-underline-offset: 4px; min-height: 44px; }
.text-button:hover { color: var(--color-ink); }
[hidden] { display: none !important; }
.legend { display: flex; justify-content: center; gap: 12px; align-items: center; color: var(--color-muted); font-size: var(--text-xs); line-height: 1.5; margin: 0 0 12px; flex-wrap: wrap; }
.legend > span { display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.keyboard { display: flex; flex-direction: column; flex: 0 0 auto; gap: 6px; padding: 0 0 var(--space-xs); user-select: none; }
.key-row { display: flex; justify-content: center; gap: 5px; }
.key { min-width: 0; flex: 1 1 0; height: 52px; border: 0; background: var(--color-key); border-radius: var(--radius-sm); font-size: var(--text-base); font-weight: 600; padding: 0; display: flex; align-items: center; justify-content: center; position: relative; }
.key:hover { background: var(--color-key-hover); }
.key[data-state="correct"] { background: var(--color-correct); color: var(--color-correct-ink); }
.key[data-state="present"] { background: var(--color-present); color: var(--color-present-ink); }
.key[data-state="absent"] { background: var(--color-absent); color: var(--color-absent-ink); }
.key[data-state]::after { position: absolute; bottom: 2px; right: 3px; font-size: 12px; line-height: 1; font-weight: 700; }
.key[data-state="correct"]::after { content: '✓'; }
.key[data-state="present"]::after { content: '•'; }
.key[data-state="absent"]::after { content: '−'; }
.key.special { flex: 1.5 1 0; }
.key.enter { background: var(--color-accent); color: var(--color-accent-ink); }
.key.enter:hover { opacity: .85; }
.key.enter:disabled { opacity: .5; }
.key-row.middle { padding-inline: 16px; }
.keyboard[data-lang="ru"] .key-row.middle { padding-inline: 10px; }
.keyboard[data-lang="ru"] .key { font-size: 15px; }
.keyboard[data-lang="ru"] .key-row { gap: 2px; }
.footer { border-top: 1px solid var(--color-line); display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0; margin-top: var(--space-sm); color: var(--color-muted); font-size: var(--text-xs); }
.footer .text-button { font-size: var(--text-xs); }
dialog { width: min(460px, calc(100% - 28px - env(safe-area-inset-left) - env(safe-area-inset-right))); max-height: calc(100svh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); margin: auto; border: 1px solid var(--color-line); padding: 0; border-radius: var(--radius-lg); background: var(--color-paper); color: var(--color-ink); overflow-y: auto; overscroll-behavior: contain; }
dialog::backdrop { background: var(--color-backdrop); }
dialog[open] { animation: dialog-in var(--dur-short) var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.dialog-inner { padding: var(--space-xl) 28px 28px; position: relative; }
.close-button { position: absolute; top: 12px; right: 12px; }
.dialog-heading { font-family: var(--font-display); font-size: 38px; line-height: 1.1; letter-spacing: -.025em; margin: 6px 32px var(--space-md) 0; overflow-wrap: anywhere; min-width: 0; }
.dialog-intro { color: var(--color-muted); line-height: 1.6; margin: 0 0 24px; font-size: 15px; }
.example { padding: 15px 0; border-top: 1px solid var(--color-line); }
.example-word { display: flex; gap: 5px; }
.example-tile { display: grid; place-items: center; position: relative; width: 40px; height: 40px; border: 1px solid var(--color-line); border-radius: var(--radius-sm); font-weight: 600; }
.example p { font-size: var(--text-sm); line-height: 1.5; margin: 10px 0 0; }
.dialog-note { font-size: var(--text-sm); line-height: 1.6; color: var(--color-muted); padding-top: 12px; }
.install-settings { border-top: 1px solid var(--color-line); margin-top: var(--space-lg); }
.install-settings [hidden] { display: none; }
.settings-links { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--text-sm); }
.settings-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--color-accent); text-underline-offset: 4px; }
.primary-button, .secondary-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; border-radius: var(--radius-md); font-size: 14px; font-weight: 600; line-height: 1.4; text-align: center; padding: 12px var(--space-md); border: 1px solid var(--color-accent); }
.primary-button { color: var(--color-accent-ink); background: var(--color-accent); }
.primary-button:hover { opacity: .9; }
.secondary-button { background: var(--color-transparent); color: var(--color-accent); margin-top: 10px; }
.secondary-button:hover { background: var(--color-accent-soft); }
.primary-button .icon, .secondary-button .icon { width: 18px; height: 18px; }
.setting { display: flex; align-items: center; gap: 16px; justify-content: space-between; padding: 20px 0; border-top: 1px solid var(--color-line); }
.setting > div { min-width: 0; }
.setting-theme { flex-wrap: wrap; }
.setting-theme select { min-height: 44px; max-width: 100%; border: 1px solid var(--color-line-strong); border-radius: var(--radius-sm); background: var(--color-surface); padding: var(--space-sm); font-size: 14px; }
.setting strong { display: block; font-size: 15px; font-weight: 500; }
.setting p { color: var(--color-muted); font-size: var(--text-sm); line-height: 1.5; margin: 6px 0 0; }
.switch { background: var(--color-line-strong); border: 0; border-radius: 25px; width: 44px; height: 26px; padding: 3px; position: relative; flex-shrink: 0; }
.switch::before { content: ''; width: 20px; height: 20px; border-radius: 50%; position: absolute; top: 3px; left: 3px; background: var(--color-surface); transition: transform var(--dur-micro) var(--ease-out); }
.switch[aria-checked="true"] { background: var(--color-accent); }
.switch[aria-checked="true"]::before { transform: translateX(18px); }
.switch::after { content: ''; position: absolute; inset: -9px -2px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 24px 0; }
.stat-value { font-size: 30px; font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-label { color: var(--color-muted); font-size: var(--text-xs); line-height: 1.4; margin-top: 5px; }
.section-heading { font-size: var(--text-sm); font-weight: 600; padding-top: 18px; border-top: 1px solid var(--color-line); margin: 20px 0 12px; }
.distribution { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.dist-label { width: 12px; color: var(--color-muted); }
.dist-track { flex: 1; min-width: 0; }
.dist-bar { height: 22px; background: var(--color-absent); border-radius: 2px; }
.dist-count { min-width: 3ch; text-align: right; color: var(--color-ink); }
.dist-bar.latest { background: var(--color-correct); color: var(--color-correct-ink); }
.empty-stats { font-size: 14px; line-height: 1.6; color: var(--color-muted); margin: 24px 0; }
.result-header { margin: var(--space-sm) 0 var(--space-md); }
.result-header .dialog-intro { margin-bottom: var(--space-md); }
.result-actions { display: flex; flex-direction: column; gap: var(--space-sm); }
.result-actions .secondary-button { margin-top: 0; }
.next-context { margin: 0; font-size: var(--text-xs); line-height: 1.5; color: var(--color-muted); }
.result-details { margin-top: var(--space-lg); border-top: 1px solid var(--color-line); }
.result-details summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--color-accent); }
.result-details .stats-grid { margin-top: var(--space-sm); }
.result-kicker { color: var(--color-accent); font-size: var(--text-sm); margin: 0 0 8px; }
.result-word { display: flex; gap: 5px; margin: 18px 0; }
.result-square { display: grid; place-items: center; width: 42px; height: 44px; border-radius: var(--radius-sm); font-size: 23px; font-weight: 600; }
.share-fallback { width: 100%; min-height: 150px; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-sm); padding: 12px; resize: vertical; font-size: 14px; line-height: 1.5; margin-top: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: clip; clip-path: inset(50%); white-space: nowrap; border: 0; }
/* Width rules own horizontal spacing; compact-height rules own vertical rhythm. */
@media (max-width: 699px) {
  .app-shell { --shell-inline: 12px; --viewport-chrome: 640px; }
  .game { max-width: 490px; }
  .toolbar-divider { margin-inline: 3px; }
  .edition > span:last-child { display: none; }
  .keyboard { margin-left: calc(max(4px, env(safe-area-inset-left)) - max(var(--shell-inline), env(safe-area-inset-left))); margin-right: calc(max(4px, env(safe-area-inset-right)) - max(var(--shell-inline), env(safe-area-inset-right))); }
  .footer { display: none; }
}
@media (max-width: 350px) {
  .toolbar { gap: 0; }
  .legend { gap: var(--space-sm); }
  .dialog-inner { padding: 28px var(--space-md) var(--space-lg); }
  .dialog-heading { font-size: 34px; }
  .stats-grid { gap: var(--space-xs); }
  .stat-value { font-size: 28px; }
  .setting-theme select { width: 100%; }
}
@media (max-height: 920px) {
  .app-shell { --viewport-chrome: 428px; }
  .utility-bar { min-height: 44px; }
  .title-block { padding: var(--space-xs) 0; }
  h1 { font-size: 32px; }
  .title-block p { display: none; }
  .game-meta { padding-top: var(--space-sm); }
  .board-area { padding-top: var(--space-sm); }
  .board { --tile-gap: 5px; }
  .legend, .footer { display: none; }
  .key { height: 48px; }
}
/* A landscape phone has useful width: keep the board beside its controls. */
@media (min-width: 640px) and (max-height: 540px) and (orientation: landscape) {
  .app-shell { --shell-inline: 12px; --viewport-chrome: 178px; max-width: 1100px; }
  .masthead { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-md); }
  .utility-bar { grid-column: 2; grid-row: 1; border: 0; }
  .edition { display: none; }
  .title-block { grid-column: 1; grid-row: 1; text-align: left; align-self: center; padding: 0; }
  .mode-tabs { grid-column: 1 / -1; grid-row: 2; gap: var(--space-md); }
  .game { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.2fr); grid-template-rows: auto auto auto auto; column-gap: var(--space-md); max-width: none; flex: 0 0 auto; }
  .game-meta { grid-column: 1 / -1; grid-row: 1; }
  .board-area { grid-column: 1; grid-row: 2 / 5; padding: var(--space-sm) 0; }
  .board { --tile: clamp(40px, min(calc((100svh - var(--viewport-chrome) - env(safe-area-inset-top) - env(safe-area-inset-bottom)) / 6), calc((100cqw - var(--tile-gap) * 4) / 5)), 48px); }
  .keyboard { grid-column: 2; grid-row: 2; align-self: end; padding: var(--space-sm) 0 0; margin: 0; }
  .message-area { grid-column: 2; grid-row: 3; }
  .legend { grid-column: 2; grid-row: 4; display: flex; margin: 0 0 var(--space-sm); }
}
@media (min-width: 700px) and (max-height: 540px) and (orientation: landscape) {
  .app-shell { --viewport-chrome: 134px; }
  .masthead { grid-template-columns: auto minmax(0, 1fr) auto; border-bottom: 1px solid var(--color-line); }
  .utility-bar { grid-column: 3; }
  .mode-tabs { grid-column: 2; grid-row: 1; border: 0; align-self: center; }
}
@media (prefers-reduced-motion: reduce) { button { transition: none; } button:active:not(:disabled) { transform: none; } .tile.reveal, dialog[open] { animation: none; } .switch::before { transition: none; } }
