:root {
  --cyan: #00E5FF; --cyan-bright: #6EFFFF; --cyan-dim: #00838F; --cyan-deep: #003A40;
  --bg: #000; --carbon: #0B0F10; --graphite: #141B1D; --steel: #1E2A2D;
  --text: #E6FBFF; --muted: #9FC4CA; --error: #FF6E6E;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--cyan); }
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; position: relative; }

/* Top bar */
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: calc(8px + var(--safe-top)) 8px 8px; background: var(--bg); border-bottom: 1px solid var(--steel); }
.bar h1 { flex: 1; font-size: 20px; margin: 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .logo { width: 36px; height: 36px; margin-left: 4px; }
.icon-btn { background: none; border: 0; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--text); }
.icon-btn:active { background: var(--steel); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

.page { padding: 12px 16px 120px; }
.page.with-nav { padding-bottom: calc(150px + var(--safe-bottom)); }

/* Buttons */
.btn { border: 0; border-radius: 22px; padding: 10px 20px; background: var(--cyan); color: #000; font-weight: 700; cursor: pointer; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.outline { background: none; color: var(--cyan); border: 1.5px solid var(--cyan-dim); }
.btn.text { background: none; color: var(--cyan); padding: 8px 10px; }
.btn.danger { color: var(--error); }
.btn.block { width: 100%; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Floating action button */
.fab { position: fixed; right: max(16px, calc(50vw - 364px)); bottom: calc(84px + var(--safe-bottom)); z-index: 11;
  background: var(--cyan); color: #000; border: 0; border-radius: 18px; padding: 15px 20px; font-weight: 800;
  box-shadow: 0 4px 24px rgba(0,229,255,.35); cursor: pointer; display: flex; gap: 8px; align-items: center; }
.fab.solo { bottom: calc(20px + var(--safe-bottom)); }

/* Bottom nav */
.nav { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 760px; z-index: 10;
  display: flex; background: var(--carbon); border-top: 1px solid var(--steel); padding-bottom: var(--safe-bottom); }
.nav button { flex: 1; background: none; border: 0; padding: 8px 2px 10px; color: var(--muted); cursor: pointer; font-size: 12px; position: relative; }
.nav button svg { width: 24px; height: 24px; fill: currentColor; display: block; margin: 0 auto 2px; }
.nav button.on { color: var(--cyan); }
.badge { position: absolute; top: 4px; left: calc(50% + 6px); background: var(--cyan); color: #000; border-radius: 9px; font-size: 11px; font-weight: 800; padding: 0 6px; }

/* Lists and cards */
.card { background: var(--graphite); border-radius: 16px; padding: 16px; margin: 0 0 12px; }
.card.hl { background: var(--cyan-deep); }
.card.tap, .item.tap { cursor: pointer; }
.item { display: flex; align-items: center; gap: 14px; padding: 12px 4px; border-bottom: 1px solid var(--steel); }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 650; }
.item .sub { color: var(--muted); font-size: 14px; }
.item .over { color: var(--muted); font-size: 12px; }
.rank { width: 30px; font-size: 22px; font-weight: 800; }
.big { font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.label { color: var(--cyan); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; font-weight: 700; }
.section { color: var(--cyan); font-weight: 800; margin: 18px 0 8px; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; white-space: pre-line; }
.error { color: var(--error); }

.tagbadge { min-width: 52px; height: 36px; padding: 0 8px; border-radius: 8px; display: grid; place-items: center;
  background: var(--cyan-deep); color: var(--cyan-bright); font-weight: 800; font-size: 17px; flex: none; }
.tagbadge.one { background: var(--cyan); color: #000; }

/* Chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1.5px solid var(--steel); background: none; color: var(--text); border-radius: 10px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.chip.on { background: var(--cyan-deep); border-color: var(--cyan); color: var(--cyan-bright); }

/* Forms */
.field { display: block; margin: 0 0 12px; }
.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field textarea, .field select { width: 100%; background: var(--carbon); border: 1.5px solid var(--steel); border-radius: 10px; padding: 12px; outline: none; }
.field input:focus, .field textarea:focus { border-color: var(--cyan); }
.score-input { width: 84px; background: var(--carbon); border: 1.5px solid var(--steel); border-radius: 10px; padding: 10px; text-align: center; font-size: 18px; }
.switch { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--cyan); }
.check { width: 22px; height: 22px; accent-color: var(--cyan); }

/* Dialog */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.72); z-index: 50; display: grid; place-items: center; padding: 16px; }
.dialog { background: var(--graphite); border-radius: 22px; padding: 22px; width: 100%; max-width: 440px; max-height: 88vh; overflow: auto; }
.dialog h2 { margin: 0 0 12px; font-size: 20px; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 16px; }
.dialog.bare { background: none; padding: 0; text-align: center; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(96px + var(--safe-bottom)); z-index: 60;
  background: var(--steel); color: var(--text); padding: 12px 18px; border-radius: 12px; max-width: 90vw; box-shadow: 0 4px 20px rgba(0,0,0,.6); }

/* Digital bag tag */
.dtag { position: relative; width: 100%; max-width: 340px; aspect-ratio: .66; margin: 0 auto; border-radius: 28px; border: 3px solid var(--cyan);
  background: linear-gradient(180deg, var(--cyan-deep), var(--carbon) 35%, #000 70%); display: flex; flex-direction: column; align-items: center;
  padding: 18px 24px; text-align: center; overflow: hidden; }
.dtag::after { content: ""; position: absolute; inset: 8px; border: 1px solid var(--cyan-dim); border-radius: 22px; pointer-events: none; }
.dtag .hole { width: 26px; height: 26px; border-radius: 50%; background: #000; border: 3px solid var(--cyan); flex: none; }
.dtag .brand { margin-top: 10px; color: var(--cyan); font-weight: 900; letter-spacing: 6px; font-size: 18px; }
.dtag .grp { color: var(--cyan-bright); font-size: 13px; letter-spacing: 2px; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dtag .num { flex: 1; display: grid; place-items: center; color: var(--cyan); font-weight: 900; line-height: 1; text-shadow: 0 0 24px var(--cyan); }
.dtag hr { width: 100%; border: 0; border-top: 1px solid var(--cyan-dim); margin: 0 0 10px; }
.dtag .kind { font-size: 10px; letter-spacing: 3px; font-weight: 800; }
.dtag .who { font-size: 22px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.dtag .club { color: var(--muted); font-size: 13px; }
.tagrow { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 8px; }
.tagrow .dtag { width: 220px; flex: none; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.stats.four { grid-template-columns: repeat(4, 1fr); }
.stat { border: 1px solid var(--cyan-dim); border-radius: 14px; padding: 12px 6px; text-align: center; }
.stat b { display: block; color: var(--cyan); font-size: 24px; font-weight: 900; }
.stat span { font-size: 11px; color: var(--muted); }

/* Challenge card */
.vs { display: flex; align-items: center; gap: 8px; margin: 8px 0; }
.vs .side { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; min-width: 0; }
.vs .side .nm { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs .x { color: var(--cyan); font-weight: 900; }
.vs .sc { font-size: 22px; font-weight: 800; }

/* Auth */
.auth { padding: calc(24px + var(--safe-top)) 24px 48px; max-width: 420px; margin: 0 auto; text-align: center; }
.auth img { width: 220px; height: 220px; }
.auth .field { text-align: left; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); margin: 14px 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--steel); }
.ios-tip { margin-top: 28px; padding: 14px; border: 1px dashed var(--cyan-dim); border-radius: 14px; font-size: 14px; color: var(--muted); }
.code { font: 800 30px ui-monospace, Menlo, monospace; letter-spacing: 4px; }
