/* Kukeri: My words. Mobile first, one column, phone width on a laptop.
   Same colours and fonts as kukeri.io (css/kukeri.css): linen page, soot ink, madder for
   the main action, brass for "right" and hints. Bulgarian is set in Alegreya, the rest in Golos Text.
   The quiz is a soot screen, like the word game's card. */

:root {
  --linen: #E7E3D9;
  --wool: #F8F6F1;
  --soot: #1E1B18;
  --madder: #A4161A;
  --madder-hover: #B91E22;
  --madder-bright: #E5584C;
  --brass: #D9A441;
  --brass-tint: rgb(217 164 65 / 0.3);
  --ink-soft: #5A544C;
  --dim: #B4AC9F;
  --line: #CFC9BC;
  --line-dark: #3A3530;
  --slot-line: #4A443D;
  --on-soot: #D8D1C5;

  --serif: "Alegreya", Georgia, "Times New Roman", serif;
  --sans: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --col: 480px;
  --gutter: 16px;
  --tabs-h: 64px;
  --r-s: 12px;
  --r-l: 20px;
  --vvh: 100dvh;
  --vvtop: 0px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--linen);
  color: var(--soot);
  font: 400 17px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
img { display: block; max-width: 100%; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--madder); }
h1, h2, p { margin: 0; }
[lang="bg"] { font-family: var(--serif); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- shell ---------------------------------------------------------------- */

/* The status bar area (iPhone) is soot, then the embroidered strap, as on kukeri.io. */
.top { border-top: env(safe-area-inset-top) solid var(--soot); }
.band {
  height: 18px;
  background: var(--soot) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='36' height='18' viewBox='0 0 36 18'%3E%3Cpath d='M18 2 L29 9 L18 16 L7 9Z' fill='%23A4161A'/%3E%3Cpath d='M18 6 L23 9 L18 12 L13 9Z' fill='%231E1B18'/%3E%3Crect x='17' y='8' width='2' height='2' fill='%23D9A441'/%3E%3Crect x='0' y='8' width='3' height='2' fill='%23A4161A'/%3E%3Crect x='33' y='8' width='3' height='2' fill='%23A4161A'/%3E%3C/svg%3E") repeat-x center;
}
.top-bar {
  max-width: var(--col); margin: 0 auto; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 calc(var(--gutter) - 8px) 0 var(--gutter);
}
.wordmark { font-family: var(--serif); font-weight: 700; font-size: 30px; line-height: 1; color: var(--soot); text-decoration: none; }

#page {
  max-width: var(--col); margin: 0 auto;
  padding: 8px var(--gutter) calc(var(--tabs-h) + env(safe-area-inset-bottom) + 28px);
}
body.logged-out #page { padding-bottom: 40px; }

.tabs {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(3, 1fr);
  max-width: var(--col); margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--wool);
  border-top: 1px solid var(--line);
}
.tabs a {
  height: var(--tabs-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 500;
}
.tabs .icon { width: 44px; height: 28px; padding: 3px 11px; border-radius: 999px; }
/* Active tab: a soot pill, like the tabs on kukeri.io */
.tabs a[aria-current="page"] { color: var(--soot); font-weight: 600; }
.tabs a[aria-current="page"] .icon { background: var(--soot); color: var(--wool); }
body.logged-out .tabs, body.logged-out .account-link { display: none; }
.account-link[aria-current="page"] { background: var(--soot); color: var(--wool); border-radius: 999px; }

body.quiz-mode { background: var(--soot); }
body.quiz-mode .top, body.quiz-mode .tabs { display: none; }

/* ---- type & layout helpers ------------------------------------------------ */

.stack > * + * { margin-top: 16px; }
.stack-s > * + * { margin-top: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row > .btn { flex: 1 1 0; }
.page-head { display: flex; align-items: center; gap: 6px; min-height: 48px; }
.page-head .page-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.page-head > .btn-icon:first-child { margin-left: -12px; }
.page-title { font-family: var(--serif); font-size: 32px; line-height: 1.1; font-weight: 700; }
.section-title { font-size: 18px; font-weight: 600; }
.lead { font-size: 19px; line-height: 1.4; }
.muted { color: var(--ink-soft); }
.small { font-size: 15px; }
.empty { color: var(--ink-soft); padding: 24px 0; }
.form-error { color: var(--madder); font-weight: 500; }
.form-error:empty { display: none; }
.card { background: var(--wool); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon-large { width: 36px; height: 36px; stroke-width: 1.6; }

/* ---- buttons: pills, as on kukeri.io --------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--soot);
  font-weight: 500; font-size: 17px; text-decoration: none; white-space: nowrap;
  cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: 0.4; pointer-events: none; }
.btn-primary { background: var(--madder); border-color: var(--madder); color: var(--wool); }
.btn-primary:active { background: var(--madder-hover); }
.btn-danger { background: var(--madder); border-color: var(--madder); color: var(--wool); }
.btn-quiet, .btn-quiet-danger { border-color: transparent; }
.btn-quiet-danger { color: var(--madder); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 16px; }
.btn-big { min-height: 56px; font-size: 19px; }
.btn-wide { width: 100%; }
.btn-icon { width: 44px; min-height: 44px; padding: 0; border-color: transparent; }
.btn-glass { background: rgb(30 27 24 / 0.72); border-color: transparent; color: var(--wool); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }

/* ---- form fields ---------------------------------------------------------- */

.field { display: block; }
.field-label { display: block; font-size: 15px; font-weight: 500; color: var(--ink-soft); margin-bottom: 4px; }
.field-input {
  width: 100%; min-height: 48px; padding: 10px 14px;
  background: var(--wool); border: 1px solid var(--line); border-radius: var(--r-s);
  font-size: 18px; /* 16px+ keeps iPhones from zooming in */
}
.field-input::placeholder { color: var(--dim); }
.field-input:focus { border-color: var(--soot); outline: none; box-shadow: 0 0 0 3px var(--brass-tint); }
select.field-input, .list-select {
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat;
  padding-right: 38px;
}
.field-bg { font-family: var(--serif); font-size: 24px; font-weight: 500; padding-top: 6px; padding-bottom: 6px; }

/* Label beside the input, as on paper: saves height on Add and in the editor. */
.fields { display: grid; gap: 8px; }
.fields .field { display: grid; grid-template-columns: 5.4em 1fr; align-items: center; gap: 10px; }
.fields .field-label { margin: 0; }

/* ---- Add ------------------------------------------------------------------- */

.list-bar { display: flex; align-items: center; gap: 8px; }
.list-bar-label { color: var(--ink-soft); font-size: 15px; }
.list-select {
  flex: 1; min-width: 0; min-height: 44px; padding-left: 16px;
  background-color: var(--wool); border: 1px solid var(--line); border-radius: 999px;
  font-weight: 500; font-size: 17px;
}
.list-bar .btn-icon { border: 1px solid var(--line); background: var(--wool); }

.photo-field { position: relative; }
.photo-empty {
  width: 100%; aspect-ratio: 16 / 10; max-height: 22dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  border: 2px dashed var(--line); border-radius: var(--r-l); background: var(--wool);
  color: var(--soot); font-weight: 500; font-size: 17px; cursor: pointer;
}
.photo-empty .icon { color: var(--madder); }
.photo-emoji { font-size: 56px; line-height: 1; }
.photo-preview {
  width: 100%; aspect-ratio: 16 / 10; max-height: 22dvh; object-fit: cover;
  border-radius: var(--r-l); background: var(--wool);
}
.photo-actions { position: absolute; right: 10px; bottom: 10px; display: flex; gap: 8px; }
.editor .photo-preview, .editor .photo-empty { max-height: 26dvh; }

.audio-field { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.btn-rec .icon { color: var(--madder); }
.btn-rec.is-live { background: var(--madder); border-color: var(--madder); color: var(--wool); }
.btn-rec.is-live .icon { color: var(--wool); }
.btn-play .icon { color: var(--madder); }
.rec-meter { flex: 1; height: 8px; border-radius: 4px; background: var(--wool); border: 1px solid var(--line); overflow: hidden; }
.rec-meter-fill { height: 100%; background: var(--madder); transition: width 0.1s linear; }
.rec-time { font-variant-numeric: tabular-nums; color: var(--ink-soft); min-width: 3ch; text-align: right; }

.strip-wrap { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line); }
.strip-title { font-size: 15px; font-weight: 500; color: var(--ink-soft); margin-bottom: 10px; }
.strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px;
  scroll-snap-type: x proximity;
}
.strip::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 3px 16px 3px 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--wool);
  font-size: 19px; cursor: pointer;
}
.chip.is-draft { border-style: dashed; border-color: var(--ink-soft); color: var(--ink-soft); font-size: 15px; font-style: italic; }
.chip-pic { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }

/* Pictures: photo, emoji, or the first letter as a placeholder. */
.pic-emoji, .pic-none { display: grid; place-items: center; background: var(--wool); }
.pic-emoji { font-size: 1.4em; }
.pic-none { color: var(--ink-soft); font-family: var(--serif); font-weight: 700; }
.chip-pic.pic-emoji, .chip-pic.pic-none { font-size: 20px; background: var(--linen); }

/* ---- Lists ------------------------------------------------------------------ */

.lists { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; min-height: 56px; }
.list-cover { width: 56px; height: 56px; border-radius: var(--r-s); object-fit: cover; flex: none; background: var(--wool); font-size: 30px; }
.list-text { display: flex; flex-direction: column; min-width: 0; }
.list-name { font-size: 19px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { color: var(--ink-soft); font-size: 15px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.badge {
  display: inline-block; padding: 1px 10px; border-radius: 999px;
  background: var(--brass-tint); color: var(--soot); font-size: 14px; font-weight: 500; white-space: nowrap;
}
.list-summary { justify-content: space-between; }
.list-summary .muted { display: flex; gap: 10px; align-items: center; }
.list-summary .btn { flex: none; }

.word-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 12px; }
@media (min-width: 400px) { .word-grid { grid-template-columns: repeat(3, 1fr); } }
.tile { position: relative; }
.tile-open {
  width: 100%; padding: 0; border: 0; background: none; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px;
}
.tile-pic { width: 100%; aspect-ratio: 1; border-radius: var(--r-s); object-fit: cover; font-size: 44px; margin-bottom: 4px; }
.tile-word { font-size: 21px; font-weight: 500; line-height: 1.15; padding: 0 2px; overflow-wrap: anywhere; }
.tile-en { font-size: 14px; color: var(--ink-soft); padding: 0 2px; }
.tile.is-draft .tile-pic { outline: 2px dashed var(--ink-soft); outline-offset: -2px; }
.tile.is-draft .tile-word { font-family: var(--sans); font-size: 15px; color: var(--ink-soft); font-style: italic; }
.tile-play {
  position: absolute; top: 6px; right: 6px; width: 40px; height: 40px;
  display: grid; place-items: center; border-radius: 50%;
  border: 0; background: rgb(30 27 24 / 0.72); color: var(--wool); cursor: pointer;
}
.tile-play::after { content: ""; position: absolute; inset: -4px; } /* 48px tap target */

/* ---- Quiz ------------------------------------------------------------------- */

.tip { background: var(--wool); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; font-size: 16px; }
.tip-details summary { color: var(--soot); font-weight: 500; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.tip-details[open] summary { margin-bottom: 8px; }

.quiz {
  /* photo: ≤ 35 % of the visible height, less when that would squeeze the letters */
  --pic-h: clamp(56px, min(calc(var(--vvh) * 0.35), calc(var(--vvh) - 310px)), 100vh);
  position: fixed; left: 0; right: 0; top: var(--vvtop); height: var(--vvh);
  max-width: var(--col); margin: 0 auto;
  display: flex; flex-direction: column; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 4px) var(--gutter) 8px;
  overflow: hidden;
  background: var(--soot); color: var(--wool);
}
.quiz .btn { border-color: var(--line-dark); color: var(--wool); }
.quiz .btn-primary { background: var(--madder); border-color: var(--madder); }
.quiz-top { display: flex; align-items: center; gap: 4px; min-height: 44px; flex: none; }
.quiz-top .btn-icon { margin-left: -12px; border-color: transparent; }
.quiz-list { flex: 1; min-width: 0; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-count { color: var(--dim); font-size: 15px; font-variant-numeric: tabular-nums; }

.quiz-pic { flex: none; height: var(--pic-h); overflow: hidden; border-radius: var(--r-l); }
.quiz-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.quiz-img.pic-emoji, .quiz-img.pic-none { display: grid; place-items: center; font-size: calc(var(--pic-h) * 0.6); background: none; }
.quiz-img.pic-none { color: var(--slot-line); }

.quiz-main { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: safe center; gap: 4px; text-align: center; }
.quiz-prompt { color: var(--dim); font-size: 15px; min-height: 1.45em; }
.quiz-prompt.is-feedback { color: var(--brass); }
.quiz-hint { font-size: 18px; color: var(--on-soot); min-height: 1.45em; }
.quiz-hint:empty { visibility: hidden; }

/* The letter slots, as in the word game: Alegreya on dark underlines. */
.slots {
  --slot-size: 1;
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 22px;
  font-family: var(--serif);
}
.slot-word { display: inline-flex; gap: calc(var(--slot-size) * 6px); }
.slot {
  min-width: calc(var(--slot-size) * 2.2rem); height: calc(var(--slot-size) * 3.3rem);
  display: grid; place-items: center;
  font-size: calc(var(--slot-size) * 2.7rem); font-weight: 500; line-height: 1;
  border-bottom: 3px solid var(--slot-line);
}
.slot.is-current { border-color: var(--brass); }
.slot.is-ghost { color: rgb(248 246 241 / 0.32); }
.slot.is-ghost.is-current { color: rgb(248 246 241 / 0.5); }
.slot.is-revealed { color: rgb(217 164 65 / 0.85); border-color: var(--brass); }
.slot.is-wrong { color: var(--madder-bright); border-color: var(--madder-bright); }
.slot.is-shown { color: var(--dim); }
.slot.is-filler { min-width: calc(var(--slot-size) * 0.6rem); border-color: transparent; color: var(--dim); }
.slots.is-done .slot.is-filled { color: var(--brass); border-color: var(--brass); }
.slots.is-done .slot-word { animation: ring 0.5s ease-out; }
.slots.shake { animation: shake 0.28s linear; }

@keyframes ring { 30% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.banner { background: var(--brass); color: var(--soot); font-weight: 600; font-size: 15px; padding: 2px 14px; border-radius: 999px; }

.quiz-actions { display: flex; gap: 8px; flex: none; }
.quiz-actions .btn { flex: 1 1 0; padding: 0 8px; }
.quiz-input {
  flex: none; width: 100%; min-height: 52px; padding: 6px 18px;
  background: #2A2622; border: 2px solid var(--line-dark); border-radius: 999px;
  font-family: var(--serif); font-size: 26px; font-weight: 500; color: var(--wool); caret-color: var(--brass);
}
.quiz-input:focus { outline: none; border-color: var(--dim); }
.quiz-input.is-wrong { border-color: var(--madder-bright); }
.quiz-input.is-done { border-color: var(--brass); color: var(--brass); }

.results { list-style: none; margin: 0; padding: 0; }
.result { display: flex; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.result-pic { width: 52px; height: 52px; border-radius: var(--r-s); object-fit: cover; flex: none; font-size: 28px; }
.result-text { flex: 1; display: flex; flex-direction: column; }
.result-word { font-size: 23px; font-weight: 500; line-height: 1.2; }
.result-next { font-size: 14px; color: var(--ink-soft); }
.result-next.is-copy { color: var(--madder); }
.result .btn-icon { color: var(--madder); }

/* ---- Account ---------------------------------------------------------------- */

.auth { padding-top: 12px; }
.invite-code { font-size: 34px; font-weight: 600; letter-spacing: 0.06em; font-variant-numeric: tabular-nums; }
.invite-url { overflow-wrap: anywhere; user-select: all; -webkit-user-select: all; }
.invite-out:empty { display: none; }

/* ---- sheets & toasts ---------------------------------------------------------- */

.sheet {
  width: 100%; max-width: var(--col); max-height: 92dvh;
  margin: auto auto 0; padding: 0;
  border: 0; border-radius: var(--r-l) var(--r-l) 0 0;
  background: var(--wool); color: var(--soot);
  overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in 0.22s ease-out; }
.sheet::backdrop { background: rgb(30 27 24 / 0.55); }
.sheet-body { padding: 18px var(--gutter) calc(18px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-head .btn-icon { margin-right: -10px; }
.sheet-title { font-family: var(--serif); font-size: 28px; font-weight: 700; line-height: 1.1; }
.sheet .field-input, .sheet .photo-empty, .sheet .rec-meter { background-color: var(--linen); }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

.toast {
  position: fixed; z-index: 100; left: 50%; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 14px);
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(min(var(--col), 100vw) - 2 * var(--gutter));
  padding: 10px 20px; border-radius: 999px;
  background: var(--soot); color: var(--wool); font-weight: 500; text-align: center;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-shown { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--madder); border-radius: var(--r-s); }
body.quiz-mode .toast { bottom: auto; top: calc(var(--vvtop) + 60px); background: var(--wool); color: var(--soot); }

/* Small phone with the keyboard open: tighter, and the English hint replaces the prompt. */
.vv-short .quiz { gap: 6px; padding-bottom: 6px; }
.vv-short .quiz-input { min-height: 46px; font-size: 23px; }
.vv-short .slot { height: calc(var(--slot-size) * 2.8rem); font-size: calc(var(--slot-size) * 2.35rem); }
.vv-short .quiz-hint:empty { display: none; }
.vv-short .quiz-prompt:not(.is-feedback):has(+ .quiz-hint:not(:empty)) { display: none; }

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

/* Laptop: the phone column, centred on a slightly darker cloth. */
@media (min-width: 560px) {
  body:not(.quiz-mode) { background: #DCD7CB; }
  .top-bar, #page { background: var(--linen); }
  #page { min-height: calc(100dvh - 74px); }
}
