:root {
    --bg: #0b0d14;
    --bg-2: #11141f;
    --card: #161a27;
    --card-2: #1c2132;
    --border: #262c3f;
    --text: #e8ebf5;
    --muted: #8b93ad;
    --accent: #5b8cff;
    --accent-2: #b15bff;
    --exact: #22b573;
    --partial: #e3b341;
    --miss: #2a3043;
    --radius: 14px;
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

html, body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    -webkit-font-smoothing: antialiased;
}

body {
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(91, 140, 255, .18), transparent 60%),
        radial-gradient(800px 500px at 100% 0%, rgba(177, 91, 255, .14), transparent 60%),
        var(--bg);
}

a { color: var(--accent); }
button { font: inherit; cursor: pointer; }

.shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 16px 16px 48px;
}

/* ---------- boot / loading ---------- */
.boot {
    min-height: 70vh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 16px;
    color: var(--muted);
}
.boot-ring {
    width: 56px; height: 56px;
    border-radius: 50%;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.boot-intro { max-width: 560px; text-align: left; color: var(--muted); font-size: 15px; line-height: 1.55; }
.boot-intro h1 { font-size: 24px; color: var(--text); margin: 8px 0 4px; }
.boot-intro h2 { font-size: 16px; color: var(--text); margin: 16px 0 4px; }
.boot-intro ul { padding-left: 20px; margin: 0; }
.boot-intro li { margin: 4px 0; }
.loading { padding: 64px 0; text-align: center; color: var(--muted); }

#blazor-error-ui {
    display: none;
    position: fixed; left: 0; right: 0; bottom: 0;
    padding: 12px 20px;
    background: #ffb35c; color: #1a1200;
    z-index: 1000;
}
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    display: grid; place-items: center;
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    font-weight: 800; font-size: 22px; color: #fff;
    box-shadow: 0 8px 24px rgba(91, 140, 255, .35);
}
.brand-mark svg {
    animation: brand-spin 9s linear infinite;
    transform-origin: 50% 50%;
}
@keyframes brand-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .brand-mark svg { animation: none; }
}
.brand h1 {
    margin: 0;
    font-size: 28px; font-weight: 800; letter-spacing: -.02em;
    color: #fff;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.streak-badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 38px; padding: 0 12px;
    border-radius: 10px;
    background: rgba(255, 138, 61, .14);
    border: 1px solid rgba(255, 138, 61, .45);
    color: #ffb27a; font-weight: 700; font-size: 14px; font-family: var(--mono);
}
.icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-weight: 700;
}
.icon-btn:hover { background: var(--card-2); }

/* ---------- mode switch ---------- */
.modes {
    display: flex; justify-content: center; gap: 4px;
    width: max-content; margin: 0 auto 18px;
    padding: 4px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.mode {
    padding: 8px 22px;
    border: none; border-radius: 9px;
    background: transparent; color: var(--muted);
    font-weight: 600;
}
.mode.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
}

/* ---------- rounds ---------- */
.rounds {
    list-style: none; padding: 0;
    display: flex; align-items: center; justify-content: center; gap: 10px;
    margin: 0 0 18px;
    font-size: 13px; font-weight: 600;
}
.round-pill {
    padding: 5px 12px; border-radius: 999px;
    background: var(--card); border: 1px solid var(--border); color: var(--muted);
}
.round-pill.active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px rgba(91, 140, 255, .15); }
.round-pill.done { background: var(--exact); border-color: var(--exact); color: #04150c; }
.round-arrow { color: var(--muted); }

/* ---------- round 1 summary strip (while round 2 is running) ---------- */
.round-strip {
    max-width: 640px; margin: 0 auto 16px;
    display: flex; align-items: center; gap: 14px;
    padding: 12px 16px;
}
.strip-img { width: 56px; height: 56px; object-fit: contain; flex: 0 0 56px; }
.strip-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.strip-title { font-weight: 700; }
.strip-sub { color: var(--muted); font-size: 13px; font-family: var(--mono); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.prefetch { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.prefetch img { width: 1px; height: 1px; }

/* ---------- image round ---------- */
.image-round {
    max-width: 640px; margin: 0 auto 20px;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    text-align: center;
}
.round-title { margin: 0; font-size: 20px; }
.reveal-note { margin: 0; color: var(--muted); font-size: 14px; }
.reveal-frame {
    position: relative;
    width: 240px; height: 240px;
    display: grid; place-items: center;
    border-radius: 18px;
    background: radial-gradient(circle at 50% 45%, var(--card-2), var(--bg-2) 70%);
    overflow: hidden;
}
.reveal-frame.solved { box-shadow: 0 0 0 3px var(--exact); }
/* Wrong round-2 guess: the frame jolts, a red ring flares and fades, and the silhouette flushes red
   before the next blur stage eases in. The .miss class is removed after MissMs (Home.razor). */
.reveal-frame.miss { animation: miss-jolt .55s cubic-bezier(.36, .07, .19, .97) both; }
.reveal-frame.miss::after {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    box-shadow: inset 0 0 0 3px #ff5c5c, inset 0 0 28px rgba(255, 92, 92, .55);
    animation: miss-fade .7s ease-out both;
}
.reveal-frame.miss .reveal-shape::after {
    content: ""; position: absolute; inset: 0; background: #ff5c5c;
    animation: miss-fade .7s ease-out both;
}
@keyframes miss-jolt {
    10%, 90% { transform: translateX(-2px) rotate(-.5deg); }
    20%, 80% { transform: translateX(4px) rotate(.5deg); }
    30%, 50%, 70% { transform: translateX(-8px) rotate(-1deg); }
    40%, 60% { transform: translateX(8px) rotate(1deg); }
}
@keyframes miss-fade { from { opacity: .9; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
    .reveal-frame.miss { animation: none; }
}
/* Blur only the details inside a crisp silhouette, never the outer contour. */
.reveal-shape {
    position: relative;
    width: 205px; height: 205px;
    background: #8490a8;
    -webkit-mask: var(--blade-mask) center / contain no-repeat;
    mask: var(--blade-mask) center / contain no-repeat;
}
.reveal-img {
    width: 205px; height: 205px; object-fit: contain;
    transition: filter 1.2s ease;
}
/* 0-1 misses: silhouette, edges softening. 2+ misses: colour comes through a heavy blur that eases
   step by step; stage 7 is the sharpest the picture gets before it is solved. */
.reveal-img.stage-0 { filter: brightness(0) invert(1) opacity(.9) blur(6px); }
.reveal-img.stage-1 { filter: brightness(0) invert(1) opacity(.9) blur(2px); }
.reveal-img.stage-2 { filter: blur(28px) saturate(1.4) contrast(.9); }
.reveal-img.stage-3 { filter: blur(20px) saturate(1.3); }
.reveal-img.stage-4 { filter: blur(14px) saturate(1.2); }
.reveal-img.stage-5 { filter: blur(10px); }
.reveal-img.stage-6 { filter: blur(7px); }
.reveal-img.stage-7 { filter: blur(5px); }
.chips { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 12px 0 0; padding: 0; }
.chip {
    padding: 6px 12px; border-radius: 999px;
    background: var(--miss); color: var(--text);
    font-size: 13px; font-weight: 600;
    text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, .35);
    animation: chip-in .45s cubic-bezier(.2, .9, .3, 1.3) both;
}
@keyframes chip-in {
    from { transform: scale(.6) translateY(-6px); opacity: 0; background: #ff5c5c; }
    to { transform: scale(1) translateY(0); opacity: 1; background: var(--miss); }
}
@media (prefers-reduced-motion: reduce) {
    .chip { animation: none; }
}
.reveal-full {
    width: 140px; height: 140px; object-fit: contain;
    display: block; margin: 0 auto 8px;
    filter: drop-shadow(0 10px 24px rgba(91, 140, 255, .35));
    animation: pop .8s cubic-bezier(.2, .9, .3, 1.2) both;
}
@keyframes pop {
    from { transform: scale(.6) rotate(-20deg); opacity: 0; }
    to { transform: scale(1) rotate(0); opacity: 1; }
}
.board-title { margin: 8px 0 10px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- intro ---------- */
.intro { text-align: center; margin-bottom: 20px; }
.tagline { margin: 0 0 6px; font-size: 18px; }
.meta { margin: 0; color: var(--muted); font-size: 14px; }
.debug-badge {
    max-width: 560px; margin: -8px auto 20px;
    padding: 8px 14px;
    text-align: center; font-size: 13px;
    color: #ffd166;
    background: rgba(255, 209, 102, .12);
    border: 1px dashed rgba(255, 209, 102, .5);
    border-radius: 10px;
}
.debug-badge code { font-family: var(--mono); }

/* ---------- search ---------- */
.guess-box { max-width: 560px; margin: 0 auto 24px; }
.search { position: relative; }
.search-input {
    width: 100%;
    padding: 16px 18px;
    font: inherit; font-size: 17px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(91, 140, 255, .18);
}
.search.open .search-input { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.suggestions {
    position: absolute; left: 0; right: 0; top: 100%;
    margin: 0; padding: 6px; list-style: none;
    background: var(--card);
    border: 1px solid var(--accent); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 20px 40px rgba(0, 0, 0, .45);
    z-index: 20;
}
.suggestions li {
    display: flex; align-items: center; gap: 14px;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}
.suggestions li:hover, .suggestions li.active { background: var(--card-2); }
.s-img {
    flex: 0 0 60px;
    width: 60px; height: 60px;
    object-fit: contain;
    border-radius: 12px;
    background: var(--bg-2);
    padding: 4px;
}
.s-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.s-name { font-weight: 700; font-size: 16px; }
.s-sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hint-text { text-align: center; color: var(--muted); font-size: 14px; margin: 12px 0 0; }

/* ---------- board ---------- */
.board { margin-top: 8px; max-width: 1140px; margin-left: auto; margin-right: auto; }
.board-scroll { overflow-x: auto; padding-bottom: 8px; }
.row {
    display: grid;
    grid-template-columns: minmax(150px, 1.7fr) repeat(8, minmax(78px, 1fr));
    gap: 6px;
    margin-bottom: 6px;
    min-width: 870px;
}
.row.head .cell {
    background: transparent;
    color: var(--muted);
    font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    min-height: 0; padding: 4px 8px;
}
.cell {
    position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 62px;
    padding: 8px;
    border-radius: 10px;
    background: var(--card);
    border: 1px solid var(--border);
    font-weight: 600; font-size: 14px; text-align: center;
    overflow-wrap: anywhere;
}
.cell.name { align-items: flex-start; text-align: left; transition: background .6s ease, border-color .6s ease, color .6s ease; }
.search-input:disabled { opacity: .55; cursor: wait; }
.cell.name .n { font-weight: 700; }
.cell.name .c { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.cell.exact { --final-bg: var(--exact); --final-fg: #04150c; }
.cell.partial { --final-bg: var(--partial); --final-fg: #1c1500; }
.cell.miss { --final-bg: var(--miss); --final-fg: var(--text); }
.cell.exact, .cell.partial, .cell.miss {
    background: var(--final-bg);
    border-color: var(--final-bg);
    color: var(--final-fg);
}
.cell.name.exact .c { color: #04150c; opacity: .75; }
.arrow { position: absolute; right: 6px; top: 4px; font-style: normal; font-size: 11px; opacity: .8; }

/* Separate faces turn continuously; each card has its own vanishing point. */
.cell.flip-card {
    display: grid; padding: 0; border: 0; background: transparent;
    grid-template-columns: minmax(0, 1fr); align-items: stretch;
    perspective: 700px;
    --turn-delay: 0s;
}
.card-turn {
    display: grid; min-width: 0;
    transform-style: preserve-3d;
    transform: rotateX(-180deg);
}
.card-face {
    grid-area: 1 / 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative; min-height: 62px; padding: 8px; border-radius: 10px;
    backface-visibility: hidden; -webkit-backface-visibility: hidden;
    border: 1px solid rgba(255, 255, 255, .12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 2px 3px rgba(0, 0, 0, .18);
}
.card-cover {
    background: linear-gradient(145deg, #242b40, var(--card) 75%);
    border-color: var(--border);
}
.card-cover::before {
    content: ""; width: 18px; height: 18px; border-radius: 6px;
    border: 1px solid rgba(139, 147, 173, .3);
    box-shadow: inset 0 0 0 4px rgba(139, 147, 173, .06);
    transform: rotate(45deg);
}
.card-result {
    transform: rotateX(-180deg);
    background: linear-gradient(145deg, rgba(255, 255, 255, .1), transparent 60%), var(--final-bg);
    color: var(--final-fg);
}
.row.fresh .card-turn {
    animation: card-turn 1.55s both;
    animation-delay: var(--turn-delay);
}
.row .flip-card:nth-child(3) { --turn-delay: .25s; }
.row .flip-card:nth-child(4) { --turn-delay: .53s; }
.row .flip-card:nth-child(5) { --turn-delay: .81s; }
.row .flip-card:nth-child(6) { --turn-delay: 1.09s; }
.row .flip-card:nth-child(7) { --turn-delay: 1.37s; }
.row .flip-card:nth-child(8) { --turn-delay: 1.65s; }
.row .flip-card:nth-child(9) { --turn-delay: 1.93s; }
.row .flip-card:nth-child(10) { --turn-delay: 2.21s; }
.row .flip-card:nth-child(11) { --turn-delay: 2.49s; }
@keyframes card-turn {
    0%   { transform: translateY(0) rotateX(0deg); animation-timing-function: cubic-bezier(.22, .7, .3, 1); }
    18%  { transform: translateY(-3px) translateZ(10px) rotateX(8deg); animation-timing-function: cubic-bezier(.42, 0, .22, 1); }
    78%  { transform: translateY(-1px) translateZ(6px) rotateX(-184deg); animation-timing-function: cubic-bezier(.2, .65, .3, 1); }
    100% { transform: translateY(0) translateZ(0) rotateX(-180deg); }
}
/* ---------- result ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
}
.result { max-width: 640px; margin: 0 auto 20px; text-align: center; }
.result.compact .reveal-grid dd { font-size: 14px; }
.result-title { margin: 0 0 16px; font-size: 20px; }
.reveal { background: var(--bg-2); border-radius: 12px; padding: 18px; }
.reveal-head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 14px; }
.reveal-head h2 { margin: 0; font-size: 26px; letter-spacing: -.01em; }
.stock { font-family: var(--mono); color: var(--muted); font-size: 14px; }
.badge {
    font-family: var(--mono); font-size: 12px; font-weight: 700;
    padding: 3px 8px; border-radius: 6px;
    background: var(--card-2); color: var(--text);
}
.badge.line-bx { background: #1f3b6e; color: #cfe0ff; }
.badge.line-ux { background: #4a1f6e; color: #ead0ff; }
.badge.line-cx { background: #6e2a1f; color: #ffd8cf; }
.reveal-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px;
    margin: 0;
}
.reveal-grid dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.reveal-grid dd { margin: 2px 0 0; font-weight: 700; }
.stat-bars { grid-column: 1 / -1; }
.stat-bars dd { display: grid; gap: 6px; margin-top: 6px; }
.bar {
    position: relative; height: 18px; border-radius: 6px; background: var(--card-2); overflow: hidden;
}
.bar i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 6px; }
.bar b { position: absolute; right: 8px; top: 0; line-height: 18px; font-size: 12px; }
.result-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 16px; margin-top: 18px; }
.countdown { color: var(--muted); font-size: 14px; }
.countdown strong { font-family: var(--mono); color: var(--text); }

.btn {
    padding: 11px 18px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--card-2);
    color: var(--text);
    font-weight: 600;
}
.btn.primary {
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 8px 20px rgba(91, 140, 255, .3);
}
.btn:hover { filter: brightness(1.08); }

/* ---------- modals ---------- */
.modal-backdrop {
    position: fixed; inset: 0;
    display: grid; place-items: center;
    padding: 16px;
    background: rgba(5, 7, 12, .7);
    backdrop-filter: blur(4px);
    z-index: 100;
}
.modal {
    width: min(520px, 100%);
    max-height: 90vh;
    overflow: auto;
    outline: none;
}
.modal .btn:focus-visible, .icon-btn:focus-visible, .mode:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal h2 { margin: 0 0 12px; }
.modal h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); }
.modal .btn { margin-top: 16px; }
.legend { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.legend li { display: flex; gap: 12px; align-items: flex-start; }
.swatch { flex: 0 0 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-size: 12px; }
.swatch.exact { background: var(--exact); }
.swatch.partial { background: var(--partial); }
.swatch.miss { background: var(--miss); }
.swatch.arrow-demo { background: var(--card-2); }
.muted { color: var(--muted); font-size: 14px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats-grid div { background: var(--bg-2); border-radius: 10px; padding: 12px 6px; text-align: center; }
.stats-grid b { display: block; font-size: 24px; }
.stats-grid span { font-size: 12px; color: var(--muted); }
.dist { display: grid; gap: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; }
.dist-row .k { width: 24px; font-family: var(--mono); color: var(--muted); }
.dist-row .v {
    background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
    padding: 3px 8px; border-radius: 6px; text-align: right; min-width: 28px;
}

/* ---------- easter eggs & achievements ---------- */
.card.xtreme {
    border-color: rgba(227, 179, 65, .7);
    box-shadow: 0 0 0 1px rgba(227, 179, 65, .25), 0 0 28px rgba(227, 179, 65, .18);
}
.anniversary { display: block; margin: 8px 0 0; font-size: 14px; color: #ffb27a; }
.result .anniversary { margin: -8px 0 16px; }
.hint-text.egg { color: var(--partial); font-weight: 600; }

.achievements { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ach {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px;
    background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
}
.ach-icon { font-size: 24px; width: 32px; text-align: center; flex: 0 0 32px; }
.ach-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ach-title { font-weight: 700; }
.ach-desc { font-size: 13px; color: var(--muted); }
.ach-date { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.ach.locked { opacity: .6; }
.ach.locked .ach-icon { filter: grayscale(1); }
.ach.unlocked { border-color: rgba(227, 179, 65, .45); }

.toast {
    position: fixed; right: 16px; bottom: 16px; z-index: 50;
    display: flex; align-items: center; gap: 12px;
    width: min(320px, calc(100vw - 32px));
    padding: 12px 16px;
    background: var(--card-2); color: var(--text);
    border: 1px solid rgba(227, 179, 65, .6); border-radius: 12px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .45), 0 0 0 1px rgba(227, 179, 65, .2);
    animation: toast 5.4s both;
}
.toast-icon { font-size: 28px; width: 40px; text-align: center; flex: 0 0 40px; }
.toast-text { display: flex; flex-direction: column; gap: 2px; }
.toast-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--partial); font-weight: 700; }
.toast-title { font-weight: 700; font-size: 16px; }
@keyframes toast {
    0%        { transform: translateY(24px); opacity: 0; }
    7%, 93%   { transform: translateY(0); opacity: 1; }
    100%      { transform: translateY(24px); opacity: 0; }
}
@keyframes toast-still { 0%, 100% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .toast { animation: toast-still 5.4s both; }
}

/* ---------- footer ---------- */
.foot { margin-top: 36px; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 600px) {
    .brand h1 { font-size: 24px; }
    .tagline { font-size: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
