/* Upkeep. Game Table theme first; the other two themes redefine the tokens later. */

:root {
  --bg: #111913;
  --surface: #182219;
  --surface-2: #121B15;
  --line: #27352B;
  --line-2: #3B4F42;
  --fg: #EDE9DF;
  --muted: #9AA89E;
  --muted-2: #B9C2B6;
  --accent: #E0A93A;
  --accent-ink: #1A1407;
  --accent-soft: rgba(224, 169, 58, 0.12);
  --accent-line: rgba(224, 169, 58, 0.35);
  --green: #3E9D6A;
  --green-ink: #06140C;
  --danger: #E0614F;
  --mana-w: #F3EBC7;
  --mana-u: #4A8FD9;
  --mana-b: #5B4D66;
  --mana-r: #D64B3B;
  --mana-g: #3E9D6A;
  --f-body: 'Manrope', system-ui, -apple-system, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --radius: 14px;
  --radius-lg: 20px;
  --nav-h: 76px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

/* Per-person accent colors, used for avatars and the join splash. */
.ac-amber { --ac: #E0A93A; --ac-ink: #1A1407; }
.ac-green { --ac: #3E9D6A; --ac-ink: #06140C; }
.ac-blue  { --ac: #4A8FD9; --ac-ink: #0B1220; }
.ac-red   { --ac: #D64B3B; --ac-ink: #FFFFFF; }
.ac-white { --ac: #F3EBC7; --ac-ink: #1A1407; }
.ac-black { --ac: #5B4D66; --ac-ink: #F3EBC7; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 30px; font-weight: 800; line-height: 1.1; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- layout ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding-left: max(16px, var(--safe-left));
  padding-right: max(16px, var(--safe-right));
  padding-block: calc(14px + var(--safe-top)) calc(var(--nav-h) + var(--safe-bottom) + 24px);
  gap: 14px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
}
.screen.no-nav { padding-bottom: calc(24px + var(--safe-bottom)); }
.screen.center { justify-content: center; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.topbar .title { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.topbar .spacer { width: 40px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card.hero {
  background: linear-gradient(160deg, #1D2B22, #162019);
  border-color: #2B3D31;
}
.card.gold {
  background: linear-gradient(160deg, #2A2414, #182219 60%);
  border-color: #4A3E1E;
}
.hr { height: 1px; background: var(--line); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--fg);
  font-weight: 700; font-size: 16px; text-decoration: none; width: 100%;
  transition: transform .08s ease, background-color .12s ease;
}
.btn:active { transform: scale(0.985); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 800; }
.btn.green { background: var(--green); border-color: var(--green); color: var(--green-ink); font-weight: 800; }
.btn.quiet { background: transparent; color: var(--muted-2); border-color: var(--line); }
.btn.danger { color: var(--danger); border-color: rgba(224, 97, 79, 0.5); background: transparent; }
.btn.small { min-height: 40px; padding: 0 14px; font-size: 14px; width: auto; }
.btn.tiny { min-height: 32px; padding: 0 10px; font-size: 12px; width: auto; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: var(--fg); padding: 0; flex: 0 0 auto;
}
.icon-btn svg, .btn svg { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--muted-2); }
.input {
  width: 100%; min-height: 52px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line-2); background: var(--surface-2); color: var(--fg); font-size: 17px;
}
.input::placeholder { color: var(--muted); }
.input.code { font-family: var(--f-mono); font-size: 28px; letter-spacing: 0.35em; text-align: center; text-transform: uppercase; }
textarea.input { min-height: 96px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; font-weight: 600; }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--fg); font-weight: 700; font-size: 14px;
  display: inline-flex; align-items: center; gap: 8px;
}
.pill.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #23302A; color: var(--muted-2); }
.chip.accent { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 52px; padding: 10px 0; }
.toggle .t-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.toggle .t-text b { font-size: 15px; }
.toggle .t-text span { font-size: 13px; color: var(--muted); }
.switch {
  width: 50px; height: 30px; border-radius: 999px; background: #23302A; border: 1px solid var(--line-2);
  position: relative; flex: 0 0 auto; padding: 0;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted-2); transition: transform .15s ease, background-color .15s ease;
}
.switch[aria-checked="true"] { background: var(--green); border-color: var(--green); }
.switch[aria-checked="true"]::after { transform: translateX(20px); background: #06140C; }

/* ---------- people ---------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--ac, var(--accent)); color: var(--ac-ink, var(--accent-ink));
  display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
  flex: 0 0 auto; overflow: hidden; border: 2px solid var(--surface);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.member { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member .m-text { display: flex; flex-direction: column; min-width: 0; }
.member .m-text b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member .m-text span { font-size: 12px; color: var(--muted); }

.mana { display: inline-flex; gap: 4px; }
.mana i { width: 10px; height: 10px; border-radius: 50%; display: block; }
.mana .w { background: var(--mana-w); } .mana .u { background: var(--mana-u); } .mana .b { background: var(--mana-b); }
.mana .r { background: var(--mana-r); } .mana .g { background: var(--mana-g); }

.accent-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.accent-picker button {
  width: 44px; height: 44px; border-radius: 50%; border: 3px solid transparent; background: var(--ac); padding: 0;
}
.accent-picker button.on { border-color: var(--fg); box-shadow: 0 0 0 2px var(--bg) inset; }

/* ---------- pod code ---------- */
.code-big {
  font-family: var(--f-mono); font-size: 34px; font-weight: 700; letter-spacing: 0.12em; text-align: center;
  padding: 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed var(--line-2);
}

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 8px max(12px, var(--safe-right)) calc(10px + var(--safe-bottom)) max(12px, var(--safe-left));
  background: #0E150F; border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0;
  font-size: 11px; font-weight: 700; color: #8C9A90; text-decoration: none;
}
.nav a svg { width: 22px; height: 22px; }
.nav a.on { color: var(--accent); }
.nav a.soon { opacity: .5; }

/* ---------- sheets, toast, splash ---------- */
#layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.sheet-wrap { position: absolute; inset: 0; pointer-events: auto; background: rgba(5, 9, 6, 0.6); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.sheet {
  width: 100%; max-width: 560px; max-height: 88%; overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 14px max(18px, var(--safe-right)) calc(22px + var(--safe-bottom)) max(18px, var(--safe-left));
  display: flex; flex-direction: column; gap: 12px; animation: up .2s ease;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto 4px; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-bottom) + 16px); transform: translateX(-50%);
  z-index: 50; pointer-events: none; display: flex; flex-direction: column; gap: 8px; align-items: center; width: calc(100% - 32px); max-width: 480px;
}
.toast-item {
  background: #0E150F; border: 1px solid var(--line-2); color: var(--fg); padding: 12px 16px; border-radius: 12px;
  font-weight: 700; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: up .2s ease; text-align: center;
}
.toast-item.err { border-color: var(--danger); color: var(--danger); }

.note-fab {
  position: fixed; right: max(14px, var(--safe-right)); bottom: calc(var(--nav-h) + var(--safe-bottom) + 14px); z-index: 30;
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line-2); background: #0E150F; color: var(--muted-2);
  display: inline-flex; align-items: center; justify-content: center; padding: 0; box-shadow: 0 6px 20px rgba(0,0,0,.45);
}
.note-fab svg { width: 18px; height: 18px; }
.no-nav ~ .note-fab, body.no-nav .note-fab { bottom: calc(16px + var(--safe-bottom)); }

/* The join splash: a challenger-style announcement. */
.splash {
  position: absolute; inset: 0; pointer-events: auto; overflow: hidden; cursor: pointer;
  background: radial-gradient(ellipse at 50% 30%, color-mix(in srgb, var(--ac) 35%, #0E150F), #070B08 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center;
  padding: 24px; animation: fade .2s ease;
}
.splash .burst {
  position: absolute; inset: -40%; background: repeating-conic-gradient(from 0deg, transparent 0 20deg, color-mix(in srgb, var(--ac) 18%, transparent) 20deg 30deg, transparent 30deg 45deg);
  animation: spin 40s linear infinite; opacity: .7;
}
@keyframes spin { to { transform: rotate(360deg); } }
.splash .eyebrow { color: var(--muted-2); position: relative; animation: fade .4s ease .9s both; }
.splash .banner {
  position: relative; width: min(86vw, 420px); padding: 26px 20px; border-radius: 24px;
  background: var(--ac); color: var(--ac-ink); display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: slide-in .5s cubic-bezier(.2,.9,.25,1.1) both;
}
@keyframes slide-in { from { transform: translateX(-120%) rotate(-6deg); } to { transform: none; } }
.splash .banner .avatar { width: 96px; height: 96px; font-size: 40px; border: 4px solid rgba(0,0,0,.18); background: rgba(0,0,0,.14); color: inherit; animation: pop .45s cubic-bezier(.2,.9,.25,1.3) .35s both; }
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
.splash .name { font-size: clamp(30px, 9vw, 44px); font-weight: 800; letter-spacing: -0.02em; line-height: 1; animation: stamp .35s cubic-bezier(.2,.9,.25,1.2) .6s both; }
@keyframes stamp { from { transform: scale(3); opacity: 0; } 70% { transform: scale(.94); opacity: 1; } to { transform: scale(1); } }
.splash .headline {
  position: relative; font-size: clamp(22px, 6.5vw, 32px); font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.1;
  color: var(--fg); text-shadow: 0 4px 24px rgba(0,0,0,.6); animation: stamp .4s cubic-bezier(.2,.9,.25,1.2) 1.0s both;
}
.splash .sub { position: relative; color: var(--muted-2); font-weight: 600; animation: fade .4s ease 1.4s both; }
.splash .hint { position: absolute; bottom: calc(28px + var(--safe-bottom)); font-size: 13px; color: var(--muted); animation: fade .6s ease 1.8s both; }

@media (prefers-reduced-motion: reduce) {
  .splash *, .sheet, .toast-item { animation-duration: .01s !important; animation-delay: 0s !important; }
}

/* ---------- misc ---------- */
.wordmark { font-weight: 800; font-size: 36px; letter-spacing: -0.03em; line-height: 1; }
.wordmark small { display: block; font-size: 14px; font-weight: 600; color: var(--muted-2); letter-spacing: 0; margin-top: 8px; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-item:first-child { border-top: 0; }
.list-item .li-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list-item .li-text b { font-size: 15px; }
.list-item .li-text span { font-size: 13px; color: var(--muted); }
.kbd { font-family: var(--f-mono); font-size: 13px; padding: 2px 6px; border-radius: 6px; background: #23302A; }
.note-row { display: flex; flex-direction: column; gap: 6px; padding: 12px 0; border-top: 1px solid var(--line); }
.note-row:first-child { border-top: 0; }
.status { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: #23302A; color: var(--muted-2); }
.status.looking { background: rgba(74,143,217,.18); color: #8FB4DE; }
.status.fixed { background: rgba(62,157,106,.2); color: #9FDDB9; }
.status.closed { opacity: .6; }
select.input { appearance: none; min-height: 44px; padding: 8px 12px; font-size: 15px; }
.gis-wrap { display: flex; justify-content: center; min-height: 44px; }
.install-step { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.install-num { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.install-art { margin-left: auto; color: var(--accent); display: inline-flex; }
