:root {
  --background: #0b0f17;
  --surface: #131a26;
  --surface-2: #1b2433;
  --border: #26314a;
  --foreground: #e6edf7;
  --muted: #8b96ab;
  --accent: #22d3a0;
  --accent-2: #38bdf8;
  --danger: #f87171;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--background);
  color: var(--foreground);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: 1rem; }
input[type=number] { appearance: textfield; -moz-appearance: textfield; }

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.app-main { flex: 1; padding: 1rem; padding-bottom: 7rem; }
.guest-main { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 1.5rem; }

.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.top-bar .bold { font-weight: 600; }

.avatar {
  width: 40px; height: 40px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem;
}

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
}
.bottom-nav-inner {
  max-width: 640px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(5, 1fr);
}
.nav-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: .65rem 0; gap: .25rem;
  color: var(--muted); font-size: .72rem; font-weight: 500;
}
.nav-tab.active { color: var(--accent); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
}
.card-lg { padding: 1.25rem; }

.stack > * + * { margin-top: .75rem; }
.stack-lg > * + * { margin-top: 1rem; }

.row { display: flex; gap: .5rem; }
.row-grow > * { flex: 1; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; font-weight: 600; margin: 0 0 .25rem; }
h3 { font-size: .95rem; font-weight: 600; margin: 0 0 .25rem; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.xs { font-size: .72rem; }
.bold { font-weight: 700; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .65rem 1rem; border-radius: .75rem;
  font-weight: 600; font-size: 1rem; cursor: pointer;
  border: 0; transition: transform .05s, background .15s, opacity .15s;
  text-align: center; line-height: 1.2;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #05241b; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { background: var(--surface-2); color: var(--foreground); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-danger { color: var(--danger); background: var(--surface-2); border: 1px solid var(--border); }
.btn-full { width: 100%; }
.btn-lg { padding: .9rem 1rem; font-size: 1rem; }
.btn-sm { padding: .4rem .75rem; font-size: .85rem; border-radius: .6rem; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

.input, .select, textarea.input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: .75rem;
  padding: .65rem .9rem; color: var(--foreground); width: 100%; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b96ab' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .8rem center; padding-right: 2.2rem; }
.label { font-size: .72rem; text-transform: uppercase; font-weight: 600; color: var(--muted); letter-spacing: .04em; margin-bottom: .3rem; display: block; }

.alert { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.4); color: var(--danger); padding: .6rem .9rem; border-radius: .6rem; font-size: .85rem; }
.alert-info { background: rgba(56,189,248,.1); border: 1px solid rgba(56,189,248,.4); color: var(--accent-2); padding: .6rem .9rem; border-radius: .6rem; font-size: .85rem; }

.progress-track { background: var(--surface-2); height: 8px; border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s ease; }

.pill-group { display: flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: .75rem; padding: .25rem; }
.pill { flex: 1; text-align: center; padding: .5rem .75rem; border-radius: .55rem; font-weight: 600; font-size: .85rem; color: var(--muted); cursor: pointer; background: none; border: 0; }
.pill.active { background: var(--accent); color: #05241b; }

.choice-row { display: flex; align-items: center; justify-content: space-between; background: var(--surface-2); border: 1px solid var(--border); border-radius: .75rem; padding: .75rem 1rem; cursor: pointer; width: 100%; text-align: left; color: inherit; }
.choice-row.active { background: rgba(34,211,160,.1); border-color: var(--accent); }
.choice-row .dot { width: 20px; height: 20px; border-radius: 999px; border: 2px solid var(--border); }
.choice-row.active .dot { border-color: var(--accent); background: var(--accent); }

.ring { position: relative; width: 96px; height: 96px; }
.ring svg { transform: rotate(-90deg); }
.ring .center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring .val { font-weight: 800; line-height: 1; }
.ring .tgt { font-size: .6rem; text-transform: uppercase; color: var(--muted); margin-top: 2px; }

.onboard-steps { display: flex; gap: .5rem; margin-bottom: 1rem; }
.onboard-steps > div { flex: 1; height: 6px; border-radius: 999px; background: var(--surface-2); }
.onboard-steps > div.done { background: var(--accent); }

.table-list > li + li { margin-top: .5rem; }
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; padding: .15rem .5rem; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

.code-box { background: var(--surface); border: 1px solid var(--border); border-radius: .75rem; padding: .5rem .75rem; text-align: center; }
.code-box .label { font-size: .6rem; }
.code-box .code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .25em; font-weight: 800; font-size: 1.1rem; }

.scan-wrap { aspect-ratio: 16/9; background: #000; border-radius: .85rem; overflow: hidden; position: relative; }
.scan-wrap video { width: 100%; height: 100%; object-fit: cover; }
.scan-wrap .frame {
  position: absolute; inset-inline: 1.5rem;
  top: 50%; transform: translateY(-50%);
  height: 90px;
  border: 2px solid var(--accent); border-radius: .5rem;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(0,0,0,.25);
}
.scan-wrap .placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: rgba(255,255,255,.7); font-size: .85rem; gap: .6rem;
  background: var(--surface-2);
}
.scan-wrap .placeholder[hidden] { display: none; }
.scan-wrap .placeholder .barcode-icon { width: 55%; max-width: 220px; height: auto; opacity: .45; }
.scan-wrap .placeholder .placeholder-text { font-weight: 500; letter-spacing: .02em; opacity: .8; }

.grams-row {
  display: flex; gap: .4rem; flex-wrap: wrap;
}
.grams-row .btn { flex: 1 1 0; min-width: 70px; white-space: nowrap; }
.grams-row .btn.active {
  background: var(--accent); color: #05241b; border-color: transparent;
}

.input-with-unit { position: relative; }
.input-with-unit .input { padding-right: 3.25rem; }
.input-with-unit .input-unit {
  position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: .85rem; pointer-events: none;
  user-select: none;
}

.leader-row { display: flex; align-items: center; gap: .75rem; background: var(--surface-2); border-radius: .85rem; padding: .75rem; }
.leader-row.me { background: rgba(34,211,160,.12); border: 1px solid rgba(34,211,160,.4); }
.leader-row .rank { font-size: 1.2rem; width: 2rem; text-align: center; }
.tabular { font-variant-numeric: tabular-nums; }

.text-accent { color: var(--accent); }
.text-accent-2 { color: var(--accent-2); }
.text-danger { color: var(--danger); }

.center-text { text-align: center; }
.space-y-2 > * + * { margin-top: .5rem; }
.space-y-3 > * + * { margin-top: .75rem; }
.space-y-4 > * + * { margin-top: 1rem; }

.kbd { font-family: ui-monospace, monospace; background: var(--surface-2); padding: .1rem .4rem; border-radius: .3rem; font-size: .8rem; }

.hr { height: 1px; background: var(--border); margin: .75rem 0; border: 0; }

.back-link { display: inline-flex; color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }

.lang-switch {
  display: inline-flex; gap: 2px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px; margin: 0;
}
.lang-pill {
  background: none; border: 0; color: var(--muted);
  padding: 4px 10px; border-radius: 999px;
  font-size: .72rem; font-weight: 700; letter-spacing: .04em; cursor: pointer;
}
.lang-pill.active { background: var(--accent); color: #05241b; }
.top-bar-right { display: flex; align-items: center; gap: .5rem; }
.guest-lang { position: absolute; top: 1rem; right: 1rem; }

@media (max-width: 380px) {
  .ring { width: 80px; height: 80px; }
  .ring .val { font-size: 1rem; }
}
