/* Campoff — night camp palette
   night #0B0F0E, smoke #17201D, ember #FF7A3D, moss #7FA98C, bone #EDE7DC, ash #8B948F */

:root {
  --night: #0B0F0E;
  --smoke: #17201D;
  --smoke-2: #1F2A26;
  --ember: #FF7A3D;
  --ember-deep: #C24A1A;
  --moss: #7FA98C;
  --bone: #EDE7DC;
  --ash: #8B948F;
  --danger: #E0604C;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--bone);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.screen { min-height: 100dvh; display: flex; flex-direction: column; max-width: 480px; margin: 0 auto; padding: 0 20px; }
[hidden] { display: none !important; }

.brand {
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  font-weight: 800; font-size: 2.6rem; letter-spacing: -0.02em; margin: 0.2em 0 0;
}
.brand.small { font-size: 1.2rem; }
.tagline { color: var(--ash); margin-top: 4px; margin-bottom: 32px; }

.ember-mark {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--ember);
  box-shadow: 0 0 22px var(--ember), 0 0 44px rgba(255,122,61,.35);
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 50% { box-shadow: 0 0 10px var(--ember), 0 0 20px rgba(255,122,61,.2); opacity: .8; } }
@media (prefers-reduced-motion: reduce) { .ember-mark { animation: none; } }

.auth-wrap { margin: auto 0; padding: 48px 0; display: flex; flex-direction: column; gap: 12px; }
.auth-wrap h2 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.field span { font-size: .85rem; color: var(--ash); }
.field input {
  background: var(--smoke); color: var(--bone);
  border: 1px solid var(--smoke-2); border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.05rem; outline: none;
}
.field input:focus-visible { border-color: var(--ember); }
#auth-code, #modal-input { letter-spacing: .25em; font-variant-numeric: tabular-nums; text-transform: uppercase; }

.btn {
  border: 1px solid var(--smoke-2); background: var(--smoke); color: var(--bone);
  border-radius: var(--radius); padding: 14px 18px; font-size: 1rem; cursor: pointer;
  transition: transform .06s ease, background .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ember); border-color: var(--ember); color: #1A0E06; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: rgba(224,96,76,.35); }
.btn.tiny { padding: 8px 14px; font-size: .85rem; border-radius: 10px; }
.btn:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }

.error { color: var(--danger); min-height: 1.2em; font-size: .9rem; }
.hint { color: var(--ash); font-size: .9rem; line-height: 1.5; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 0 8px;
}
.iconbtn { background: none; border: none; color: var(--ash); font-size: 1.3rem; cursor: pointer; padding: 6px 10px; }
.iconbtn:focus-visible { outline: 2px solid var(--ember); border-radius: 8px; }

/* -------- home -------- */
.home-main { display: flex; flex-direction: column; align-items: center; padding: 24px 0 8px; }
.start-ring {
  width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #241812 0%, var(--smoke) 62%);
  border: 2px solid var(--ember-deep);
  color: var(--bone); cursor: pointer;
  box-shadow: 0 0 40px rgba(255,122,61,.16), inset 0 0 30px rgba(255,122,61,.08);
  transition: box-shadow .3s, transform .06s;
}
.start-ring:active { transform: scale(.97); }
.start-ring:focus-visible { outline: 3px solid var(--ember); outline-offset: 4px; }
.start-label { font-family: "Bricolage Grotesque", sans-serif; font-weight: 800; font-size: 1.5rem; line-height: 1.15; }
.ritual { color: var(--ash); font-size: .85rem; letter-spacing: .04em; margin-top: 14px; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 16px 0; }
.total { background: var(--smoke); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.total b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.total span { color: var(--ash); font-size: .72rem; }

.groups-block { padding-bottom: 32px; }
.groups-head { display: flex; align-items: center; justify-content: space-between; }
.groups-head h3 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; margin: 12px 0; }
.group-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.group-item {
  background: var(--smoke); border-radius: var(--radius); padding: 14px 16px;
  display: flex; justify-content: space-between; align-items: center; cursor: pointer;
}
.group-item small { color: var(--ash); }

/* -------- personal goal card -------- */
.goal-card {
  background: var(--smoke); border-radius: var(--radius);
  padding: 16px; margin: 12px 0 4px;
  display: flex; flex-direction: column; gap: 10px;
}
.goal-card.reached { align-items: center; text-align: center; border: 1px solid var(--ember-deep); }
.goal-card.reached .ember-mark { margin-bottom: 2px; }
.goal-h { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; font-size: 1.1rem; margin: 0; }
.goal-sub { color: var(--ash); font-size: .85rem; line-height: 1.5; margin: 0; }
.goal-reward-line { font-size: 1.05rem; margin: 0; overflow-wrap: anywhere; }
.goal-progress { color: var(--ash); font-size: .85rem; margin: 0; font-variant-numeric: tabular-nums; }
.goal-count { color: var(--ash); font-size: .8rem; margin: 2px 0 0; }
.goal-count b { color: var(--bone); }
.goal-bar { height: 10px; background: var(--smoke-2); border-radius: 6px; overflow: hidden; }
.goal-bar span {
  display: block; height: 100%; border-radius: 6px;
  background: linear-gradient(90deg, var(--ember-deep), var(--ember));
  transition: width .4s ease;
}
.goal-card .field { margin: 2px 0; }

/* -------- streak flame --------
   Amber, right of the name, with a number. Never green (that is presence,
   left of the name). Dimmed at 40% until today has burned: own view only. */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.flame { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.flame svg { width: 16px; height: 16px; fill: var(--ember); display: block; }
.flame b { font-size: .9rem; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--bone); }
.flame.dim svg { opacity: .4; }
.flame.small svg { width: 14px; height: 14px; }
.flame.small b { font-size: .82rem; }
.streak-note { margin-top: 10px; text-align: center; }

/* The flame on the home screen is a button: it opens the rules. Big enough to
   tap on a phone, quiet enough not to compete with Start Campoff. */
button.flame {
  background: none; border: none; cursor: pointer;
  padding: 6px 8px; margin: -6px -4px -6px 0; border-radius: 10px;
}
button.flame:focus-visible { outline: 2px solid var(--ember); }
/* Zero state, own screen only: grey flame, grey zero, no amber at all. It is a
   door into the feature, never a mark of failure. The board never shows this. */
.flame.zero svg { fill: var(--ash); opacity: .55; }
.flame.zero b { color: var(--ash); }

/* -------- streak rules sheet -------- */
.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center; z-index: 55;
  padding: 16px;
}
.sheet-card {
  background: var(--smoke); border-radius: 20px; padding: 24px 22px;
  width: 100%; max-width: 440px; max-height: 88dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  margin-bottom: env(safe-area-inset-bottom);
}
.sheet-flame svg { width: 34px; height: 34px; fill: var(--ember); display: block; }
.sheet-card h3 { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; font-size: 1.35rem; margin: 0; }
.sheet-lead { color: var(--bone); font-size: .95rem; line-height: 1.55; margin: 0; }
.sheet-rules { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.sheet-rules li { color: var(--ash); font-size: .9rem; line-height: 1.6; padding-left: 14px; border-left: 2px solid var(--smoke-2); }
.sheet-rules b { color: var(--bone); font-weight: 600; }
.sheet-close-note { color: var(--ash); font-size: .88rem; font-style: italic; margin: 6px 0 2px; }

/* -------- goal: releasing the goal in motion -------- */
.goal-release { display: flex; justify-content: flex-end; margin-top: 2px; }
.goal-release button {
  background: none; border: none; color: var(--ash); cursor: pointer;
  font-size: .8rem; padding: 6px 2px; text-decoration: underline;
  text-underline-offset: 3px;
}
.goal-release button:hover { color: var(--bone); }
.goal-release button:focus-visible { outline: 2px solid var(--ember); border-radius: 6px; }
.goal-confirm { display: flex; flex-direction: column; gap: 10px; }
.goal-confirm .goal-confirm-actions { display: flex; gap: 10px; }
.goal-confirm .goal-confirm-actions .btn { flex: 1; }

/* -------- session: near-black, one dim timer -------- */
.session-screen { background: #000; justify-content: center; }
.session-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; padding: 40px 0; }
.session-ring { width: 230px; height: 230px; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: #101010; stroke-width: 3; }
.ring-fg {
  fill: none; stroke: var(--ember-deep); stroke-width: 3; stroke-linecap: round;
  stroke-dasharray: 565.5; stroke-dashoffset: 565.5; opacity: .55;
  transition: stroke-dashoffset 1s linear;
}
.session-time {
  position: absolute; font-variant-numeric: tabular-nums;
  font-size: 2.2rem; color: #5A5148; letter-spacing: .06em;
}
.session-inner { position: relative; }
.session-time { top: 50%; left: 50%; transform: translate(-50%, -130%); }
.session-hint { color: #33302B; font-size: .8rem; }
.btn.end { background: transparent; border-color: #262626; color: #6B655D; }

.done-time { font-size: 2.4rem; font-variant-numeric: tabular-nums; font-family: "Bricolage Grotesque", sans-serif; margin: 0; }

/* -------- group board -------- */
.group-title { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; }
.tabs { display: flex; gap: 6px; padding: 8px 0 16px; }
.tabs button {
  flex: 1; background: transparent; border: 1px solid var(--smoke-2); color: var(--ash);
  border-radius: 10px; padding: 9px 0; cursor: pointer; font-size: .85rem;
}
.tabs button.active { background: var(--smoke); color: var(--bone); border-color: var(--ember-deep); }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.board-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--smoke); border-radius: var(--radius); padding: 13px 16px;
}
.board-row.me { border: 1px solid var(--ember-deep); }
.presence {
  width: 11px; height: 11px; border-radius: 50%; flex: none;
  background: #3A423E;
}
.presence.on {
  background: var(--moss);
  box-shadow: 0 0 10px var(--moss), 0 0 20px rgba(127,169,140,.4);
}
.board-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-time { font-variant-numeric: tabular-nums; color: var(--bone); }
.board-rank { color: var(--ash); width: 1.4em; font-size: .85rem; }

/* Friends / Camps toggle. A filled two segment control, so it reads as a
 * switch between two views rather than as the period tabs below it. */
.seg {
  display: flex; gap: 4px; background: var(--smoke); border-radius: 12px;
  padding: 4px; margin: 12px 0 4px;
}
.seg button {
  flex: 1; background: transparent; border: 0; color: var(--ash);
  border-radius: 9px; padding: 9px 0; cursor: pointer;
  font-family: inherit; font-size: .9rem; -webkit-user-select: none; user-select: none;
}
.seg button.active { background: var(--smoke-2); color: var(--bone); }

/* The quiet "You" marker on your own row. Never a badge, never a colour:
 * it says which row is yours and nothing more. */
.you-mark { color: var(--ash); font-size: .78rem; font-weight: 600; letter-spacing: .02em; }

/* The friends list reuses .board and .board-row exactly, so a row here and a
 * row on a camp board are the same object. The only difference is that no
 * .board-rank is ever drawn: this list is ordered, but it has no positions. */
#friends-list { padding-bottom: 8px; }

.invite-box { padding: 16px 0 32px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.invite-box b { color: var(--ember); letter-spacing: .2em; }

.settings-wrap { display: flex; flex-direction: column; gap: 10px; padding: 12px 0 32px; }
.settings-wrap hr { border: none; border-top: 1px solid var(--smoke-2); width: 100%; margin: 16px 0; }

/* -------- modal + toast -------- */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal-card { background: var(--smoke); border-radius: 18px; padding: 22px; width: 100%; max-width: 380px; }
.modal-card h3 { margin: 0 0 8px; font-family: "Bricolage Grotesque", sans-serif; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--smoke-2); color: var(--bone); border-radius: 12px;
  padding: 12px 20px; z-index: 60; font-size: .9rem; max-width: 90vw;
}

/* ---------------- camp description and counting window ---------------- */
.field textarea, .field select {
  background: var(--smoke); color: var(--bone);
  border: 1px solid var(--smoke-2); border-radius: var(--radius);
  padding: 14px 16px; font-size: 1.05rem; outline: none;
  font-family: inherit; resize: vertical;
}
.field textarea:focus-visible, .field select:focus-visible { border-color: var(--ember); }
.window-row { display: flex; gap: 10px; }
.window-row .field { flex: 1; }
.camp-desc { margin: 4px 0 0; color: var(--bone); white-space: pre-wrap; overflow-wrap: anywhere; }
.camp-window-line { margin: 2px 0 8px; }

/* ---------------- notifications panel (Paziņojumi), rendered by push.js ----
 * Same smoke card, same hint colour and same checkbox rows as the rest of
 * the settings screen, so it reads as part of the app and not as a new tab. */
.np-panel { display: flex; flex-direction: column; gap: 10px; }
.np-h { font-family: "Bricolage Grotesque", sans-serif; font-weight: 600; font-size: 1.1rem; margin: 0; }
.np-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  background: var(--smoke); border-radius: var(--radius); padding: 13px 16px; cursor: pointer;
}
.np-label { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.np-label small { color: var(--ash); font-size: .82rem; line-height: 1.45; }
.np-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; flex: none;
  width: 46px; height: 28px; border-radius: 14px; background: var(--smoke-2);
  border: 1px solid var(--smoke-2); position: relative; cursor: pointer; margin: 0;
  transition: background .2s;
}
.np-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--ash); transition: transform .2s, background .2s;
}
.np-row input[type="checkbox"]:checked { background: var(--ember-deep); border-color: var(--ember-deep); }
.np-row input[type="checkbox"]:checked::after { transform: translateX(18px); background: var(--bone); }
.np-row input[type="checkbox"]:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.np-trust { margin: 2px 0 0; font-style: italic; }
