:root {
  --bg: #FFF7EC;
  --ink: #221A14;
  --muted: #8A7B6E;
  --card: #FFFFFF;
  --line: #EFE3D3;
  --brand: #5B4BDB;
  --brand-ink: #FFFFFF;
  --yes: #1E9E5A;
  --no: #E5484D;
  --warn: #F5A524;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .07);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
main { padding: 16px 16px calc(24px + var(--safe-b)); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 20px 0 8px; }
.dim { color: var(--muted); }
.small { font-size: 13px; }

/* buttons */
.btn { appearance: none; border: 0; background: var(--card); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); border-radius: 14px; padding: 12px 16px; font-weight: 700; cursor: pointer; transition: transform .12s ease, opacity .2s; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 6px 16px rgba(91, 75, 219, .32); }
.btn.big { width: 100%; padding: 16px; font-size: 18px; border-radius: 16px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--muted); width: 100%; margin-top: 8px; }
.row { display: flex; gap: 10px; }
.row > .btn { flex: 1; }

/* home */
.home { display: flex; flex-direction: column; gap: 14px; padding-top: 32px; }
.strip { display: flex; justify-content: center; gap: 6px; }
.strip .mini { width: 52px; height: 52px; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); transform: rotate(var(--r, 0deg)); }
.strip .mini:nth-child(odd) { --r: -5deg; }
.strip .mini:nth-child(even) { --r: 4deg; margin-top: 8px; }
.logo { font-size: 52px; font-weight: 900; text-align: center; letter-spacing: -.03em; margin-top: 8px; color: var(--brand); }
.tag { text-align: center; color: var(--muted); margin: -6px 8px 10px; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14px; color: var(--muted); }
input { font: inherit; font-size: 18px; padding: 14px 16px; border-radius: 14px; border: 0; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--ink); width: 100%; outline: none; }
input:focus { box-shadow: inset 0 0 0 2px var(--brand); }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 6px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.joinrow { display: flex; gap: 10px; }
.codein { text-transform: uppercase; letter-spacing: .3em; font-weight: 800; text-align: center; }
.joinrow .btn { padding: 0 22px; }

/* lobby */
.codebox { background: var(--card); border-radius: 22px; box-shadow: var(--shadow); padding: 18px; text-align: center; }
.codebox .lbl { font-size: 13px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.bigcode { font-size: 64px; font-weight: 900; letter-spacing: .14em; color: var(--brand); margin: 2px 0 10px; padding-left: .14em; }
.plist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.plist li { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 14px; padding: 10px 12px; box-shadow: var(--shadow); }
.plist li.off { opacity: .5; }
.pname { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pname em { font-style: normal; color: var(--muted); font-weight: 600; }
.badge { font-size: 12px; font-weight: 800; color: var(--brand); background: #ECE9FF; border-radius: 99px; padding: 3px 9px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 900; color: #fff; background: hsl(var(--h) 65% 55%); flex: none; }
.avatar.sm { width: 30px; height: 30px; font-size: 14px; }
.avatar.xs { width: 24px; height: 24px; font-size: 12px; }
.segs { display: flex; gap: 6px; background: #F3E9DB; padding: 4px; border-radius: 14px; }
.seg { flex: 1; border: 0; background: transparent; padding: 10px 0; border-radius: 10px; font-weight: 800; color: var(--muted); }
.seg.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.lobby > .btn.primary { margin-top: 22px; }
.waiting { text-align: center; color: var(--muted); padding: 18px 8px; font-weight: 600; }
.rules { margin-top: 18px; background: var(--card); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); }
.rules summary { font-weight: 800; cursor: pointer; }
.rules ol { padding-left: 20px; margin: 10px 0 4px; display: grid; gap: 8px; font-size: 15px; }

/* game */
.bar { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(255, 247, 236, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.pill { border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 99px; padding: 7px 12px; font-weight: 800; font-size: 14px; white-space: nowrap; }
button.pill { cursor: pointer; }
.peekbtn { background: #221A14; color: #fff; }
.game { padding-top: 12px; }
.game.my-turn { padding-bottom: calc(110px + var(--safe-b)); }
.game.has-sheet { padding-bottom: calc(360px + var(--safe-b)); }
.hunt { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 600; }
.hunt.me { background: #221A14; color: #fff; padding: 12px 14px; border-radius: 16px; font-size: 18px; }
.turn { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 14px; border-radius: 14px; background: var(--card); box-shadow: var(--shadow); font-weight: 700; }
.turn.mine { background: var(--brand); color: #fff; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(91, 75, 219, .18); } }
.timer { position: relative; height: 8px; background: #F0E4D4; border-radius: 99px; margin: 8px 40px 0 0; }
.timer .fill { height: 100%; width: 100%; background: var(--yes); border-radius: 99px; transition: background .3s; }
.timer .fill.low { background: var(--no); }
.timer span { position: absolute; right: -40px; top: -6px; font-size: 13px; font-weight: 800; color: var(--muted); width: 34px; text-align: right; }
.note { margin-top: 10px; padding: 10px 14px; border-radius: 14px; background: #FFF0C9; font-weight: 600; font-size: 15px; }
.note.warn { background: #FFE1E1; }
.counts { margin: 14px 2px 8px; color: var(--muted); font-weight: 600; font-size: 14px; }
.counts b { color: var(--ink); font-size: 18px; }

.board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 480px) { .board { grid-template-columns: repeat(6, 1fr); } }
.tile { position: relative; border: 0; padding: 0; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; cursor: default; transition: transform .2s ease, opacity .35s ease, filter .35s ease; }
.tile .face { aspect-ratio: 1; }
.tile .face svg { display: block; width: 100%; height: 100%; }
.tile .nm { font-size: 12px; font-weight: 800; padding: 3px 2px 5px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.out { opacity: .28; filter: grayscale(1); transform: scale(.94); }
.tile.out::after { content: ""; position: absolute; inset: 0; background:
  linear-gradient(45deg, transparent calc(50% - 2px), rgba(229, 72, 77, .85) calc(50% - 2px), rgba(229, 72, 77, .85) calc(50% + 2px), transparent calc(50% + 2px)),
  linear-gradient(-45deg, transparent calc(50% - 2px), rgba(229, 72, 77, .85) calc(50% - 2px), rgba(229, 72, 77, .85) calc(50% + 2px), transparent calc(50% + 2px)); }
.tile.fresh { animation: knock .9s ease both; }
@keyframes knock { 0% { opacity: 1; filter: none; transform: scale(1); } 35% { transform: scale(1.08) rotate(-4deg); opacity: 1; filter: none; } 100% { opacity: .28; filter: grayscale(1); transform: scale(.94); } }
.tile.pickable { cursor: pointer; box-shadow: var(--shadow), inset 0 0 0 2px #CFC6FF; }
.tile.pickable:active { transform: scale(.95); }
.tile.picked { box-shadow: 0 0 0 3px var(--brand), 0 8px 18px rgba(91, 75, 219, .35); transform: scale(1.04); z-index: 1; }
.tile.reveal { box-shadow: 0 0 0 3px var(--yes); transform: scale(1.06); z-index: 1; }

.logh { margin: 22px 2px 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.log { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; font-size: 14px; }
.log li { background: var(--card); border-radius: 12px; padding: 9px 12px; box-shadow: var(--shadow); }
.log i { font-style: normal; color: #4A3F36; }
.ans { display: inline-block; font-weight: 900; font-size: 12px; padding: 2px 7px; border-radius: 6px; color: #fff; margin: 0 2px; }
.ans.yes { background: var(--yes); }
.ans.no { background: var(--no); }

/* bottom actions */
.actions, .sheet { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 10; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -8px 30px rgba(60, 40, 20, .16); padding: 14px 14px calc(14px + var(--safe-b)); animation: up .22s ease; }
@keyframes up { from { transform: translate(-50%, 30px); opacity: 0; } }
.actions .btn.big { font-size: 20px; }
.btn.ask { background: #221A14; color: #fff; }
.hint { text-align: center; font-weight: 800; color: var(--yes); margin-bottom: 10px; }
.sheethead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 18px; }
.x { border: 0; background: #F3E9DB; width: 34px; height: 34px; border-radius: 50%; font-weight: 800; cursor: pointer; }
.qscroll { max-height: min(46dvh, 340px); overflow-y: auto; margin: 0 -4px 12px; padding: 0 4px; }
.qgroup { margin-bottom: 10px; }
.glabel { font-size: 12px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 0; background: #F3E9DB; padding: 9px 13px; border-radius: 99px; font-weight: 700; font-size: 15px; cursor: pointer; }
.chip.on { background: var(--brand); color: #fff; }
.chip:disabled { opacity: .35; text-decoration: line-through; cursor: not-allowed; }
.sheet .btn.big { font-size: 16px; }
.guessrow { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 18px; }
.guessrow .mini, .hist .mini { width: 56px; height: 56px; border-radius: 12px; overflow: hidden; flex: none; }

/* modals and overlays */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(34, 26, 20, .45); display: grid; place-items: center; padding: 18px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.card { background: var(--card); border-radius: 24px; padding: 22px 18px; width: 100%; max-width: 420px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); max-height: 92dvh; overflow-y: auto; }
.card h2 { font-size: 28px; margin: 4px 0; }
.card p { margin: 4px 0 12px; }
.card .btn { margin-top: 14px; width: 100%; }
.pop { animation: pop .35s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.big-emoji { font-size: 48px; line-height: 1; }
.revealface { width: 150px; margin: 10px auto; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow), 0 0 0 4px var(--yes); }
.revealface svg { display: block; width: 100%; }
.revealface .nm { font-weight: 900; padding: 6px; font-size: 18px; }
.pts { font-weight: 800; color: var(--yes); margin-bottom: 8px; }
.scores { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; text-align: left; }
.scores li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 12px; background: #FBF5EC; }
.scores li.me { box-shadow: inset 0 0 0 2px var(--brand); }
.scores li.off { opacity: .55; }
.scores .rank { width: 22px; font-weight: 900; color: var(--muted); text-align: center; }
.scores .score { font-weight: 900; font-size: 18px; }

.splash { position: fixed; z-index: 30; left: 50%; top: 42%; transform: translate(-50%, -50%); width: min(88vw, 400px); border-radius: 28px; padding: 20px; text-align: center; color: #fff; pointer-events: none; animation: splash 2.1s ease both; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.splash.yes { background: var(--yes); }
.splash.no { background: var(--no); }
.splash.meh { background: #221A14; }
.splash .sq { font-weight: 700; font-size: 17px; opacity: .95; }
.splash .sa { font-size: 72px; font-weight: 900; line-height: 1.05; letter-spacing: -.02em; }
.splash .sa.small { font-size: 48px; }
.splash .sm { font-weight: 700; opacity: .9; }
@keyframes splash { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1.04); } 20% { transform: translate(-50%, -50%) scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -50%) scale(.96); } }
.toast { position: fixed; z-index: 40; left: 50%; transform: translateX(-50%); bottom: calc(130px + var(--safe-b)); background: #221A14; color: #fff; padding: 10px 16px; border-radius: 12px; font-weight: 700; font-size: 15px; animation: fade .2s ease; max-width: 90vw; text-align: center; }
.offline { position: fixed; z-index: 40; top: 8px; left: 50%; transform: translateX(-50%); background: var(--warn); color: #221A14; font-weight: 800; padding: 6px 14px; border-radius: 99px; font-size: 14px; }

/* game over */
.over { text-align: center; padding-top: 28px; }
.over h1 { font-size: 34px; margin: 6px 0 4px; }
.podium li:first-child { background: #FFF0C9; font-size: 18px; }
.hist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; text-align: left; }
.hist li { display: flex; gap: 12px; align-items: center; background: var(--card); padding: 8px; border-radius: 14px; box-shadow: var(--shadow); }
.over .btn.primary { margin-top: 22px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* categories */
.decks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.deckcard { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center; text-align: left; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 14px; padding: 10px 12px; cursor: pointer; }
.deckcard:disabled { cursor: default; opacity: .55; }
.deckcard.on { box-shadow: 0 0 0 2.5px var(--brand), var(--shadow); opacity: 1; }
.deckcard .de { grid-row: span 2; font-size: 26px; }
.deckcard .dn { font-weight: 800; font-size: 15px; }
.deckcard .dd { font-size: 12px; color: var(--muted); line-height: 1.25; }

/* photo cards */
.face.photo, .mini.photo, .revealface.photo { background: #EFE6DA; }
.tile .face.photo img, .mini.photo img, .revealface.photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 18%; }
.revealface.photo img { aspect-ratio: 1; height: auto; }
.initials { width: 100%; height: 100%; aspect-ratio: 1; display: grid; place-items: center; font-weight: 900; font-size: 22px; color: #fff; background: linear-gradient(135deg, #7C5CFF, #E5484D); }
.tile .nm { white-space: normal; line-height: 1.15; min-height: 2.3em; display: flex; align-items: center; justify-content: center; font-size: 11px; }
