/* ==========================================================================
   Noos Alibi - lobby and board.
   ========================================================================== */
:root { --bg: #f8fafc; --accent: #88b04b; --dark: #1e293b; --user-text: #6366f1; --clash: #fee2e2; --grid-line: #cbd5e1; --note-color: #475569; --diagonal: #e2e8f0;
        --muted: #64748b; --card: #ffffff; --edge: #e2e8f0; --easy: #88b04b; --medium: #f59e0b; --hard: #ef4444; --extreme: #7c3aed; }
body.alibi-page { margin: 0; font-family: 'Quicksand', sans-serif; background: var(--bg); color: var(--dark); animation: pageFade 0.4s ease-out; }
@keyframes pageFade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------- LOBBY */
.alb-wrap { max-width: 960px; margin: 28px auto 60px; padding: 0 18px; }
.alb-hero { text-align: center; margin-bottom: 26px; }
.alb-hero h1 { margin: 0 0 6px; font-size: clamp(26px, 5vw, 36px); font-weight: 700; letter-spacing: -0.5px; }
.alb-hero p { margin: 0 auto; color: var(--muted); max-width: 520px; font-weight: 500; line-height: 1.5; }
.alb-hero-actions { margin-top: 18px; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.alb-btn { display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px; border-radius: 14px; border: 2px solid var(--edge); background: var(--card); color: var(--dark);
           font: 700 14px 'Quicksand', sans-serif; text-decoration: none; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
.alb-btn:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.05); }
.alb-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.alb-btn.primary:hover { box-shadow: 0 8px 20px rgba(136,176,75,.35); }
.alb-btn.small { padding: 8px 14px; font-size: 13px; border-radius: 11px; }

.alb-resume { background: linear-gradient(135deg, #fffbeb, #fff7ed); border: 2px solid #fde68a; border-radius: 20px; padding: 16px 18px; margin-bottom: 26px; }
.alb-resume h2 { margin: 0 0 10px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #b45309; }
.alb-resume-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.alb-resume-card { flex: 0 0 auto; background: #fff; border: 2px solid #fde68a; border-radius: 14px; padding: 10px 14px; text-decoration: none; color: var(--dark); min-width: 128px; }
.alb-resume-card:hover { border-color: var(--medium); }
.alb-resume-card b { display: block; font-size: 14px; }
.alb-resume-card span { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .4px; }

.alb-section { margin-bottom: 30px; }
.alb-section-head { display: flex; align-items: baseline; gap: 10px; margin: 0 4px 12px; }
.alb-section-head h2 { margin: 0; font-size: 19px; font-weight: 700; }
.alb-section-head span { color: var(--muted); font-size: 13px; font-weight: 500; }
.alb-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.alb-tile { position: relative; display: flex; flex-direction: column; background: var(--card); border: 2px solid transparent; border-radius: 22px; padding: 16px 16px 14px; text-decoration: none; color: inherit;
            box-shadow: 0 4px 14px rgba(15,23,42,.04); transition: transform .18s, border-color .18s, box-shadow .18s; }
.alb-tile:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: 0 12px 26px rgba(15,23,42,.08); }
.alb-tile-art { background: #f1f5f9; border-radius: 16px; padding: 8px; margin-bottom: 12px; }
.alb-tile-art svg { display: block; width: 100%; height: auto; max-height: 118px; }
.alb-tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.alb-tile h3 { margin: 0; font-size: 18px; font-weight: 700; }
.alb-tag { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #f1f5f9; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.alb-tile p { margin: 6px 0 12px; font-size: 13px; line-height: 1.45; color: var(--muted); font-weight: 500; flex: 1; }
.alb-progress { height: 7px; background: #eef2f7; border-radius: 99px; overflow: hidden; }
.alb-progress i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width .6s ease; }
.alb-count { margin-top: 7px; display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); }

/* ------------------------------------------------------- VARIANT PAGE */
.alb-crumb { display: inline-block; margin: 0 0 14px 2px; color: #94a3b8; font-size: 13px; font-weight: 600; text-decoration: none; }
.alb-crumb:hover { color: var(--accent); }
.alb-variant { display: grid; grid-template-columns: 150px 1fr; gap: 22px; align-items: center; background: var(--card); border-radius: 24px; padding: 20px; box-shadow: 0 4px 14px rgba(15,23,42,.04); margin-bottom: 18px; }
.alb-variant .alb-tile-art { margin: 0; }
.alb-variant h1 { margin: 0 0 4px; font-size: 28px; font-weight: 700; }
.alb-variant .alb-rule { margin: 0 0 12px; color: var(--muted); font-weight: 500; line-height: 1.5; font-size: 14px; }
.alb-variant-stats { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
@media (max-width: 560px) { .alb-variant { grid-template-columns: 1fr; } .alb-variant .alb-tile-art { max-width: 150px; } }

.alb-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.alb-tab { flex: 1 1 110px; text-decoration: none; color: inherit; background: var(--card); border: 2px solid var(--edge); border-radius: 16px; padding: 10px 12px 9px; text-align: center; transition: border-color .15s, transform .15s; }
.alb-tab:hover { transform: translateY(-2px); }
.alb-tab b { display: block; font-size: 13px; text-transform: capitalize; }
.alb-tab small { display: block; font-size: 11px; font-weight: 700; color: var(--muted); margin-top: 2px; }
.alb-tab .alb-progress { margin-top: 7px; height: 5px; }
.alb-tab.active { border-color: var(--dark); background: #fff; box-shadow: 0 6px 16px rgba(15,23,42,.07); }
.alb-tab[data-d="easy"] .alb-progress i { background: var(--easy); } .alb-tab[data-d="medium"] .alb-progress i { background: var(--medium); }
.alb-tab[data-d="hard"] .alb-progress i { background: var(--hard); } .alb-tab[data-d="extreme"] .alb-progress i { background: var(--extreme); }

.alb-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.alb-toolbar .spacer { flex: 1; }
.alb-select { padding: 9px 12px; border-radius: 11px; border: 2px solid var(--edge); background: var(--card); font: 600 13px 'Quicksand', sans-serif; color: var(--dark); }

.alb-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 9px; }
.alb-chip { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; padding: 11px 4px 9px; background: var(--card); border: 2px solid var(--edge); border-radius: 14px;
            text-decoration: none; color: var(--dark); font-weight: 700; font-size: 15px; transition: transform .12s, border-color .12s; }
.alb-chip:hover { transform: translateY(-2px); border-color: var(--accent); }
.alb-chip em { font-style: normal; width: 22px; height: 4px; border-radius: 3px; background: var(--dc, #94a3b8); }
.alb-chip.is-completed { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alb-chip.is-completed::after { content: '✓'; position: absolute; top: 3px; right: 6px; font-size: 11px; color: #16a34a; }
.alb-chip.is-progressing { background: #fffbeb; border-color: #fcd34d; }
.alb-chip.is-progressing::after { content: '…'; position: absolute; top: -2px; right: 7px; font-size: 16px; color: #d97706; font-weight: 800; }
.alb-empty { text-align: center; color: var(--muted); padding: 40px 10px; font-weight: 600; }

.alb-pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 26px; }
.alb-pager a, .alb-pager span { min-width: 38px; padding: 9px 12px; text-align: center; border-radius: 11px; border: 2px solid var(--edge); background: var(--card); font-weight: 700; font-size: 13px; color: var(--dark); text-decoration: none; }
.alb-pager a:hover { border-color: var(--accent); }
.alb-pager .cur { background: var(--dark); border-color: var(--dark); color: #fff; }
.alb-pager .gap { border: none; background: none; min-width: 0; padding: 9px 2px; color: #94a3b8; }


/* --------------------------------------------------------- HOW IT WORKS */
.alb-how { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 24px; }
.alb-how > div { background: var(--card); border-radius: 18px; padding: 14px 16px; box-shadow: 0 4px 14px rgba(15,23,42,.04); }
.alb-how b { display: block; font-size: 14px; margin-bottom: 4px; }
.alb-how span { font-size: 13px; line-height: 1.45; color: var(--muted); font-weight: 500; }
.alb-how i { font-style: normal; font-size: 22px; display: block; margin-bottom: 4px; }
@media (max-width: 640px) { .alb-how { grid-template-columns: 1fr; } }
.alb-tab small em { font-style: normal; opacity: .75; }

/* ------------------------------------------------------------ THE BOARD
   One-screen layout: alibi.js measures the space under the site header and sets --board (square size)
   and the height of .alb-play, so the page never scrolls. Wide screens put the board left and controls +
   clues right; narrow screens stack board, controls, then a clue list that scrolls inside its own box. */
html:has(body.alibi-playing), body.alibi-playing { overflow: hidden; overscroll-behavior: none; }
body.alibi-page { --board: min(94vw, 520px); }
.alb-play { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 10px; box-sizing: border-box; max-width: 1180px; margin: 0 auto; height: calc(100dvh - 76px); overflow: hidden; padding-top: 6px; }
.alb-boardcol { flex: 0 0 auto; width: var(--board); }
.alb-side { display: flex; flex-direction: column; gap: 8px; flex: 1 1 0; min-height: 0; width: min(100%, 560px); }
.alb-play.wide { flex-direction: row; justify-content: center; align-items: flex-start; gap: 22px; }
.alb-play.wide .alb-side { flex: 0 1 520px; height: 100%; width: auto; }

.alb-board { position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr); width: var(--board); height: var(--board); border: 3px solid var(--dark); border-radius: 10px; background: #fff; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: manipulation; box-sizing: border-box; }
.alb-cell { position: relative; display: flex; align-items: center; justify-content: center; background: var(--room, #fff); border-right: 1px solid rgba(30,41,59,.14); border-bottom: 1px solid rgba(30,41,59,.14); cursor: pointer; box-sizing: border-box; min-width: 0; min-height: 0; transition: background-color .12s; }
.alb-cell:hover { filter: brightness(.96); }
.alb-cell.bad { background-image: linear-gradient(rgba(239,68,68,.28), rgba(239,68,68,.28)); }
.alb-cell.glow { box-shadow: inset 0 0 0 3px #f59e0b; z-index: 3; animation: albPulse 1s ease-in-out 2; }
.alb-cell.glow-room { box-shadow: inset 0 0 0 3px #f59e0b; z-index: 3; }
.alb-cell.glow-room.glow { z-index: 4; }
@keyframes albPulse { 50% { box-shadow: inset 0 0 0 5px #f59e0b; } }

/* room names: one pill per room, sized by JS to fit the room's widest row of squares */
.alb-labels { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.alb-rl { position: absolute; display: flex; justify-content: center; align-items: flex-start; text-align: center; font-weight: 800; line-height: 1.05; letter-spacing: .1px; color: #1e293b; padding-top: 2px; box-sizing: border-box;
          text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #fff; }
.alb-cell.under-label .alb-badge { margin-top: 12%; width: 66%; height: 66%; }
.alb-cell.under-label .alb-item { transform: translateY(14%); }

.alb-item { font-size: calc(var(--board) / var(--n) * .46); line-height: 1; pointer-events: none; filter: drop-shadow(0 1px 0 rgba(255,255,255,.6)); }
.alb-cell.has-s .alb-item { position: absolute; right: 2px; bottom: 1px; font-size: calc(var(--board) / var(--n) * .24); opacity: .85; transform: none; }
.alb-victim { font-size: calc(var(--board) / var(--n) * .5); pointer-events: none; }
.alb-cell.is-victim { box-shadow: inset 0 0 0 2px #b91c1c; }
.alb-cell.is-victim .alb-item { position: absolute; right: 2px; bottom: 1px; font-size: calc(var(--board) / var(--n) * .22); transform: none; }
.alb-badge { width: 74%; height: 74%; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--c); color: #fff; font-weight: 800; font-size: calc(var(--board) / var(--n) * .3); letter-spacing: -.5px; box-shadow: 0 2px 6px rgba(0,0,0,.25), inset 0 0 0 2px rgba(255,255,255,.55); pointer-events: none; animation: albPop .18s ease-out; }
@keyframes albPop { from { transform: scale(.4); } to { transform: scale(1); } }
.alb-badge.hinted { box-shadow: 0 0 0 3px #88b04b, 0 2px 6px rgba(0,0,0,.25); }
.alb-x { font-size: calc(var(--board) / var(--n) * .5); color: rgba(30,41,59,.38); font-weight: 700; pointer-events: none; line-height: 1; }
.alb-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 5; }
.alb-overlay path { stroke: var(--dark); stroke-width: 3px; stroke-linecap: square; fill: none; vector-effect: non-scaling-stroke; }

.alb-hint-line { text-align: center; color: var(--muted); font-size: 12px; font-weight: 700; margin-top: 5px; height: 17px; line-height: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* controls */
.alb-controls { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.alb-tray { display: grid; grid-template-columns: repeat(auto-fit, minmax(30px, 1fr)); gap: 5px; max-width: 100%; }
.alb-chip { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 3px; background: var(--card); border: 2px solid var(--edge); border-radius: 99px; font: 700 11px 'Quicksand', sans-serif; color: var(--dark); cursor: pointer; transition: transform .12s, border-color .12s; min-width: 0; }
.alb-chip:hover { transform: translateY(-1px); }
.alb-chip .dot { flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%; background: var(--c); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.alb-chip .nm { display: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }
.alb-chip.sel { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, #fff); }
.alb-chip.placed { opacity: .45; }
.alb-chip.placed.sel { opacity: 1; }
.alb-chip.xtool { --c: #94a3b8; }
.alb-chip.xtool .dot { font-size: 13px; }
.alb-play.wide .alb-tray { grid-template-columns: repeat(2, 1fr); }
.alb-play.wide .alb-chip { justify-content: flex-start; }
.alb-play.wide .alb-chip .nm { display: block; }

.alb-actions { display: flex; gap: 4px; justify-content: center; background: #fff; border-radius: 16px; padding: 4px 6px; box-shadow: 0 4px 14px rgba(15,23,42,.04); }
.alb-act { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; background: none; border: none; font: 700 10.5px 'Quicksand', sans-serif; color: var(--muted); cursor: pointer; padding: 3px 2px; border-radius: 12px; white-space: nowrap; }
.alb-act:hover { background: #f1f5f9; }
.alb-act svg { width: 19px; height: 19px; }
.alb-act.accent { color: var(--accent); }

/* case file: scrolls inside its own box, so the page itself never has to */
.alb-case { flex: 1 1 0; min-height: 0; overflow-y: auto; background: var(--card); border-radius: 18px; padding: 12px 14px; box-shadow: 0 6px 20px rgba(15,23,42,.06); -webkit-overflow-scrolling: touch; }
.alb-case h2 { margin: 0 0 2px; font-size: 16px; font-weight: 700; }
.alb-story { margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; color: var(--muted); font-weight: 500; }
.alb-story b { color: var(--dark); }
.alb-clues { list-style: none; margin: 0; padding: 0; counter-reset: c; columns: 2 230px; column-gap: 10px; }
.alb-clue { display: flex; gap: 8px; align-items: flex-start; padding: 5px 6px; border-radius: 10px; font-size: 12.5px; line-height: 1.35; font-weight: 600; cursor: pointer; counter-increment: c; break-inside: avoid; }
.alb-clue::before { content: counter(c); flex: 0 0 20px; height: 20px; border-radius: 50%; background: #f1f5f9; color: var(--muted); font-size: 10.5px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin-top: 0; }
.alb-clue:hover { background: #f8fafc; }
.alb-clue .who { color: var(--c, var(--dark)); font-weight: 800; white-space: nowrap; }
.alb-clue .who i { display: inline-flex; align-items: center; justify-content: center; width: 15px; height: 15px; margin-right: 3px; border-radius: 50%; background: var(--c); color: #fff; font-style: normal; font-size: 7.5px; font-weight: 800; vertical-align: -3px; }
.alb-clue.ok::before { content: '✓'; background: #dcfce7; color: #15803d; }
.alb-clue.no::before { content: '✕'; background: #fee2e2; color: #dc2626; }
.alb-clue.no { background: #fef2f2; }
.alb-clue.struck span { text-decoration: line-through; opacity: .5; }
.alb-verdict { margin-top: 10px; padding: 10px 12px; border-radius: 14px; background: #fef2f2; border: 2px solid #fecaca; font-size: 13px; font-weight: 700; line-height: 1.45; display: none; }
.alb-verdict.show { display: block; }
.alb-verdict b { color: #b91c1c; }
@media (max-width: 420px) { .alb-clues { columns: 1; } .alb-story { font-size: 12px; margin-bottom: 4px; } }

.alb-play.compact .alb-chip .nm { display: none; }
.alb-play.compact .alb-tray { grid-template-columns: repeat(auto-fit, minmax(30px, 1fr)); }
.alb-play.compact .alb-chip { justify-content: center; }
.alb-play.wide .alb-case { min-height: 0; }
