:root {
  --bg: #0b0b0c;
  --surface: #17171a;
  --surface-2: #222227;
  --line: #2e2e35;
  --text: #f3efe6;
  --muted: #a39f96;
  --accent: #f4b860;
  --accent-ink: #1d1406;
  --truth: #7fd1a8;
  --lie: #f28b82;
  --radius: 18px;
  --serif: "Iowan Old Style", "Palatino", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 96px); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { font-family: var(--serif); font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.brand small { display: block; font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }

/* segmented mode picker */
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--surface); border-radius: 14px; padding: 4px; gap: 4px; }
.segmented button { padding: 10px 6px; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; }
.segmented button.on { background: var(--surface-2); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.05) inset; }

.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); user-select: none; }
.toggle input { appearance: none; width: 40px; height: 24px; border-radius: 12px; background: var(--surface-2); position: relative; transition: background .2s; margin: 0; }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s; }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(16px); background: var(--accent-ink); }

/* camera */
.viewfinder { position: relative; margin-top: 14px; border-radius: var(--radius); overflow: hidden; background: #000; aspect-ratio: 3 / 4; }
.viewfinder video, .viewfinder img.still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.viewfinder .hint { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.shutter-wrap { position: absolute; left: 0; right: 0; bottom: 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.viewfinder video::-webkit-media-controls, .viewfinder video::-webkit-media-controls-start-playback-button { display: none !important; -webkit-appearance: none; }
.shutter { width: 76px; height: 76px; border-radius: 50%; background: #fff; border: 5px solid rgba(255,255,255,.35); background-clip: padding-box; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
.shutter:active { transform: scale(.92); }
.shutter-label { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #fff; text-shadow: 0 1px 6px rgba(0,0,0,.8); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 20px; border-radius: 999px; font-weight: 650; font-size: 16px; background: var(--surface-2); color: var(--text); text-decoration: none; }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.big { min-height: 60px; padding: 0 34px; font-size: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.45); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn.truth { background: var(--truth); color: #0b2117; }
.btn.lie { background: var(--lie); color: #2a0b08; }

/* story card */
.card { background: var(--surface); border-radius: var(--radius); padding: 18px; margin-top: 14px; }
.card .photo { width: 100%; border-radius: 12px; display: block; margin-bottom: 14px; max-height: 360px; object-fit: cover; }
.place { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.title { font-family: var(--serif); font-size: 24px; font-weight: 700; margin: 0 0 10px; line-height: 1.2; }
.story { font-family: var(--serif); font-size: 19px; line-height: 1.5; margin: 0; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 6px; vertical-align: middle; margin-left: 6px; }
.badge.fiction { background: rgba(242,139,130,.18); color: var(--lie); }
.badge.fact { background: rgba(127,209,168,.16); color: var(--truth); }
.badge.mp { background: rgba(244,184,96,.16); color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.guess { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.guess .btn { min-height: 58px; font-size: 18px; border-radius: 16px; }
.verdict { margin-top: 16px; padding: 14px 16px; border-radius: 14px; font-weight: 650; font-size: 17px; }
.verdict.good { background: rgba(127,209,168,.14); color: var(--truth); }
.verdict.bad { background: rgba(242,139,130,.14); color: var(--lie); }
.verdict span { display: block; font-weight: 500; font-size: 14px; color: var(--text); opacity: .85; margin-top: 2px; }
.more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; font-family: var(--serif); font-size: 17px; line-height: 1.5; }
.more p { margin: 0 0 10px; }
.more-label { font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin-bottom: 4px; }
.more-block + .more-block { margin-top: 12px; }
.source { font-family: var(--sans); font-size: 13px; color: var(--muted); margin-top: 6px; }
.error { color: var(--lie); font-size: 14px; margin-top: 10px; white-space: pre-wrap; }

.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid rgba(0,0,0,.2); border-top-color: currentColor; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.thinking { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 16px; }
.thinking .spinner { border-color: var(--surface-2); border-top-color: var(--accent); }

/* bottom tabs */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 8px; padding: 10px 16px calc(var(--safe-bottom) + 10px); background: linear-gradient(transparent, var(--bg) 30%); z-index: 20; }
.tabs button { flex: 1; max-width: 200px; min-height: 50px; border-radius: 16px; background: var(--surface); color: var(--muted); font-weight: 650; }
.tabs button.on { background: var(--surface-2); color: var(--text); }

/* journal */
#map { height: 260px; border-radius: var(--radius); overflow: hidden; background: var(--surface); margin-top: 6px; }
.leaflet-container { font-family: var(--sans); }
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.entry { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: center; background: var(--surface); border-radius: 14px; padding: 10px; text-align: left; }
.entry img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.entry .t { font-weight: 650; font-size: 16px; }
.entry .m { font-size: 13px; color: var(--muted); margin-top: 2px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; line-height: 1.5; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 20px 0 8px; }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 16px 16px calc(var(--safe-bottom) + 20px); }
.sheet .card { margin-top: 8px; }

/* multiplayer */
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 40px; font-weight: 800; letter-spacing: .14em; color: var(--accent); }
.qr { background: #fff; padding: 12px; border-radius: 14px; width: 184px; height: 184px; display: grid; place-items: center; }
.qr img, .qr canvas { width: 160px !important; height: 160px !important; }
.join-box { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.link { font-size: 14px; color: var(--muted); word-break: break-all; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 17px; }
.board li:last-child { border-bottom: 0; }
.board .rank { width: 26px; color: var(--muted); font-weight: 700; }
.board .nm { flex: 1; }
.board .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.board li.me { color: var(--accent); }
.board li.win .nm::after { content: " 🏆"; }
.stat { font-size: 15px; color: var(--muted); }
.stat b { color: var(--text); font-size: 22px; }
input.text { width: 100%; min-height: 54px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: 18px; padding: 0 16px; outline: none; }
input.text:focus { border-color: var(--accent); }
.center { text-align: center; }
.big-msg { font-family: var(--serif); font-size: 26px; font-weight: 700; margin: 30px 0 8px; }
.muted { color: var(--muted); }

#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translate(-50%, 20px); background: var(--surface-2); color: var(--text); padding: 12px 18px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.confetti { position: fixed; top: -10px; width: 9px; height: 14px; border-radius: 2px; z-index: 70; pointer-events: none; animation: fall 2s ease-in forwards; }
@keyframes fall { to { top: 105vh; transform: translateX(40px) rotate(720deg); } }

/* reveal + double down */
.zinger { display: block; font-family: var(--serif); font-weight: 500; font-size: 16px; margin-top: 8px; color: var(--text); }
.double { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 14px; background: var(--surface-2); font-size: 15px; font-weight: 600; user-select: none; }
.double input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; }
.double small { color: var(--muted); font-weight: 500; }
.double:has(input:checked) { background: rgba(244,184,96,.18); color: var(--accent); }
.voters { font-size: 14px; color: var(--muted); margin-top: 8px; }
.results { list-style: none; padding: 0; margin: 14px 0 0; }
.results li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 15px; }
.results li:last-child { border-bottom: 0; }
.results .nm { flex: 1; }
.results .v { color: var(--muted); font-size: 14px; }
.results .pts { width: 34px; text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.results li.good .pts { color: var(--truth); }
.results li.bad .pts { color: var(--lie); }
.awards { display: grid; gap: 10px; margin-top: 16px; }
.award { display: flex; gap: 12px; align-items: center; background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.award .emoji { font-size: 30px; }
.aw-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.aw-name { font-family: var(--serif); font-size: 19px; font-weight: 700; }
.aw-why { font-size: 13px; color: var(--muted); }
.osm-dark { filter: invert(1) hue-rotate(180deg) brightness(.9) contrast(.9); } /* dark map from standard OpenStreetMap tiles */
