/* Spot the bug: an app-style page. Menu scrolls; play and results are full-screen. */
.bug-app { background-attachment: scroll; -webkit-tap-highlight-color: transparent; }
.bug-app button, .bug-app summary, .bug-app a { touch-action: manipulation; }
.bug-app .toast { z-index: 80; top: calc(16px + env(safe-area-inset-top)); }

/* Installed as an app: no site tabs, just the game */
@media (display-mode: standalone) { .bug-app .tabs { display: none; } }
.streak { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; }
.streak b { color: var(--green); font-weight: 500; }

/* Menu */
.app { max-width: 720px; margin: 0 auto; padding: 22px max(16px, env(safe-area-inset-left)) calc(28px + env(safe-area-inset-bottom)); }
.intro h1 { margin: 6px 0 0; font-size: clamp(2rem, 7vw, 2.8rem); line-height: 1.05; letter-spacing: -.035em; font-weight: 800; }
.intro p { margin: 8px 0 20px; color: var(--muted); }
.card { background: rgba(255,255,255,.035); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 14px; }
.card h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.card h2 .no { font-family: var(--mono); font-size: .85rem; font-weight: 500; color: var(--cyan); margin-left: 4px; }
.card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.daily { border-color: rgba(74,222,128,.35); background: linear-gradient(160deg, rgba(74,222,128,.08), rgba(91,207,230,.03) 60%, rgba(255,255,255,.02)); }
.sub-t { margin: 6px 0 16px; color: var(--muted); font-size: .95rem; }
.next, .best-t { font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.next { margin: 10px 0 0; text-align: center; }
.best-t { margin: 10px 0 0; text-align: center; }
.best-t:empty { display: none; }
.done-t { margin: 12px 0 16px; color: var(--muted); }
.btn.big { display: block; width: 100%; padding: 14px 18px; font-size: 1.05rem; font-weight: 600; border-radius: 12px; text-align: center; }
.btn.big:active { transform: scale(.985); }
.pick { margin-top: 16px; }
.pick:last-of-type { margin-bottom: 18px; }
.lbl { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 0 20px 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; font: inherit; font-size: .95rem; color: var(--text); padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; transition: border-color .15s, background .15s; }
.chip:hover { border-color: rgba(91,207,230,.5); }
.chip[aria-checked="true"] { border-color: var(--cyan); background: rgba(91,207,230,.14); }
.seg { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.seg button { font: inherit; font-size: .92rem; color: var(--muted); padding: 9px 4px; border: 0; border-radius: 9px; background: none; cursor: pointer; }
.seg button[aria-checked="true"] { color: var(--text); background: rgba(91,207,230,.16); box-shadow: inset 0 0 0 1px var(--cyan); }
.seg button.x[aria-checked="true"] { background: rgba(236,72,153,.14); box-shadow: inset 0 0 0 1px var(--pink); }
.hint { margin: 8px 0 0; font-size: .85rem; color: var(--muted); }
.how summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-right: 4px; transition: transform .2s; }
.how[open] summary::after { transform: rotate(-135deg); }
.pts { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: .9rem; }
.pts th { text-align: left; font-weight: 500; color: var(--muted); font-size: .78rem; padding: 0 0 6px; }
.pts td { padding: 7px 0; border-top: 1px solid var(--line); font-family: var(--mono); font-size: .84rem; }
.pts td:first-child { font-family: inherit; font-size: .92rem; }
.rules { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: .9rem; }
.rules li + li { margin-top: 6px; }
.install { margin: 4px 0 14px; }
.install .hint { text-align: center; }
.madeby { text-align: center; color: var(--muted); font-size: .85rem; margin: 18px 0 0; }
.madeby a { color: var(--cyan); text-decoration: none; }

/* Result squares: found first try / found after wrong taps or partly / not found */
.grid-row { display: flex; gap: 6px; }
.grid-row i { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); background: #1E2833; }
.grid-row i.g { background: var(--green); border-color: var(--green); }
.grid-row i.a { background: var(--amber); border-color: var(--amber); }
.grid-row i.x { background: none; border-style: dashed; }

/* Full-screen play and results */
body.playing { overflow: hidden; }
.screen { position: fixed; inset: 0; z-index: 50; background: var(--bg); background-image: linear-gradient(160deg, #13232B 0%, #161C28 55%, #1B1A2B 100%); display: flex; }
.scr-in { flex: 1; display: flex; flex-direction: column; min-height: 0; width: 100%; max-width: 860px; margin: 0 auto; padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.hud { display: flex; align-items: center; gap: 8px; min-height: 48px; font-size: .95rem; }
.icon-btn { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin-left: -6px; border: 0; border-radius: 10px; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: rgba(255,255,255,.06); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.prog { font-family: var(--mono); color: var(--muted); font-size: .9rem; margin-right: 2px; }
.prog b { color: var(--text); font-weight: 500; }
.hud .tag { font-family: var(--mono); font-size: .74rem; padding: 3px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); white-space: nowrap; }
.hud .tag.x { color: var(--pink); border-color: rgba(236,72,153,.5); }
.hud .sp { flex: 1; }
.score { font-family: var(--mono); font-size: .9rem; color: var(--muted); white-space: nowrap; }
.score b { color: var(--green); font-size: 1.05rem; font-weight: 500; }
.timer { flex: none; height: 6px; border-radius: 3px; background: rgba(255,255,255,.08); overflow: hidden; margin: 4px 0 12px; }
.timer i { display: block; height: 100%; width: 100%; background: var(--green); border-radius: 3px; transition: width .1s linear; }
.timer i.low { background: var(--amber); }
.ask { flex: none; }
.goal { margin: 0 0 4px; font-weight: 500; line-height: 1.4; }
.goal:empty { display: none; }
.goal .k { font-family: var(--mono); font-size: .72rem; font-weight: 400; color: var(--cyan); text-transform: uppercase; letter-spacing: .06em; margin-right: 8px; }
.left { margin: 0 0 6px; font-size: .88rem; color: var(--muted); }
.left:empty { display: none; }
.left b { color: var(--pink); font-weight: 600; }
.code { flex: 0 1 auto; min-height: 0; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: #0F161E; padding: 8px 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.ln { display: flex; align-items: flex-start; width: 100%; text-align: left; font-family: var(--mono); font-size: .92rem; line-height: 1.5; color: #E6EDF3; background: none; border: 0; border-left: 3px solid transparent; padding: 8px 14px 8px 0; cursor: pointer; user-select: none; -webkit-user-select: none; transition: background .12s; }
.ln .no { flex: none; width: 2.6em; padding-right: .9em; text-align: right; color: #4A5866; }
.ln .src { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ln:hover:not(:disabled) { background: rgba(91,207,230,.07); }
.ln:active:not(:disabled) { background: rgba(91,207,230,.16); }
.ln:disabled { cursor: default; }
.ln.blank { padding: 0; height: 14px; pointer-events: none; }
.ln.wrong { background: rgba(247,200,115,.10); border-left-color: var(--amber); color: #FBDDA6; animation: shake .28s; }
.ln.right { background: rgba(74,222,128,.14); border-left-color: var(--green); }
.ln.missed { background: rgba(236,72,153,.10); border-left-color: var(--pink); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .ln.wrong { animation: none; } .sheet { animation: none !important; } }
@media (max-width: 560px) { .ln { font-size: .8rem; padding: 8px 10px 8px 0; } .ln .no { width: 2.3em; padding-right: .7em; } }
.msg { flex: none; min-height: 1.5em; margin: 8px 2px 0; font-size: .9rem; color: var(--muted); }
.msg.bad { color: #FBDDA6; } .msg.ok { color: var(--green); }

.sheet { flex: none; margin-top: auto; max-height: 52vh; overflow: auto; margin: 0 -14px calc(-12px - env(safe-area-inset-bottom)); padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; background: #1B2531; border-top: 1px solid var(--line); box-shadow: 0 -18px 40px -20px rgba(0,0,0,.8); animation: up .25s ease-out; }
@media (min-width: 900px) { .sheet { margin: auto 0 0; border-radius: 14px; border: 1px solid var(--line); padding-bottom: 16px; } }
@keyframes up { from { transform: translateY(40%); opacity: 0; } }
.fb-h { margin: 0 0 4px; font-weight: 700; font-size: 1.05rem; }
.fb-h.ok { color: var(--green); } .fb-h.bad { color: #FBDDA6; }
.fb-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.fb-item:last-child { border-bottom: 0; margin-bottom: 8px; }
.fb-why { margin: 0; color: var(--muted); font-size: .94rem; }
.fb-why .n { font-family: var(--mono); font-size: .78rem; color: var(--cyan); margin-right: 6px; }
.fb-fix { display: flex; gap: 10px; align-items: baseline; margin-top: 6px; }
.fb-fix span { flex: none; font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--green); }
.fb-fix code { min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #CFF3FB; font-size: .84rem; }

.end .scr-in { justify-content: center; }
.end-box { width: 100%; max-width: 420px; margin: 0 auto; text-align: center; }
.end-box h2 { margin: 0; font-size: 1.1rem; color: var(--muted); font-weight: 500; }
.end-box .total { margin: 10px 0 18px; font-size: clamp(3rem, 14vw, 4.2rem); font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.end-box .total small { font-size: .35em; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.end-box .grid-row { justify-content: center; }
.end-box .done-t { margin: 16px 0 24px; }
.end-btns { display: grid; gap: 10px; }
