/* Boulder web app — phone-first, brand-matched dark theme. */
:root {
  --bg-1: #06010f;
  --bg-2: #1a1230;
  --bg-3: #2b2244;
  --pink: #ff6b6b;
  --magenta: #c147ff;
  --blue: #47a0ff;
  --mint: #2ee6a0;
  --gold: #ffd960;
  --ink-1: rgba(255, 255, 255, 0.94);
  --ink-2: rgba(255, 255, 255, 0.55);
  --ink-3: rgba(255, 255, 255, 0.35);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  color: var(--ink-1);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}
body { padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: 0.2px; }
.brand-name { font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.sync-status {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-3);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
}
.sync-status.synced { color: var(--mint); border-color: rgba(46, 230, 160, 0.4); background: rgba(46, 230, 160, 0.08); }
.sync-status.syncing { color: var(--gold); border-color: rgba(255, 217, 96, 0.4); background: rgba(255, 217, 96, 0.08); }
.sync-status.error { color: var(--pink); border-color: rgba(255, 107, 107, 0.4); background: rgba(255, 107, 107, 0.08); }
.icon-btn {
  background: transparent; border: none; color: var(--ink-2);
  font-size: 20px; cursor: pointer;
  padding: 4px 8px; border-radius: 8px;
}
.icon-btn:hover { color: white; background: rgba(255, 255, 255, 0.05); }

.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 18px 80px;
}

.hero { text-align: center; padding: 20px 0 8px; }
.tier { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.tier-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.grain-count { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.hero-row {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap;
  margin-top: 8px;
}
.momentum {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px;
  background: rgba(46, 230, 160, 0.10);
  border: 1px solid rgba(46, 230, 160, 0.30);
  border-radius: 999px;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.02em;
}
.momentum .dot {
  width: 5px; height: 5px;
  background: var(--mint);
  border-radius: 50%;
  box-shadow: 0 0 5px var(--mint);
}
.momentum .m-tier { color: white; }
.momentum .m-mult { color: var(--gold); font-variant-numeric: tabular-nums; }
.pending-badge {
  display: inline-flex; align-items: center;
  padding: 4px 8px;
  background: rgba(255, 217, 96, 0.10);
  border: 1px solid rgba(255, 217, 96, 0.35);
  border-radius: 999px;
  color: var(--gold);
  font-size: 11px; font-weight: 800;
  letter-spacing: 0.02em;
}

.canvas-wrap {
  position: relative;
  margin: 12px 0;
  height: 240px;
  border-radius: 18px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, 0.04), transparent 70%);
  border: 1px solid var(--line);
  overflow: hidden;
}
#rock { display: block; width: 100%; height: 100%; }
.rock-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(20, 12, 36, 0.96);
  color: white;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 217, 96, 0.4);
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 11px;
  line-height: 1.45;
  opacity: 0;
  transition: opacity 0.12s ease-out;
  max-width: 220px;
  z-index: 5;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}
.rock-tooltip .tt-title { font-weight: 800; font-size: 12px; margin-bottom: 2px; }
.rock-tooltip .tt-tag   { color: var(--gold); font-weight: 700; }
.rock-tooltip .tt-when  { color: rgba(255, 255, 255, 0.55); font-size: 10px; margin-top: 2px; }
.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 20px;
}
.empty-rock { font-size: 52px; opacity: 0.55; }
.empty div { color: var(--ink-2); font-size: 14px; font-weight: 600; }
.empty-sub { color: var(--ink-3) !important; font-size: 12px !important; font-weight: 400 !important; }

.action-row {
  display: flex; gap: 10px;
  margin-bottom: 12px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px;
  padding: 12px 18px;
  font-family: inherit; font-size: 14px; font-weight: 800;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: transform 0.12s ease-out, box-shadow 0.12s, opacity 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-claim {
  flex: 1;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--magenta));
  color: rgba(0, 0, 0, 0.88);
  box-shadow: 0 8px 22px rgba(255, 217, 96, 0.32);
}
.btn-share {
  flex: 1;
  background: linear-gradient(90deg, var(--pink), var(--magenta));
  color: white;
  box-shadow: 0 8px 22px rgba(193, 71, 255, 0.32);
}
.btn-share.compact { flex: 0 0 auto; padding: 12px 16px; }
.btn-share .btn-share-label { display: inline; }

.tag-section { margin-bottom: 14px; }
.tag-section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.tag-manage-btn {
  background: transparent;
  border: none;
  color: var(--ink-2);
  font-family: inherit;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.tag-manage-btn:hover { color: white; background: rgba(255,255,255,0.04); }
.tag-row {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.tag:hover { color: white; background: rgba(255, 255, 255, 0.07); }
.tag.active {
  border-color: var(--mint);
  background: rgba(46, 230, 160, 0.12);
  color: white;
}
.tag-emoji { font-size: 14px; }
.tag-add {
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--ink-3);
}
.tag-add:hover { color: white; border-color: var(--ink-2); }

.focus-block { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field-label .muted { color: var(--ink-3); font-weight: 500; text-transform: none; letter-spacing: 0; }

input[type="text"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: white;
  font-family: inherit; font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  outline: none;
  transition: border-color 0.12s, background 0.12s;
}
input[type="text"]:focus { border-color: var(--magenta); background: rgba(255, 255, 255, 0.07); }

.duration-row { display: flex; gap: 6px; margin-top: 12px; }
.chip {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 10px 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover { background: rgba(255, 255, 255, 0.08); color: white; }
.chip.active {
  background: rgba(193, 71, 255, 0.18);
  border-color: rgba(193, 71, 255, 0.55);
  color: white;
}

.timer-row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.timer {
  flex: 1;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", monospace;
  font-size: 32px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.btn-focus {
  background: linear-gradient(90deg, var(--mint), var(--blue));
  color: rgba(0, 0, 0, 0.85);
  padding: 14px 28px;
  font-size: 15px;
  box-shadow: 0 8px 22px rgba(46, 230, 160, 0.32);
}
.btn-focus.focusing {
  background: linear-gradient(90deg, var(--pink), var(--magenta));
  color: white;
}

.bottom-tip {
  margin-top: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

/* Modal + Sheet shared */
.modal, .sheet {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  z-index: 100;
}
.modal-card, .sheet-card {
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-3));
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 28px 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.7);
}
.modal-card { text-align: center; }
.modal-emoji {
  font-size: 56px;
  filter: drop-shadow(0 0 18px rgba(193, 71, 255, 0.4));
}
.modal-card h1 {
  margin: 10px 0 4px;
  font-size: 24px; font-weight: 800; letter-spacing: -0.01em;
}
.modal-card > p {
  font-size: 13px; color: var(--ink-2);
  margin-bottom: 18px;
}
.modal-card .field-label { text-align: left; margin-top: 10px; }
.btn-start {
  margin-top: 18px;
  width: 100%;
  background: linear-gradient(90deg, var(--gold), var(--pink), var(--magenta));
  color: rgba(0, 0, 0, 0.85);
  padding: 14px 0;
  font-size: 15px;
}
.btn-start:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-3);
  box-shadow: none;
}
.onb-foot { margin-top: 14px; font-size: 11px; color: var(--ink-3); }

.onb-pair-link {
  margin-top: 14px;
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  font-family: inherit; font-size: 12px; font-weight: 600;
  padding: 8px 0;
  cursor: pointer;
}
.onb-pair-link:hover { color: white; }
.onb-pair-help { margin-top: 6px; }
.onb-pair-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--pink);
  text-align: left;
}
.btn-pair {
  margin-top: 14px;
  width: 100%;
  background: linear-gradient(90deg, var(--mint), var(--blue), var(--magenta));
  color: rgba(0, 0, 0, 0.85);
  padding: 14px 0;
  font-size: 15px;
}
.btn-pair:disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink-3);
  box-shadow: none;
}

/* Tag editor sheet */
.hue-swatch-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.hue-swatch {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--line);
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease-out;
  -webkit-tap-highlight-color: transparent;
}
.hue-swatch:hover { transform: scale(1.06); }
.hue-swatch.selected {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 18px rgba(255, 217, 96, 0.35);
}
.hue-swatch-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.03em;
  color: rgba(0, 0, 0, 0.55);
  position: absolute;
  bottom: 4px; left: 0; right: 0;
  text-align: center;
}
.tag-sheet-actions {
  display: flex; align-items: center; gap: 8px;
  margin-top: 18px;
}
.tag-sheet-actions .spacer { flex: 1; }
.btn-primary-small {
  background: linear-gradient(90deg, var(--mint), var(--blue));
  border: none;
  color: rgba(0, 0, 0, 0.85);
  font-family: inherit; font-size: 13px; font-weight: 800;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-primary-small:hover { transform: translateY(-1px); }

.toggle-row {
  display: flex; align-items: center; gap: 10px;
  margin-top: 8px;
  font-size: 14px;
  cursor: pointer;
}
.toggle-row input[type="checkbox"] {
  width: 18px; height: 18px;
  cursor: pointer;
  accent-color: var(--mint);
}

.groups-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.group-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
}
.group-item .group-name { font-weight: 700; flex: 1; }
.group-item .group-code {
  font-family: ui-monospace, monospace;
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.1em;
}
.group-item a {
  font-size: 11px; font-weight: 700;
  color: var(--blue);
}
.group-item .group-leave {
  background: transparent; border: none;
  color: var(--pink);
  font-size: 14px; cursor: pointer;
  padding: 2px 6px;
}
.groups-actions { display: flex; gap: 8px; margin-top: 10px; }

.sheet-card { position: relative; }
.sheet-card h2 { font-size: 20px; font-weight: 800; margin-bottom: 16px; }
.sheet-card section { margin-bottom: 18px; }
.sheet-close {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: none; color: white;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.sheet-foot { font-size: 12px; color: var(--ink-2); text-align: center; }

.sync-id-row { display: flex; gap: 8px; align-items: center; }
.sync-id {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 10px;
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.btn-small {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  color: white;
  font-family: inherit; font-size: 12px; font-weight: 700;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.btn-small:hover { background: rgba(255, 255, 255, 0.13); }
.btn-danger {
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: var(--pink);
  font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(255, 107, 107, 0.2); }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

[hidden] { display: none !important; }
