/* Фото Діксіт — visual language borrowed from bettter.us:
   off-white paper, pale yellow and deep green fields, black square buttons,
   condensed uppercase headlines, numbered white cards with a dash. */
:root {
  --paper: #f9f9f9;
  --white: #fff;
  --ink: #000;
  --mute: #6a6a6a;
  --line: #e4e4e4;
  --yellow: #f6f09a;
  --green: #203520;
  --green-2: #2b462b;
  --red: #ff4d67;
  --pad: clamp(16px, 4vw, 40px);
  --max: 1080px;
  /* Roboto Flex: a grotesk with a width axis (for Univers-like condensed headlines) and Cyrillic. */
  --font: 'Roboto Flex', 'Helvetica Neue', Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.45 var(--font);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.vh { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }
.boot { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; background: var(--yellow); font-weight: 800; font-stretch: 62%; font-size: 40px; text-transform: uppercase; }

/* ---------- type */
.h1, .h2, .h3 { margin: 0; text-transform: uppercase; font-weight: 800; letter-spacing: 0.005em; text-wrap: balance; }
.h1 { font-stretch: 62%; font-size: clamp(52px, 15vw, 128px); line-height: 0.86; }
.h2 { font-stretch: 68%; font-size: clamp(30px, 7.4vw, 52px); line-height: 0.95; }
.h3 { font-stretch: 75%; font-size: 22px; line-height: 1; }
.num { font-size: 13px; font-variant-numeric: tabular-nums; margin-bottom: 10px; }
.dash { margin: 14px 0 0; line-height: 1; }
.dash::before { content: '—'; }
.lead { font-size: 17px; line-height: 1.4; max-width: 46ch; margin: 14px 0 0; text-wrap: pretty; }
.muted { color: var(--mute); }
.small { font-size: 13px; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; }
.link.danger { color: #c4002b; }

/* ---------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 48px; padding: 0 22px; border: 1px solid var(--ink); border-radius: 0;
  background: var(--ink); color: var(--white);
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none;
  transition: background-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: #222; }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { background: var(--ink); color: var(--white); }
.btn.white { background: var(--white); color: var(--ink); border-color: var(--white); }
.btn.white:hover { background: var(--yellow); border-color: var(--yellow); }
.btn.danger { background: var(--white); color: #c4002b; border-color: #c4002b; }
.btn.wide { width: 100%; }
.btn:disabled, .btn[aria-disabled='true'] { background: #cfcfcf; border-color: #cfcfcf; color: #6a6a6a; cursor: default; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* ---------- top bar (two white pills like bettter's nav) */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: stretch; gap: 8px;
  padding: 10px var(--pad);
  margin-bottom: -60px; /* the pills float over the page, like bettter's nav */
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.main > :first-child { padding-top: 76px; }
.pill { display: flex; align-items: stretch; background: var(--white); box-shadow: 0 6px 24px rgba(0,0,0,.06); min-height: 40px; }
.pill > * { padding: 0 12px; display: flex; align-items: center; font-size: 12px; white-space: nowrap; }
.brand b { font-weight: 600; }
.brand span { background: #efefef; color: var(--mute); }
.pill .link { font-size: 12px; }
.pill .phase { color: var(--mute); }

/* ---------- sections */
.main { padding-bottom: calc(40px + var(--safe-b)); }
.sec { padding: 36px var(--pad); max-width: var(--max); margin: 0 auto; }
.field-yellow { background: var(--yellow); }
.field-green { background: var(--green); color: var(--white); }
.full { max-width: none; }
.full > .inner { max-width: var(--max); margin: 0 auto; }
.sec + .sec { padding-top: 8px; }
.field-yellow + .sec, .field-green + .sec { padding-top: 36px; }
.sec-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }

/* ---------- login */
.login { min-height: 100vh; min-height: 100dvh; background: var(--yellow); display: flex; flex-direction: column; justify-content: space-between; padding: 24px var(--pad) calc(28px + var(--safe-b)); }
.login form { background: var(--white); padding: 22px; max-width: 420px; width: 100%; margin-top: 28px; }
.login .h1 { margin-top: 16vh; }
.login .pill { display: inline-flex; }
label.f { display: block; font-size: 12px; color: var(--mute); margin: 0 0 6px; }
.input {
  width: 100%; min-height: 48px; padding: 12px 14px; border: 1px solid #cfcfcf; border-radius: 0; background: var(--white);
  font-size: 16px; /* no iOS zoom */
}
.input:focus { outline: none; border-color: var(--ink); }
.f-row + .f-row { margin-top: 14px; }
.err { color: #c4002b; font-size: 13px; margin-top: 12px; min-height: 1em; }

/* ---------- hero */
.hero { padding-top: 26px; padding-bottom: 44px; }
.hero .h1 { margin-top: 6px; }

/* ---------- lobby */
.counter { font-weight: 800; font-stretch: 62%; font-size: 64px; line-height: .85; font-variant-numeric: tabular-nums; }
.counter small { font-size: 28px; color: var(--mute); }
.uploads { margin-top: 16px; display: grid; gap: 6px; }
.up { display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--white); padding: 10px 12px; font-size: 13px; }
.up .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up.bad { color: #c4002b; }
.up .st { color: var(--mute); white-space: nowrap; }
.bar { height: 3px; background: #e2e2e2; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--ink); }

.people { margin-top: 18px; display: grid; gap: 6px; }
.person { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; background: var(--white); padding: 14px; }
.person .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.person .who b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person .cnt { font-variant-numeric: tabular-nums; font-size: 13px; }
.person .bar { grid-column: 1 / -1; margin-top: 4px; }
.badge { display: inline-block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; padding: 3px 6px; background: var(--ink); color: var(--white); font-weight: 600; white-space: nowrap; }
.badge.y { background: var(--yellow); color: var(--ink); }
.badge.g { background: var(--green); color: var(--white); }
.badge.o { background: transparent; color: var(--ink); border: 1px solid currentColor; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cfcfcf; flex: none; }
.dot.on { background: #27a644; }

.rules { margin-top: 0; }
.rules summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.rules summary::-webkit-details-marker { display: none; }
.rules summary::after { content: '+'; font-size: 28px; font-weight: 300; }
.rules[open] summary::after { content: '–'; }
.rules ol { padding-left: 20px; margin: 16px 0 0; max-width: 62ch; }
.rules li { margin: 8px 0; }

.select { min-height: 48px; padding: 0 12px; border: 1px solid #cfcfcf; background: var(--white); border-radius: 0; font-size: 16px; }

/* ---------- cards */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(6, 1fr); gap: 12px; } .grid.mine { grid-template-columns: repeat(8, 1fr); } }
.grid.mine { grid-template-columns: repeat(4, 1fr); gap: 6px; }
@media (min-width: 720px) { .grid.mine { grid-template-columns: repeat(8, 1fr); } }
.card {
  position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--white);
  aspect-ratio: 3 / 4; overflow: hidden; outline-offset: 3px;
  box-shadow: 0 1px 0 rgba(0,0,0,.04);
  transition: transform .15s ease;
}
.grid.mine .card { aspect-ratio: 1; }
.card img { width: 100%; height: 100%; object-fit: cover; background: #ececec; }
.card:active { transform: scale(.98); }
.card .no { position: absolute; top: 6px; left: 6px; background: var(--white); color: var(--ink); font-size: 11px; padding: 2px 5px; font-variant-numeric: tabular-nums; }
.card .tag { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; text-align: center; background: var(--ink); color: var(--white); }
.card .tag.y { background: var(--yellow); color: var(--ink); }
.card.sel { outline: 3px solid var(--ink); }
.field-green .card.sel { outline-color: var(--yellow); }
.card.dim img { opacity: .45; }

/* reveal: card + caption */
.reveal { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 10px; margin-top: 20px; }
@media (min-width: 720px) { .reveal { grid-template-columns: repeat(4, 1fr); } }
.rv { background: var(--white); color: var(--ink); display: flex; flex-direction: column; }
.rv .card { aspect-ratio: 3 / 4; }
.rv .cap { padding: 10px 10px 12px; font-size: 12px; line-height: 1.35; display: grid; gap: 6px; }
.rv .cap .by { font-weight: 600; font-size: 13px; }
.rv .muted, .field-green .rv .muted { color: var(--mute); }
.rv.story { outline: 3px solid var(--yellow); }
.votes { display: flex; flex-wrap: wrap; gap: 4px; }
.vchip { font-size: 11px; padding: 2px 6px; background: #efefef; }

/* ---------- scoreboard */
.board { display: flex; gap: 6px; overflow-x: auto; margin: 16px calc(var(--pad) * -1) 0; padding: 0 var(--pad) 4px; scrollbar-width: none; }
.board::-webkit-scrollbar { display: none; }
.chip { flex: none; background: var(--white); color: var(--ink); padding: 8px 10px; min-width: 84px; display: grid; gap: 2px; }
.chip .n { font-size: 12px; display: flex; align-items: center; gap: 6px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.chip .s { font-weight: 800; font-stretch: 62%; font-size: 30px; line-height: .9; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px; }
.chip .s small { font-size: 14px; font-stretch: 100%; font-weight: 600; color: #1d7a34; }
.chip .st { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--mute); }
.chip.teller { background: var(--ink); color: var(--white); }
.chip.teller .st { color: rgba(255,255,255,.7); }
.chip.teller .s small { color: #8be39b; }
.chip.me { box-shadow: inset 0 0 0 1px var(--ink); }
.chip .st.done { color: #1d7a34; }

/* ---------- game stage */
.stage-meta { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; align-items: baseline; }
.clue { font-weight: 800; font-stretch: 62%; font-size: clamp(40px, 12vw, 96px); line-height: .9; text-transform: uppercase; margin: 12px 0 0; overflow-wrap: anywhere; text-wrap: balance; }
.clue-by { margin-top: 10px; font-size: 13px; }
.field-green .muted { color: rgba(255,255,255,.7); }
.waiting { margin-top: 16px; font-size: 13px; }
.waiting b { font-weight: 600; }
.result-line { margin-top: 14px; font-size: 17px; max-width: 52ch; }
.points { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.points span { background: var(--white); color: var(--ink); padding: 6px 10px; font-size: 13px; }
.points span b { font-weight: 700; }

.story-form { margin-top: 18px; display: grid; gap: 10px; }
.story-form textarea { resize: none; min-height: 84px; }
.story-pick { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.story-pick .card { width: 64px; flex: none; }
.chars { font-size: 12px; color: var(--mute); text-align: right; }

.sticky-act {
  position: sticky; bottom: 0; z-index: 10;
  padding: 12px var(--pad) calc(12px + var(--safe-b));
  background: linear-gradient(transparent, var(--paper) 30%);
  max-width: var(--max); margin: 0 auto;
}

details.host { background: var(--white); padding: 14px; margin-top: 8px; }
details.host summary { cursor: pointer; font-size: 13px; font-weight: 600; }
details.host p { font-size: 13px; color: var(--mute); margin: 10px 0 0; }

.history { display: grid; gap: 10px; margin-top: 18px; }
.hrow { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; background: var(--white); padding: 8px; }
.hrow .card { aspect-ratio: 3/4; }
.hrow .q { font-weight: 700; font-stretch: 75%; font-size: 20px; text-transform: uppercase; line-height: 1; overflow-wrap: anywhere; }
.hrow .m { font-size: 12px; color: var(--mute); margin-top: 6px; }

/* ---------- final */
.podium { display: grid; gap: 6px; margin-top: 22px; }
.place { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; background: var(--white); padding: 12px 14px; }
.place .p { font-size: 13px; font-variant-numeric: tabular-nums; }
.place .nm { font-weight: 600; }
.place .sc { font-weight: 800; font-stretch: 62%; font-size: 36px; line-height: .9; }
.place.win { background: var(--ink); color: var(--white); }
.album-round { margin-top: 28px; }
.album-round .h3 { margin-top: 4px; }

/* ---------- viewer */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: #0b0b0b; color: var(--white);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; touch-action: pan-y;
}
.v-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 13px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
.v-top .btn { min-height: 38px; padding: 0 14px; }
.v-img { position: relative; min-height: 0; display: grid; place-items: center; padding: 0 10px; }
.v-img img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.v-bar { display: grid; grid-template-columns: 56px 1fr 56px; gap: 8px; padding: 12px 12px calc(14px + var(--safe-b)); align-items: center; }
.v-bar .nav { min-height: 52px; background: transparent; border: 1px solid rgba(255,255,255,.4); color: var(--white); font-size: 22px; }
.v-bar .nav:disabled { opacity: .25; }
.v-bar .btn { min-height: 52px; }
.v-note { text-align: center; font-size: 13px; color: rgba(255,255,255,.8); padding: 0 8px; }

/* ---------- sheet (host panel) */
.sheet-bg { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.4); display: flex; justify-content: flex-end; }
.sheet { width: min(520px, 100%); height: 100%; overflow-y: auto; background: var(--paper); padding: 18px var(--pad) calc(28px + var(--safe-b)); }
.sheet .h2 { margin-top: 8px; }
.sheet-close { display: flex; justify-content: flex-end; }
.invite { background: var(--yellow); padding: 16px; margin-top: 16px; }
.invite pre { white-space: pre-wrap; font: 14px/1.5 var(--font); margin: 0; overflow-wrap: anywhere; }
.acct { background: var(--white); padding: 14px; display: grid; gap: 8px; }
.acct .row1 { display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.acct .acts { display: flex; gap: 14px; flex-wrap: wrap; }
.add-row { display: flex; gap: 8px; margin-top: 16px; }
.add-row .input { flex: 1; }

/* ---------- toast */
.toast { position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--white); padding: 12px 16px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast.bad { background: #c4002b; }
.offline { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--red); color: var(--white); text-align: center; font-size: 12px; padding: 4px; }

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

/* ---------- who are you */
.person.pickme { width: 100%; border: 0; text-align: left; font: inherit; color: inherit; grid-template-columns: 1fr auto; }
.person.pickme:hover { background: var(--yellow); }
.person.pickme .cnt { font-size: 12px; letter-spacing: .04em; }
