:root {
  --bg: #14100e;
  --bg2: #1c1714;
  --card: #221c18;
  --line: #33291f;
  --ink: #f2e8de;
  --ink-dim: #a3948a;
  --ember: #e07a3f;
  --ember-hot: #ff5c33;
  --cold: #4b7a9e;
  --ok: #7a9a4e;
  --err: #d9614f;
  --radius: 12px;
}

* { box-sizing: border-box; }

/* Nase .hearth/.latest/.guess-form maji display:flex, ktery by jinak
   prebil vychozi [hidden] { display: none } z prohlizece. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a1c14 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}

h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 800; letter-spacing: -.01em; }
h1 { font-size: clamp(2rem, 6vw, 3rem); margin: .2em 0 .3em; }
h3 { font-size: 1rem; margin: 0 0 .8rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

.screen { max-width: 720px; margin: 0 auto; padding: 24px 18px 80px; }

/* ---------- uvítání ---------- */
.welcome { text-align: center; padding-top: 6vh; }
.flame { font-size: 56px; line-height: 1; filter: drop-shadow(0 0 24px #ff5c3355); }
.lede { color: var(--ink-dim); max-width: 46ch; margin: 0 auto 2rem; }
.lede em { color: var(--ember); font-style: normal; font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: left;
  margin-bottom: 18px;
}

.tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; border-radius: 8px; cursor: pointer;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink-dim); font: inherit; font-size: .92rem;
}
.tab.active { background: var(--ember); border-color: var(--ember); color: #1a0f08; font-weight: 600; }

label { display: block; margin-bottom: 14px; font-size: .85rem; color: var(--ink-dim); }

input {
  display: block; width: 100%; margin-top: 6px;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 13px; color: var(--ink); font: inherit;
}
input:focus { outline: 2px solid var(--ember); outline-offset: 1px; border-color: transparent; }

button.primary {
  width: 100%; padding: 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: linear-gradient(180deg, var(--ember), #c4622f);
  color: #1a0f08; font: inherit; font-weight: 600;
}
button.primary:disabled { opacity: .5; cursor: wait; }

.hint { font-size: .8rem; color: var(--ink-dim); margin: 0 0 14px; }
.err { color: var(--err); font-size: .88rem; margin: 6px 0 10px; }
.ok  { color: var(--ok);  font-size: .88rem; margin: 6px 0 0; }
.empty { color: var(--ink-dim); font-size: .9rem; text-align: center; padding: 20px 0; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; padding-bottom: 16px;
  border-bottom: 1px solid var(--line); margin-bottom: 20px;
}
.brand { font-family: Fraunces, serif; font-weight: 800; }
.topbar nav { display: flex; align-items: center; gap: 10px; font-size: .88rem; }
.navbtn {
  background: transparent; border: 1px solid transparent; color: var(--ink-dim);
  padding: 5px 10px; border-radius: 7px; cursor: pointer; font: inherit; position: relative;
}
.navbtn.active { color: var(--ink); border-color: var(--line); background: var(--card); }
.dot { position: absolute; top: 2px; right: 2px; width: 7px; height: 7px; border-radius: 50%; background: var(--ember-hot); }
.who { color: var(--ember); font-weight: 600; }
.linkbtn { background: none; border: 0; color: var(--ink-dim); cursor: pointer; font: inherit; font-size: .82rem; text-decoration: underline; }

/* ---------- hra ---------- */
.status { display: flex; justify-content: space-between; color: var(--ink-dim); font-size: .85rem; margin-bottom: 14px; }

.guess-form { display: flex; gap: 8px; }
.guess-form input { margin: 0; flex: 1; font-size: 1.05rem; }
.guess-form button { width: auto; padding: 12px 22px; white-space: nowrap; }

@keyframes pop { from { transform: scale(.96); opacity: 0 } to { transform: none; opacity: 1 } }

.guesses { list-style: none; padding: 0; margin: 18px 0 0; }

.g {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 4px 12px; padding: 9px 12px; margin-bottom: 6px;
  border-radius: 9px; background: var(--bg2);
  border: 1px solid var(--line); position: relative; overflow: hidden;
}
.g { transition: box-shadow .45s ease, border-color .45s ease; }
.g.touched { box-shadow: 0 0 0 1px var(--ember), 0 0 18px -6px var(--ember-hot); border-color: var(--ember); }
.g .bar {
  position: absolute; inset: 0 auto 0 0; z-index: 0; width: 0;
  opacity: .22; border-radius: 9px 0 0 9px;
  transition: width .85s cubic-bezier(.2,.8,.2,1), background .5s linear;
}
.g > * { position: relative; z-index: 1; }
.g .w { font-weight: 600; }
.g .t { font-variant-numeric: tabular-nums; font-weight: 700; }
.g .meta { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: .78rem; color: var(--ink-dim); }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px 2px 3px; border-radius: 99px;
  background: #ffffff0d; border: 1px solid var(--line);
}
.badge .av {
  width: 17px; height: 17px; border-radius: 50%;
  display: grid; place-items: center; font-size: .62rem; font-weight: 700; color: #1a0f08;
}
.badge .ord { opacity: .6; font-variant-numeric: tabular-nums; }
.badge.others { padding-left: 8px; }

.win { text-align: center; background: linear-gradient(180deg, #3a1f10, #221610); border: 1px solid var(--ember); border-radius: var(--radius); padding: 22px; margin-bottom: 18px; }
.win-flame { font-size: 40px; filter: drop-shadow(0 0 20px #ff5c3388); }
.win h2 { margin: .3em 0; font-size: 1.25rem; }
.win strong { color: var(--ember); }
.win p { color: var(--ink-dim); margin: 0; font-size: .9rem; }

.board { margin-top: 30px; }
.board ol { padding-left: 20px; margin: 0; }
.board li { padding: 4px 0; color: var(--ink-dim); }
.board li b { color: var(--ink); }
.board li.me b { color: var(--ember); }

/* ---------- kamarádi ---------- */
.people { list-style: none; padding: 0; margin: 0; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.people li:last-child { border-bottom: 0; }
.people .av { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .75rem; font-weight: 700; color: #1a0f08; }
.people .name { flex: 1; font-weight: 500; }
.people button { background: transparent; border: 1px solid var(--line); color: var(--ink-dim); border-radius: 7px; padding: 5px 11px; cursor: pointer; font: inherit; font-size: .8rem; }
.people button.accept { border-color: var(--ok); color: var(--ok); }

#friend-form { display: flex; gap: 8px; }
#friend-form input { margin: 0; }
#friend-form button { width: auto; padding: 11px 18px; white-space: nowrap; }

@media (max-width: 480px) {
  .guess-form { flex-direction: column; }
  .guess-form button { width: 100%; }
  .topbar nav { width: 100%; }
}

/* ======================================================================
   Pohyb. Vse, co se tu hybe, je pod @media prefers-reduced-motion vypnute.
   ====================================================================== */

/* ---------- proužek posledního tipu ---------- */
.latest {
  --c: var(--ember);
  display: flex; align-items: center; gap: 12px;
  margin: 16px 0 4px; padding: 12px 16px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 16%, transparent), transparent 70%), var(--bg2);
  border: 1px solid color-mix(in srgb, var(--c) 40%, var(--line));
}
.lat-num {
  font-family: Fraunces, Georgia, serif; font-weight: 800; font-size: 1.9rem;
  line-height: 1; color: var(--c); font-variant-numeric: tabular-nums; min-width: 2.4ch;
}
.lat-text { color: var(--ink-dim); font-size: .92rem; }
.lat-text b { color: var(--ink); font-weight: 600; }
.lat-word { color: var(--c); font-weight: 600; }

.latest.pending {
  background: linear-gradient(90deg, #ffffff08, transparent 70%), var(--bg2);
  border-color: var(--line);
}
.lat-spark {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 50% 60%, #ffb347, #ff5c33 55%, transparent 70%);
  animation: spark 1.1s ease-in-out infinite;
}
@keyframes spark {
  0%, 100% { transform: scale(.75); opacity: .55 }
  50%      { transform: scale(1.1); opacity: 1 }
}

/* Čekání na odpověď — po tlačítku přejede uhlík. */
.guess-form button.waiting {
  position: relative; overflow: hidden; color: transparent;
}
.guess-form button.waiting::after {
  content: '…'; position: absolute; inset: 0;
  display: grid; place-items: center; color: #1a0f08; font-weight: 700;
}
.guess-form button.waiting::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, #fff6 50%, transparent 80%);
  animation: sweep 1s linear infinite;
}
@keyframes sweep { from { transform: translateX(-100%) } to { transform: translateX(100%) } }

/* ---------- U ohně ---------- */
.hearth {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 10px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
}
.hearth-label {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-dim); font-weight: 600; flex: none;
}
.hearth-list { list-style: none; display: flex; gap: 14px; flex-wrap: wrap; padding: 0; margin: 0; }

.ch { display: flex; align-items: center; gap: 8px; opacity: .42; transition: opacity .5s ease; }
.ch.on { opacity: 1; }
.ch .av {
  width: 28px; height: 28px; border-radius: 50%; flex: none; position: relative;
  display: grid; place-items: center; font-size: .74rem; font-weight: 700; color: #1a0f08;
}
/* Kdo sedí u ohně, tomu avatar dýchá. */
.ch.on .av { animation: flicker 3.4s ease-in-out infinite; }
@keyframes flicker {
  0%, 100% { box-shadow: 0 0 0 0 #ff5c3300, 0 0 10px -2px #ff5c3355 }
  45%      { box-shadow: 0 0 0 3px #ff5c3318, 0 0 16px -1px #ff5c3388 }
}
/* Kruh po tipu. Říká „hraje“, neříká co. */
.ch .av.ping::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--ember-hot); animation: ping .85s cubic-bezier(.2,.8,.2,1) 2;
}
@keyframes ping {
  from { transform: scale(.85); opacity: .9 }
  to   { transform: scale(1.75); opacity: 0 }
}
.ch-b { display: flex; flex-direction: column; line-height: 1.25; }
.ch-n { font-size: .84rem; font-weight: 600; }
.ch-s { font-size: .7rem; color: var(--ink-dim); }
.ch.solved .ch-s { color: var(--ember); }
.ch.solved .av { box-shadow: 0 0 0 2px var(--ember); }

/* ---------- jiskry po výhře ---------- */
.win { position: relative; }
.ember {
  position: absolute; bottom: 14px; width: 5px; height: 5px; border-radius: 50%;
  pointer-events: none; filter: blur(.3px);
}

/* ---------- hlášky ---------- */
.toasts {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 50; pointer-events: none;
}
.toast {
  background: var(--card); border: 1px solid var(--line); color: var(--ink);
  padding: 10px 16px; border-radius: 99px; font-size: .86rem;
  box-shadow: 0 10px 30px -10px #000a;
}
.toast.hot { border-color: var(--ember); box-shadow: 0 10px 30px -10px #000a, 0 0 22px -8px var(--ember-hot); }

/* ---------- klid ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 480px) {
  .hearth { gap: 8px; }
  .hearth-list { gap: 10px; }
  .lat-num { font-size: 1.6rem; }
}
