:root {
    font-family: "Segoe UI", system-ui, sans-serif;
    color: #161c33;
    background: #f5f2e9;
    --blue: #2e22a3;
    --mint: #a5ffce;
    --panel: #181e3b;
    --quiet: #bac3dc;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; background: radial-gradient(ellipse at 12% 15%, #e6e1ff, transparent 48%), #f5f2e9; }
a { color: var(--blue); text-underline-offset: 3px; }
button, summary { font: inherit; }
button:not(:disabled), summary { cursor: pointer; }
:is(a, button, summary):focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

.site-header { border-bottom: 1px solid #d9d4c7; }
.header-inner {
    width: min(1120px, calc(100% - 56px));
    margin: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 64px;
}
.brand { color: #161c33; text-decoration: none; }
.brand strong { color: var(--blue); }
.site-header nav a { font-size: .84rem; font-weight: 650; }

.layout {
    width: min(1120px, calc(100% - 56px));
    margin: auto;
    padding: clamp(36px, 7vh, 80px) 0 48px;
    display: grid;
    grid-template-columns: minmax(240px, .72fr) minmax(420px, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "intro repair" "guide repair" "carousel carousel";
    align-items: start;
    gap: 34px clamp(30px, 6vw, 90px);
}
.intro { grid-area: intro; padding-top: 19px; }
.intro .eyebrow { margin: 0 0 18px; color: var(--blue); font-size: .73rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.intro h1 { margin: 0; font-size: clamp(3.1rem, 6vw, 6rem); line-height: .94; letter-spacing: -.075em; }
.intro h1 em { display: block; color: var(--blue); font-style: normal; }
.intro p { max-width: 30ch; margin: 19px 0 0; color: #464b62; line-height: 1.55; font-size: 1.03rem; }
.guide { grid-area: guide; border-top: 1px solid #d9d4c7; padding-top: 21px; }
.guide h2 { margin: 0 0 8px; font-size: 1rem; }
.guide p { margin: 0 0 10px; color: #484d62; font-size: .9rem; line-height: 1.53; }
.guide summary { margin-top: 18px; color: var(--blue); font-weight: 650; font-size: .88rem; }
.guide details p { margin: 9px 0 0; }
.guide .related-game { margin-top: 14px; }

.repair {
    grid-area: repair;
    min-width: 0;
    padding: clamp(18px, 4vw, 33px);
    border-radius: 19px;
    color: #f5f6ff;
    background: radial-gradient(ellipse at top right, #30305d, transparent 65%), var(--panel);
    border: 1px solid #464c77;
    box-shadow: 0 18px 38px #25264727;
}
.stage-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.repair-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 16px; border-bottom: 1px solid #4b5275; }
.mission-label { color: var(--mint); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.fullscreen-toggle { flex-shrink: 0; }
.mission-progress { margin: 18px 0 22px; }
.mission-progress label { display: flex; justify-content: space-between; gap: 12px; color: var(--quiet); font-size: .75rem; }
.mission-progress strong { color: var(--mint); }
.mission-progress progress { display: block; width: 100%; height: 7px; margin-top: 9px; appearance: none; border: 0; border-radius: 8px; overflow: hidden; background: #343e62; accent-color: var(--mint); }
.mission-progress progress::-webkit-progress-bar { background: #343e62; }
.mission-progress progress::-webkit-progress-value { background: var(--mint); }
.mission-progress progress::-moz-progress-bar { background: var(--mint); }
.board-legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 16px; margin: 18px 0 12px; font-size: .73rem; color: var(--quiet); }
.board-legend span { display: inline-flex; align-items: center; gap: 6px; }
.board-legend i { display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid #7380a2; border-radius: 3px; font-style: normal; font-size: .65rem; }
.legend-dark { background: #080d20; }
.legend-light { background: #f6f7f5; }
.legend-missing { background: #2d4463; color: var(--mint); }
.fill-progress { margin: 10px 0; color: var(--mint); font-size: .78rem; font-weight: 650; }
.repair:is(:fullscreen, .is-expanded) { width: 100%; height: 100%; max-width: none; overflow: auto; border: 0; border-radius: 0; padding: max(20px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); }
.repair.is-expanded { position: fixed; inset: 0; z-index: 20; height: 100dvh; }
body:has(.repair.is-expanded) { overflow: hidden; }
.repair:is(:fullscreen, .is-expanded) > * { width: 100%; max-width: 1280px; margin-inline: auto; }
.repair:is(:fullscreen, .is-expanded) .board { width: min(100%, 640px); }
.repair:is(:fullscreen, .is-expanded) .stage-header { margin-top: 22px; }
.stage-count { margin: 0 0 5px; color: var(--mint); font-size: .77rem; font-weight: 700; }
.repair h2 { margin: 0; font-size: clamp(1.2rem, 3vw, 1.67rem); line-height: 1.12; }
.stage-mode { font-size: .73rem; font-weight: 700; color: #dde1fa; border: 1px solid #5a638a; padding: 6px 8px; border-radius: 5px; }
.rule, .board-help, .finished > p { color: var(--quiet); font-size: .88rem; line-height: 1.45; }
.rule { margin: 12px 0 13px; }
.board-help { margin: 12px 0 6px; }
.board-help strong { color: var(--mint); }

.board { width: min(100%, 384px); margin: auto; table-layout: fixed; border-spacing: 4px; }
.board :is(th, td) { padding: 0; }
.clue {
    text-align: center;
    color: #e4e8ff;
    font-size: .76rem;
    font-weight: 700;
    border-radius: 4px;
    background: #2a3457;
}
.board thead th { height: 26px; }
.clue[data-invalid="true"] { color: #301829; background: #ffc0a9; }
.tile {
    display: grid;
    place-items: center;
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #7380a2;
    border-radius: 3px;
    font-size: 1.1rem;
    font-weight: 800;
    padding: 0;
}
.tile[data-fill="1"] { background: #080d20; color: var(--mint); }
.tile[data-fill="0"] { background: #f6f7f5; color: #214334; }
button.tile { border: 2px solid #53ac8a; }
button.tile[data-fill="empty"] { color: #baffdd; background: repeating-linear-gradient(135deg, #243959 0 7px, #2d4463 7px 10px); }
button.tile:hover:not(:disabled) { border-color: var(--mint); }
button.tile:focus-visible { outline-color: var(--mint); outline-offset: 1px; }
button.tile:disabled { border-color: #718fa0; }

.status { margin: 0; min-height: 2.55em; padding: 5px 0; color: var(--quiet); font-size: .86rem; line-height: 1.35; }
.status:empty { min-height: 0; padding: 0; }
.status[data-tone="success"] { color: var(--mint); }
.status[data-tone="error"] { color: #ffc0a9; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.actions > button { flex: 1 1 150px; }
.primary, .secondary { min-height: 46px; padding: 11px 16px; border-radius: 10px; font-size: .9rem; font-weight: 700; }
.primary { color: #10291f; background: var(--mint); border: 1px solid var(--mint); }
.primary:hover { background: #c5ffe0; }
.secondary { color: #e3e7fc; background: #273052; border: 1px solid #657298; }
.secondary:hover:not(:disabled) { background: #323f66; }
.secondary:disabled { opacity: .55; }
.repair :is(.primary, .secondary):focus-visible { outline-color: var(--mint); }
.finished { text-align: center; padding: 14px 0 4px; }
.finished canvas { display: block; width: min(100%, 290px); height: auto; margin: 19px auto 13px; image-rendering: pixelated; }
.finished .decoded strong { color: var(--mint); }

@media (max-width: 800px) {
    .header-inner, .layout { width: min(600px, calc(100% - 36px)); }
    .layout { grid-template-columns: 1fr; grid-template-rows: auto; grid-template-areas: "intro" "repair" "guide" "carousel"; gap: 22px; padding-top: 25px; }
    .intro { padding: 0; }
    .intro h1 { font-size: clamp(2.65rem, 8.5vw, 4.4rem); }
    .intro h1 em { display: inline; }
    .intro p { max-width: 48ch; margin-top: 11px; }
}

@media (max-width: 395px) {
    .header-inner, .layout { width: calc(100% - 24px); }
    .repair { padding: 14px; border-radius: 13px; }
    .board { border-spacing: 3px; }
    .clue { font-size: .68rem; }
}

@media (min-width: 960px) {
    .header-inner, .layout { width: min(1600px, calc(100% - 80px)); }
    .header-inner { min-height: 78px; font-size: 1.15rem; }
    .site-header nav a { font-size: 1.05rem; }
    .layout { grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); gap: 28px clamp(32px, 4vw, 64px); padding-top: 36px; }
    .intro .eyebrow { font-size: .95rem; }
    .intro p { font-size: 1.25rem; line-height: 1.65; }
    .guide h2 { font-size: 1.35rem; }
    .guide p, .guide summary { font-size: 1.12rem; line-height: 1.65; }
    .repair { padding: clamp(24px, 2.5vw, 40px); }
    .repair h2 { font-size: 2rem; }
    .repair .mission-label, .repair .mission-progress label, .repair .stage-count, .repair .stage-mode { font-size: 1rem; }
    .repair .rule, .repair .board-help, .repair .finished > p, .repair .status { font-size: 1.2rem; line-height: 1.55; }
    .repair .board-legend, .repair .fill-progress { font-size: 1.05rem; }
    .repair .board-legend i { width: 21px; height: 21px; font-size: .9rem; }
    .repair .board { width: min(100%, 540px); border-spacing: 5px; }
    .repair .clue { font-size: 1.1rem; }
    .repair .board thead th { height: 34px; }
    .repair .tile { font-size: 1.6rem; }
    .repair .primary, .repair .secondary { min-height: 56px; font-size: 1.12rem; }
    .repair:is(:fullscreen, .is-expanded) { padding: clamp(20px, 3vh, 36px) clamp(24px, 4vw, 72px); }
    .repair:is(:fullscreen, .is-expanded) > * { max-width: 1600px; }
    .repair:is(:fullscreen, .is-expanded) #puzzle {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(360px, 480px);
        grid-template-areas: "board heading" "board rule" "board legend" "board help" "board filled" "board status" "board actions";
        gap: 14px clamp(28px, 4vw, 64px);
        align-content: center;
        align-items: start;
        min-height: calc(100dvh - 190px);
    }
    .repair:is(:fullscreen, .is-expanded) .board { grid-area: board; align-self: center; width: min(100%, 760px, calc(100dvh - 190px)); border-spacing: 6px; }
    .repair:is(:fullscreen, .is-expanded) .stage-header { grid-area: heading; margin: 0; }
    .repair:is(:fullscreen, .is-expanded) .stage-count { font-size: 1.2rem; margin-bottom: 10px; }
    .repair:is(:fullscreen, .is-expanded) h2 { font-size: clamp(2rem, 2.5vw, 2.8rem); }
    .repair:is(:fullscreen, .is-expanded) .rule { grid-area: rule; margin: 0; font-size: 1.4rem; line-height: 1.55; }
    .repair:is(:fullscreen, .is-expanded) .board-legend { grid-area: legend; justify-content: flex-start; margin: 0; padding-block: 12px; font-size: 1.1rem; }
    .repair:is(:fullscreen, .is-expanded) .board-help { grid-area: help; margin: 0; font-size: 1.3rem; line-height: 1.55; }
    .repair:is(:fullscreen, .is-expanded) .fill-progress { grid-area: filled; margin: 0; font-size: 1.2rem; }
    .repair:is(:fullscreen, .is-expanded) .status { grid-area: status; font-size: 1.2rem; }
    .repair:is(:fullscreen, .is-expanded) .actions { grid-area: actions; flex-direction: column; margin: 0; }
    .repair:is(:fullscreen, .is-expanded) .actions > button { flex: none; min-height: 64px; font-size: 1.25rem; }
    .repair:is(:fullscreen, .is-expanded) .clue { font-size: 1.3rem; }
    .repair:is(:fullscreen, .is-expanded) .board thead th { height: 34px; }
    .repair:is(:fullscreen, .is-expanded) .tile { font-size: 1.7rem; border-radius: 6px; }
}

.games-carousel { --ink: #f8f5ff; --mint: #7fffe0; --violet: #ba9cff; --muted: #c5bdd8; --line: #d9d4c7; }
.games-carousel .carousel-catalog { color: var(--blue); }
.games-carousel .carousel-status { color: #484d62; }

.qr-mission-page .instagram-prompt::backdrop {
    background:
        radial-gradient(ellipse at center, #ffffff66, #f5f5f5cc),
        repeating-conic-gradient(#ffffff 0% 25%, #dce0e7 0% 50%) 0 0 / 48px 48px;
    backdrop-filter: blur(3px);
}

.qr-mission-page .instagram-prompt {
    --ink: #18213b;
    --mint: #17634d;
    --violet: #6442ac;
    color-scheme: light;
    border-color: #d1d5e2;
    background:
        linear-gradient(135deg, #fffffff2, #f6f5fbef),
        repeating-conic-gradient(#dce0e7 0% 25%, #ffffff 0% 50%) 0 0 / 28px 28px;
    box-shadow: 0 26px 86px #25305038;
}
.qr-mission-page .instagram-prompt h2 span { color: #6442ac; }
.qr-mission-page .instagram-prompt #instagram-description { color: #525b73; }
.qr-mission-page .reel-carousel__track { scrollbar-color: #9b8bb8 transparent; }
.qr-mission-page .reel-card { background: #ffffff; border-color: #d1c9df; }
.qr-mission-page .reel-card:hover { background: #f1edf9; border-color: #8767bc; }
.qr-mission-page .instagram-prompt__actions .console-button { color: #35274e; background: #eee8f7; border-color: #a896c2; }
.qr-mission-page .instagram-prompt__actions .console-button:hover { background: #e1d6f1; }
