:root {
  color-scheme: dark;
  --bg: #141311;
  --panel: #201f1b;
  --line: #49453c;
  --text: #f7f2e6;
  --muted: #b9b1a2;
  --green: #b9d860;
  --green-dark: #426e35;
  --yellow: #f3c943;
  --red: #f1694e;
  font-family: "Arial", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 280px; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 4% 12%, rgba(173, 71, 46, .16), transparent 29rem),
    radial-gradient(circle at 96% 31%, rgba(91, 110, 51, .16), transparent 30rem),
    repeating-linear-gradient(0deg, transparent 0 27px, rgba(255,255,255,.012) 28px 29px),
    var(--bg);
}
button, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.site-shell { max-width: 1340px; min-height: 100vh; padding: 0 clamp(16px, 3vw, 44px); margin: auto; display: flex; flex-direction: column; }
.site-header { min-height: 87px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--text); }
.brand { display: inline-flex; align-items: center; gap: 15px; text-decoration: none; }
.brand-mark { width: 51px; height: 51px; display: grid; place-items: center; border: 2px solid #17150e; color: #19160b; background: var(--yellow); box-shadow: 4px 4px 0 var(--red); font-size: 29px; font-weight: 900; letter-spacing: -7px; padding-right: 7px; transform: rotate(-7deg); }
.brand-mark span { color: var(--red); }
.brand-copy { display: grid; gap: 4px; }
.brand-copy strong { font-size: 20px; line-height: 1; font-weight: 900; letter-spacing: -.045em; white-space: nowrap; }
.brand-dot { color: var(--red); }
.brand-copy small { color: var(--yellow); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.header-actions { display: flex; gap: 8px; }
.text-button, .site-footer button { border: 1px solid var(--line); border-radius: 2px; background: #24221d; color: var(--text); font-size: 12px; font-weight: 800; padding: 11px 14px; transition: background .16s, border-color .16s, transform .16s; }
.text-button:hover, .site-footer button:hover { border-color: var(--yellow); background: #393329; transform: translateY(-2px); }

.main-layout { display: grid; grid-template-columns: minmax(155px, 215px) minmax(350px, 510px) minmax(155px, 215px); justify-content: center; align-items: start; gap: clamp(23px, 4vw, 57px); flex: 1; padding: clamp(32px, 5vh, 58px) 0 72px; }
.visual-rail { display: flex; flex-direction: column; min-width: 0; }
.visual-rail figure { margin: 0; }
.visual-rail img { display: block; width: 100%; height: auto; }
.visual-rail figcaption { font-family: "Courier New", monospace; font-size: clamp(9px, .9vw, 12px); font-weight: 900; letter-spacing: .09em; line-height: 1.15; white-space: nowrap; }
.visual-rail-left { padding-top: 33px; gap: clamp(45px, 9vh, 100px); }
.portrait-sticker { width: min(100%, 214px); padding: 8px 8px 7px; background: #dadfd5; color: #1f2522; box-shadow: 10px 12px 0 #332f27, 12px 14px 0 var(--line); transform: rotate(-6deg); }
.portrait-sticker img { aspect-ratio: 1; object-fit: cover; filter: contrast(1.08) saturate(.85); }
.portrait-sticker figcaption { padding: 8px 3px 2px; font-size: 16px; letter-spacing: -.02em; }
.ebalo-sticker { align-self: flex-end; width: min(80%, 172px); padding: 8px 8px 9px; color: #221d10; background: #fcf5e1; box-shadow: 7px 8px 0 #382f21; text-align: center; transform: rotate(9deg); }
.ebalo-sticker img { aspect-ratio: 1; object-fit: contain; }
.ebalo-sticker figcaption { padding-top: 6px; }
.visual-rail-right { padding-top: 18px; gap: clamp(54px, 11vh, 112px); }
.hero-sticker { width: min(100%, 215px); padding: 5px; background: #182f24; border: 1px solid #60945d; box-shadow: 9px 9px 0 #283727; transform: rotate(5deg); }
.hero-sticker img { aspect-ratio: 16 / 9; object-fit: cover; }
.hero-sticker figcaption { margin: 8px 4px 4px; color: var(--green); }
.buldiga-sticker { align-self: center; position: relative; width: min(100%, 204px); text-align: center; transform: rotate(-8deg); }
.buldiga-sticker::before { content: ""; position: absolute; z-index: -1; width: 72%; aspect-ratio: 1; top: 15%; left: 15%; border: 2px dashed #7893ad; border-radius: 50%; }
.buldiga-sticker img { clip-path: circle(37% at 50% 50%); filter: drop-shadow(5px 6px 0 #413f80); }
.buldiga-sticker figcaption { margin-top: -10px; color: #a9c3eb; text-shadow: 2px 2px #262e4e; }

.game-card { width: 100%; min-width: 0; border: 2px solid #7b7464; border-radius: 3px; background: var(--panel); box-shadow: 11px 11px 0 #0b0a09, 12px 12px 0 #544d3c; padding: 0 clamp(16px, 2.5vw, 29px) clamp(20px, 2.5vw, 29px); }
.game-card-stripe { height: 11px; margin: 0 calc(-1 * clamp(16px, 2.5vw, 29px)) 24px; background: repeating-linear-gradient(115deg, var(--yellow) 0 14px, #29251c 14px 20px); border-bottom: 2px solid #ad8f2c; }
.game-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.section-kicker { color: var(--yellow); margin: 0 0 9px; font-size: 10px; font-weight: 900; letter-spacing: .15em; }
.game-card h2 { margin: 0; font-size: clamp(22px, 2.5vw, 31px); font-weight: 900; letter-spacing: -.045em; }
.date-badge { border: 1px solid var(--line); color: #d4cabb; font-family: "Courier New", monospace; font-size: 10px; letter-spacing: -.04em; font-weight: 700; padding: 8px 9px; white-space: nowrap; }
.status { min-height: 1.35em; margin: 18px 0 21px; color: #c9c1b2; font-size: 13px; line-height: 1.4; }
.status.error { color: #f4ad9f; }
.storage-notice { border: 1px solid #9f7d35; background: #362b1e; color: #f3d797; padding: 10px 12px; font-size: 12px; line-height: 1.4; margin-top: 18px; }
.board { width: 100%; max-width: 322px; margin: 0 auto 27px; display: grid; gap: 7px; }
.board-row { display: grid; grid-template-columns: repeat(var(--word-length, 5), minmax(0, 1fr)); gap: 7px; }
.tile { min-width: 0; aspect-ratio: 1; display: grid; place-items: center; border: 2px solid #6b6252; color: var(--text); font-size: clamp(23px, 6vw, 31px); font-weight: 900; line-height: 1; transition: background .18s, border-color .18s, transform .18s; }
.tile.word-gap { margin-left: 6px; }
.board.long .board-row { gap: 3px; }
.board.long .tile { border-width: 1px; font-size: clamp(12px, 3vw, 21px); }
.board.very-long .board-row { gap: 2px; }
.board.very-long .tile { font-size: clamp(10px, 2.5vw, 16px); }
.board.extra-long .tile { font-size: clamp(17px, 2vw, 23px); }
.tile.filled { border-color: #b4a581; background: #3b372d; }
.tile.correct { background: var(--green-dark); border-color: #86b459; color: #fff; }
.tile.present { background: #a17b24; border-color: #e0b646; color: #fff; }
.tile.absent { background: #4b4842; border-color: #666159; color: #fff; }
.board-row.active .tile:not(.filled) { border-color: #948770; }
.keyboard { display: grid; gap: 5px; width: 100%; }
.keyboard-row { display: flex; justify-content: center; gap: 4px; }
.key { flex: 1 1 0; min-width: 0; height: 43px; display: grid; place-items: center; padding: 0 1px; border: 1px solid #675f51; border-radius: 2px; background: #3d3931; color: #f4efe4; font-size: clamp(10px, 2.5vw, 13px); font-weight: 900; transition: transform .1s, background .18s, border-color .18s; }
.key:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--yellow); background: #5a5040; }
.key:active:not(:disabled) { transform: translateY(0); }
.key.special { flex: 1.45 1 0; font-size: 15px; color: var(--yellow); background: #343025; border-color: #8b7746; }
.key.ye { font-size: 9px; letter-spacing: -.035em; }
.key.correct { background: var(--green-dark); border-color: #86b459; color: #fff; }
.key.present { background: #a17b24; border-color: #e0b646; color: #fff; }
.key.absent { background: #4b4842; border-color: #666159; color: #e0dbd1; }
.key:disabled { opacity: .72; }

.empty-state { text-align: center; padding: 38px 15px 24px; }
.empty-icon { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 20px; border: 1px dashed #927c48; color: var(--yellow); font-size: 35px; }
.empty-state h3 { font-size: 21px; margin: 0 0 9px; }
.empty-state p { color: var(--muted); line-height: 1.6; font-size: 13px; max-width: 290px; margin: auto; }
.result-card { margin-top: 27px; padding-top: 23px; border-top: 1px solid var(--line); }
.result-card h3 { font-size: 22px; margin: 0 0 13px; letter-spacing: -.03em; }
.answer-line { margin: 0 0 9px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.answer-line strong { margin-left: 5px; color: var(--green); font-size: 19px; letter-spacing: .07em; }
.context-text { margin: 0 0 11px; font-size: 14px; line-height: 1.55; }
.context-text a { color: var(--green); overflow-wrap: anywhere; text-underline-offset: 4px; }
.result-image { display: block; width: 100%; height: auto; margin: 12px 0; border: 1px solid var(--line); }
.source-link { color: var(--green); font-size: 13px; font-weight: 700; text-underline-offset: 4px; }
.source-link:hover { color: #d4ee9f; }
.result-actions { display: grid; grid-template-columns: 1fr; gap: 9px; margin-top: 21px; }
.primary-button, .secondary-button { min-height: 44px; border-radius: 2px; padding: 10px 14px; font-size: 13px; font-weight: 800; }
.primary-button { display: flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid #ffe178; background: var(--yellow); color: #211b0e; }
.primary-button:hover { background: #ffdf6a; }
.secondary-button { border: 1px solid #746a56; background: transparent; color: var(--text); }
.secondary-button:hover { background: #38342b; }

.legend-tile { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 2px; color: #fff; font-weight: 900; }
.legend-tile.correct { background: var(--green-dark); }
.legend-tile.present { background: #a17b24; }
.legend-tile.absent { background: #4b4842; }

.site-footer { min-height: 78px; border-top: 2px solid var(--text); display: flex; align-items: center; justify-content: space-between; gap: 16px; color: #a69d8e; font-size: 10px; font-weight: 800; letter-spacing: .1em; }
.footer-divider { color: var(--red); margin: 0 8px; }
.site-footer button { border: 0; padding: 9px 0; color: var(--yellow); background: transparent; font-size: 11px; letter-spacing: 0; }

.modal { width: min(100% - 28px, 500px); max-height: min(85vh, 740px); overflow-y: auto; border: 2px solid #8a7c5d; border-radius: 3px; background: #24221d; color: var(--text); box-shadow: 10px 10px 0 rgba(0,0,0,.6); padding: clamp(21px, 4vw, 32px); }
.modal::backdrop { background: rgba(10,9,7,.83); }
.modal-head { display: flex; align-items: start; justify-content: space-between; }
.modal-head .section-kicker { padding-top: 8px; }
.icon-button { width: 31px; height: 31px; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--muted); font-size: 23px; line-height: 1; }
.icon-button:hover { background: #413a2c; color: #fff; }
.modal h2 { margin: 16px 0 17px; font-size: 29px; letter-spacing: -.04em; }
.modal p { color: #d0c7b7; font-size: 14px; line-height: 1.62; }
.modal p strong { color: #fff8e7; }
.modal-action { width: 100%; margin-top: 19px; }
.help-example { display: flex; gap: 6px; margin: 21px 0; }
.help-example .legend-tile { width: 43px; height: 43px; font-size: 21px; }
.modal-subtitle { margin-top: -8px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 25px 0; }
.stat { min-width: 0; border: 1px solid var(--line); background: #302d27; padding: 15px 5px; text-align: center; }
.stat strong { display: block; color: var(--green); font-size: 26px; line-height: 1; }
.stat span { display: block; margin-top: 8px; color: #c6bcab; font-size: 10px; line-height: 1.2; }
.stats-subhead { font-size: 13px; letter-spacing: .02em; }
.distribution { display: grid; gap: 7px; }
.dist-row { display: grid; grid-template-columns: 14px 1fr; align-items: center; gap: 9px; color: #d0c7b7; font-size: 12px; font-weight: 700; }
.dist-track { height: 24px; background: #37342d; overflow: hidden; }
.dist-bar { min-width: 25px; height: 100%; display: flex; align-items: center; justify-content: flex-end; padding: 0 7px; background: #638a42; color: #fff; }
.dist-bar.zero { background: #545047; }
#share-fallback { width: 100%; resize: vertical; border: 1px solid #766b58; border-radius: 2px; padding: 12px; background: #161510; color: #fff; line-height: 1.55; }

@media (max-width: 940px) {
  .main-layout { grid-template-columns: minmax(135px, 185px) minmax(345px, 510px) minmax(135px, 185px); gap: 20px; }
  .visual-rail-left { padding-top: 60px; }
  .visual-rail-right { padding-top: 48px; }
}

@media (max-width: 760px) {
  .site-header { min-height: 75px; }
  .main-layout { display: flex; flex-direction: column; align-items: center; gap: 25px; width: 100%; max-width: 530px; margin: auto; padding-top: 28px; padding-bottom: 54px; }
  .visual-rail { width: 100%; padding: 0; flex-direction: row; align-items: center; justify-content: space-between; gap: 14px; }
  .visual-rail-left { min-height: 136px; padding: 0 7px; }
  .visual-rail-left .portrait-sticker { width: 128px; padding: 5px; }
  .visual-rail-left .portrait-sticker figcaption { padding: 4px 2px 0; font-size: 12px; }
  .visual-rail-left .ebalo-sticker { width: 98px; padding: 4px; align-self: center; }
  .visual-rail-left .ebalo-sticker figcaption { font-size: 8px; }
  .game-card { max-width: 510px; }
  .visual-rail-right { min-height: 135px; margin-top: 0; padding: 0 10px; }
  .visual-rail-right .hero-sticker { width: 165px; }
  .visual-rail-right .buldiga-sticker { width: 112px; align-self: center; }
  .visual-rail-right .buldiga-sticker figcaption { margin-top: -4px; font-size: 8px; }
  .site-footer { align-items: flex-start; flex-direction: column; justify-content: center; padding: 22px 0; line-height: 1.5; }
}

@media (max-width: 420px) {
  .brand { gap: 9px; }
  .brand-mark { width: 39px; height: 39px; font-size: 23px; }
  .brand-copy strong { font-size: 14px; }
  .brand-copy small { font-size: 7px; }
  .header-actions { gap: 4px; }
  .text-button { padding: 9px 7px; font-size: 10px; }
  .game-card { padding: 0 13px 21px; }
  .game-card-stripe { margin: 0 -13px 20px; }
  .board { width: min(100%, 296px); gap: 5px; }
  .board.long { width: 100%; }
  .board.very-long .board-row { grid-template-columns: repeat(var(--mobile-word-length), minmax(0, 1fr)); }
  .board.very-long .tile { font-size: clamp(16px, 4.5vw, 23px); }
  .board-row { gap: 5px; }
  .keyboard-row { gap: 2px; }
  .key { height: 42px; font-size: 10px; }
  .key.ye { font-size: 8px; }
  .stats-grid { gap: 5px; }
  .stat strong { font-size: 22px; }
  .stat span { font-size: 9px; }
}

@media (max-width: 360px) {
  .site-header { flex-wrap: wrap; gap: 8px; padding: 12px 0; }
  .header-actions { flex-basis: 100%; justify-content: flex-end; }
  .visual-rail-left { min-height: 115px; }
  .visual-rail-left .portrait-sticker { width: 108px; }
  .visual-rail-left .ebalo-sticker { width: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
