:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f232c;
  --border: #2a2f3a;
  --text: #eef0f3;
  --text-dim: #9aa1ad;
  --accent: #5b8def;
  --accent-2: #ff8a5b;
  --success: #3ecf8e;
  --danger: #ef5b5b;
  --warn: #f4c152;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  height: 100%;
}

body { padding-bottom: calc(64px + var(--safe-bottom)); }

a { color: inherit; }

button, input, select { font-family: inherit; font-size: inherit; }

.hidden { display: none !important; }

/* Extra breathing room at the bottom so the last card on any scrollable
   screen (e.g. the bottom of Admin > Users, or Admin > Settings) never sits
   underneath the fixed bottom nav bar. Written as individual sides (not the
   `padding` shorthand) so a later rule can't silently reset this again. */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding-top: 16px;
  padding-left: 16px;
  padding-right: 16px;
  padding-bottom: calc(96px + var(--safe-bottom));
}

.center-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

h1, h2, h3 { margin: 0 0 12px 0; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }

p { line-height: 1.4; }

label { display: block; font-size: .85rem; color: var(--text-dim); margin: 10px 0 4px; }

input[type=text], input[type=password], input[type=number], input[type=email], input[type=date], select, textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 13px 18px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  min-height: 46px;
  width: 100%;
  transition: transform .05s ease, opacity .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); color: #06281a; }
.btn.small { width: auto; padding: 8px 14px; min-height: 36px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.error-text { color: var(--danger); font-size: .85rem; margin-top: 6px; min-height: 1em; }
.success-text { color: var(--success); font-size: .85rem; margin-top: 6px; }
.hint { color: var(--text-dim); font-size: .8rem; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  background: rgba(15,17,21,.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .logout-btn { background: none; border: none; color: var(--text-dim); font-size: .85rem; }

/* Bottom nav */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.bottom-nav button {
  flex: 1; background: none; border: none; color: var(--text-dim);
  padding: 10px 4px 8px; font-size: .72rem; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.bottom-nav button .icon { font-size: 1.3rem; }
.bottom-nav button.active { color: var(--accent); }

/* Exercise task card (Today screen) */
.task-card { display: flex; align-items: center; gap: 12px; }
.task-card .task-info { flex: 1; min-width: 0; }
.task-card .task-name { font-weight: 600; }
.task-card .task-target { color: var(--text-dim); font-size: .9rem; }
.task-card .rest-badge { display: inline-block; background: var(--surface-2); color: var(--warn); font-size: .75rem; padding: 2px 8px; border-radius: 20px; margin-top: 4px; }
.done-btn {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); font-size: 1.6rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.done-btn.completed { background: var(--success); border-color: var(--success); color: #06281a; }

.help-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); font-weight: 700; font-size: .95rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.countdown-banner {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px; font-size: .85rem; color: var(--text-dim); text-align: center;
}

/* Status / head-to-head */
.vs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.profile-box .avatar {
  width: 56px; height: 56px; border-radius: 50%; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.2rem;
  margin: 0 auto 8px;
}
.profile-box.me .avatar { background: var(--accent); color: white; }
.profile-box.opponent .avatar { background: var(--accent-2); color: #2a1200; }
.profile-box .avatar-img {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 8px; display: block; border: 2px solid var(--border);
}
.profile-box.me .avatar-img { border-color: var(--accent); }
.profile-box.opponent .avatar-img { border-color: var(--accent-2); }
.profile-box .name { font-weight: 600; }
.profile-box .lives { margin-top: 6px; font-size: .9rem; }
.profile-box .points { color: var(--text-dim); font-size: .85rem; margin-top: 2px; }
.profile-box .strikes-indicator { margin-top: 6px; font-size: .78rem; color: var(--warn); }
.profile-box .forfeited-tag { margin-top: 6px; font-size: .78rem; color: var(--danger); font-weight: 600; }

/* Circular avatar preview shown in the "My account" modal */
.avatar-preview-img {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border);
}
.avatar-preview-fallback {
  width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: white;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem;
}

.progress-compare { margin: 16px 0; }
.ex-block-title { text-align: center; font-weight: 600; margin: 18px 0 10px; }
.ex-block-title:first-child { margin-top: 0; }

/* Segmented ("servings"-style) progress meter - one block per growth step */
.segbar-wrap { margin-bottom: 16px; }
.segbar-header { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-dim); margin-bottom: 6px; }
.segbar-header .me-pct { color: var(--accent); }
.segbar-header .opponent-pct { color: var(--accent-2); }
.segmented-bar { display: flex; gap: 3px; }
.segmented-bar .seg { flex: 1; height: 14px; border-radius: 3px; background: var(--surface-2); }
.segmented-bar .seg.filled.me { background: var(--accent); }
.segmented-bar .seg.filled.opponent { background: var(--accent-2); }
.segbar-endpoints { display: flex; justify-content: space-between; font-size: .72rem; color: var(--text-dim); margin-top: 4px; }

/* Two-column event timeline, one side per person */
.timeline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 14px; }
.timeline-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.timeline-col h3 { margin-bottom: 10px; }
.timeline-item { position: relative; padding: 8px 0 8px 14px; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-item::before { content: ''; position: absolute; left: 0; top: 14px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.timeline-item.opponent::before { background: var(--accent-2); }
.timeline-date { font-size: .68rem; color: var(--text-dim); }
.timeline-detail { font-size: .82rem; margin-top: 2px; line-height: 1.3; }

.winner-banner {
  background: linear-gradient(135deg, var(--success), #2a9d6f);
  color: #06281a; text-align: center; padding: 14px; border-radius: var(--radius);
  font-weight: 700; margin-bottom: 14px;
}

/* Lists */
.list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: none; }

.tag { display: inline-block; background: var(--surface-2); border-radius: 20px; padding: 2px 10px; font-size: .75rem; color: var(--text-dim); }
.tag.active { color: var(--success); }
.tag.pending { color: var(--warn); }

.tabs-row { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.tabs-row button { flex-shrink: 0; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-dim); }
.tabs-row button.active { background: var(--accent); color: white; border-color: var(--accent); }

.fab {
  position: fixed; right: 18px; bottom: calc(76px + var(--safe-bottom)); z-index: 8;
  width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: white;
  border: none; font-size: 1.8rem; box-shadow: 0 6px 18px rgba(0,0,0,.4);
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--surface); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 18px; max-height: 88vh; overflow-y: auto;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.modal-sheet .modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-sheet .close-btn { background: none; border: none; color: var(--text-dim); font-size: 1.4rem; }

.exercise-block { border: 1px dashed var(--border); border-radius: 12px; padding: 12px; margin-bottom: 12px; position: relative; }
.exercise-block .remove-ex { position: absolute; top: 8px; right: 8px; background: none; border: none; color: var(--danger); font-size: 1.1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.spinner { text-align: center; padding: 30px; color: var(--text-dim); }

.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.checkbox-row input { width: auto; }
