:root {
  --bg: #0c0d0b; --panel: #151713; --line: #2a2d26; --ink: #eef3e4; --mute: #a3ab96;
  --lime: #c6ff4d; --lav: #b9a3ff; --coral: #ff7a63; --miss: #1d201b;
  --r: 14px; --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--ink); font: 16px/1.4 var(--font);
  display: flex; flex-direction: column; overflow-x: hidden;
  background-image: radial-gradient(circle at 50% -20%, rgba(198,255,77,.10), transparent 55%),
    radial-gradient(circle at 110% 30%, rgba(185,163,255,.07), transparent 40%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
[hidden] { display: none !important; }
.defs { position: absolute; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
svg { width: 1em; height: 1em; flex: none; }
button, input, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--lav); outline-offset: 2px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px 4px; width: 100%; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mark { width: 30px; height: 30px; transform: rotate(-6deg); }
h1 { margin: 0; font-size: 1.45rem; letter-spacing: -.03em; font-weight: 800; }
h1 span { color: var(--lime); }
.no { font: 600 .8rem var(--mono); color: var(--mute); border: 1px solid var(--line); border-radius: 99px; padding: 2px 8px; }
.tools { display: flex; gap: 4px; }
.icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; font-size: 22px; color: var(--ink); }
.icon:hover { background: var(--panel); }

main { width: 100%; max-width: 760px; margin: 0 auto; padding: 4px 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.tries { display: flex; gap: 6px; justify-content: center; padding: 4px 0 2px; }
.tries i { width: 26px; height: 6px; border-radius: 9px; background: var(--line); }
.tries i.used { background: var(--lav); }
.tries i.won { background: var(--lime); }

.search { position: relative; display: flex; gap: 8px; }
.field { position: relative; flex: 1; display: flex; align-items: center; background: var(--panel); border: 2px solid var(--line); border-radius: var(--r); }
.field:focus-within { border-color: var(--lime); }
#q { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; padding: 12px 4px 12px 14px; font-size: 1.05rem; }
#q::placeholder { color: #7b8370; }
.icon.ghost { width: 44px; height: 44px; color: var(--mute); font-size: 20px; }
.go { width: 54px; border: 0; border-radius: var(--r); background: var(--lime); color: #10110e; display: grid; place-items: center; font-size: 24px; }
.go:active { transform: translateY(1px); }
.go:disabled, .search.locked .field { opacity: .45; }
.options { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px); margin: 0; padding: 6px; list-style: none;
  background: #191b17; border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 18px 40px rgba(0,0,0,.55); max-height: min(50vh, 340px); overflow-y: auto; overscroll-behavior: contain; }
.options li { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px; cursor: pointer; min-height: 48px; }
.options li[aria-selected="true"], .options li:hover { background: #262a21; }
.options img { width: 36px; height: 36px; image-rendering: pixelated; border-radius: 8px; background: #0f100e; }
.options b { font: 700 .95rem var(--mono); }
.options .sub { color: var(--mute); font-size: .85rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.options .dotc { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.options .empty { color: var(--mute); cursor: default; }
.msg { min-height: 1.3em; margin: 0; text-align: center; color: var(--coral); font-size: .9rem; }

.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.guess { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.t { position: relative; min-height: 62px; border-radius: 11px; padding: 6px 6px 7px; display: flex; flex-direction: column; justify-content: space-between; gap: 2px; overflow: hidden;
  background: var(--miss); border: 1px solid var(--line); }
.t small { font-size: .66rem; text-transform: uppercase; letter-spacing: .06em; opacity: .75; font-weight: 700; }
.t span { font-size: .8rem; font-weight: 700; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: break-word; hyphens: auto; }
.t .clan { font-size: .66rem; font-weight: 600; opacity: .8; -webkit-line-clamp: 1; }
.t.hit { background: var(--lime); color: #10110e; border-color: transparent; }
.t.near { background: var(--lav); color: #14101f; border-color: transparent; }
.t.hit::after, .t.near::after { content: ""; position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; border-radius: 50%; }
.t.hit::after { background: #10110e; }
.t.near::after { border: 2px solid #14101f; }
.t .sw { display: block; width: 26px; height: 26px; border-radius: 8px; box-shadow: inset 0 0 0 2px rgba(255,255,255,.28), 0 0 0 1px rgba(0,0,0,.35); }
.t .row { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 5px; }
.t .row .sw { width: 16px; height: 16px; border-radius: 50%; flex: none; }
.t .rank { display: flex; align-items: center; gap: 2px; font-family: var(--mono); }
.t .rank svg { font-size: 1.1rem; }
.t.me { padding: 0; background: #0f100e; align-items: center; justify-content: center; }
.t.me img { width: 100%; max-width: 64px; aspect-ratio: 1; image-rendering: pixelated; display: block; }
.t.me b { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font: 700 .7rem var(--mono); background: rgba(12,13,11,.82); padding: 1px 0; }
.guess.fresh .t { animation: flip .5s both; }
.guess.fresh .t:nth-child(2) { animation-delay: .06s; } .guess.fresh .t:nth-child(3) { animation-delay: .12s; }
.guess.fresh .t:nth-child(4) { animation-delay: .18s; } .guess.fresh .t:nth-child(5) { animation-delay: .24s; }
.guess.fresh .t:nth-child(6) { animation-delay: .30s; } .guess.fresh .t:nth-child(7) { animation-delay: .36s; }
.guess.fresh .t:nth-child(8) { animation-delay: .42s; }
@keyframes flip { from { transform: rotateX(90deg); opacity: .2; } to { transform: none; opacity: 1; } }

.result { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 18px; background: linear-gradient(140deg, #1a1d15, #141612); border: 1px solid var(--line); }
.result.won { border-color: rgba(198,255,77,.55); }
.art { flex: none; display: block; border-radius: 14px; overflow: hidden; background: #0f100e; }
.art img { display: block; width: 112px; height: 112px; image-rendering: pixelated; }
.result-body { min-width: 0; flex: 1; }
.result h2 { margin: 0; font-size: 1.3rem; letter-spacing: -.02em; }
.result.won h2 { color: var(--lime); }
.result-id { margin: 0 0 10px; font: 700 .95rem var(--mono); color: var(--mute); }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); font-weight: 700; text-decoration: none; }
.btn svg { font-size: 18px; }
.btn.primary { background: var(--lime); color: #10110e; border-color: transparent; }
.next { margin: 10px 0 0; color: var(--mute); font-size: .85rem; }
.next time { font-family: var(--mono); color: var(--ink); }

.foot { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; padding: 14px 14px 18px; color: var(--mute); font-size: .85rem; }
.foot strong { color: var(--ink); }
.foot .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--line); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #10110e; font-weight: 700; padding: 10px 16px; border-radius: 99px; transition: .25s; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

dialog { border: 1px solid var(--line); border-radius: 20px; padding: 0; background: #151713; color: var(--ink); width: min(420px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); }
dialog::backdrop { background: rgba(5,6,4,.72); }
.sheet { padding: 16px 18px 20px; overflow-y: auto; max-height: calc(100dvh - 26px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px 6px 0; }
.sheet h2 { margin: 0; font-size: 1.2rem; }
.sheet p { margin: 6px 0 12px; color: #cfd6c3; }
.sheet .fine { color: var(--mute); font-size: .85rem; margin-bottom: 0; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.legend li { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.legend .sw { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-size: 18px; border: 1px solid var(--line); }
.sw.hit { background: var(--lime); border-color: transparent; } .sw.near { background: var(--lav); border-color: transparent; } .sw.miss { background: var(--miss); }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 16px; text-align: center; }
.nums div { background: var(--miss); border-radius: 12px; padding: 8px 2px; }
.nums dt { font-size: .7rem; color: var(--mute); text-transform: uppercase; letter-spacing: .05em; }
.nums dd { margin: 0; font: 800 1.4rem var(--mono); }
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.dist li { display: grid; grid-template-columns: 16px 1fr; gap: 8px; align-items: center; font: 700 .85rem var(--mono); }
.dist i { display: block; min-width: 26px; padding: 3px 7px; border-radius: 6px; background: var(--miss); font-style: normal; text-align: right; }
.dist li.now i { background: var(--lime); color: #10110e; }

@media (min-width: 640px) {
  .guess { grid-template-columns: 64px repeat(7, minmax(0, 1fr)); }
  .t { min-height: 74px; }
  .t span { font-size: .9rem; } .t small, .t .clan { font-size: .7rem; }
  .art img { width: 144px; height: 144px; }
  h1 { font-size: 1.7rem; }
}
/* Phone landscape and short screens: keep the input and the latest guess in view. */
@media (max-height: 480px) and (orientation: landscape) {
  .top { padding-top: 6px; }
  main { gap: 8px; }
  .guess { grid-template-columns: 52px repeat(7, minmax(0, 1fr)); }
  .t { min-height: 52px; }
  .art img { width: 88px; height: 88px; }
  .result { padding: 10px; }
  .foot { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.lost { justify-content: center; align-items: center; text-align: center; }
