/* Valor styles, carried over from the M0 prototype.
   Visual language follows the mascot drawing: thick dark outlines, rounded
   chunky shapes, flat fills, a friendly rounded display font and a slight
   hand-made wobble. Colours come only from the --v-* role tokens that
   palette.ts derives, so any palette stays readable. */

:root {
  /* fallbacks match the default palette; palette.ts overrides them */
  --v-background: #efefd0; --v-surface: #f9f9ec; --v-surface2: #f3f3dc;
  --v-text: #004e89; --v-muted: #326f98; --v-ink: #001f37; --v-border: #001f37;
  --v-nav: #004e89; --v-nav-contrast: #efefd0; --v-focus: #004e89; --v-plate: #f9f9ec;
  --v-primary: #ff6b35; --v-primary-contrast: #001f37; --v-primary-text: #b24b25;
  --v-secondary: #004e89; --v-secondary-contrast: #f9f9ec; --v-secondary-text: #004e89;
  --v-accent: #1a659e; --v-accent-contrast: #f9f9ec; --v-accent-text: #1a659e;
  --v-success: #1e9e3e; --v-success-contrast: #001f37; --v-success-text: #107c2a;
  --v-danger: #bf2318; --v-danger-contrast: #f9f9ec; --v-danger-text: #bf2318;
  --v-warning: #f4a825; --v-warning-contrast: #001f37; --v-warning-text: #8f6216;

  --font-display: "Fredoka", "Nunito", ui-rounded, system-ui, sans-serif;
  --font-body: "Nunito", ui-rounded, system-ui, sans-serif;
  --line: 3px;
  --r-wobble: 22px 18px 24px 17px / 18px 24px 17px 22px;
  --r-wobble-sm: 14px 11px 15px 12px / 12px 15px 11px 14px;
  --drop: 0 4px 0 var(--v-ink);
  --gutter: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.45;
  color: var(--v-text);
  background: var(--v-nav);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; display: block; }
button, input { font: inherit; color: inherit; }
a { color: var(--v-primary-text); font-weight: 700; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
.break { overflow-wrap: anywhere; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--v-focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--v-background);
}
h1:focus-visible { outline: none; box-shadow: none; }

/* ------------------------------------------------------------ the stage */
.stage { min-height: 100%; }
.phone {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  height: 100vh;
  height: 100dvh;
  background: var(--v-background);
  overflow: hidden;
}
.desk-note { display: none; }

@media (min-width: 560px) and (min-height: 700px) {
  .stage {
    display: flex; align-items: center; justify-content: center; gap: 48px;
    min-height: 100vh; padding: 24px;
  }
  .phone {
    width: 410px; /* 390 px of screen inside a 10 px bezel */
    height: min(864px, calc(100vh - 48px));
    border: 10px solid var(--v-ink);
    border-radius: 52px;
    box-shadow: 0 10px 0 var(--v-ink);
    flex: none;
  }
}
@media (min-width: 1000px) and (min-height: 700px) {
  .desk-note {
    display: block; width: 240px; color: var(--v-nav-contrast);
  }
  .desk-note img { width: 96px; height: 96px; margin-bottom: 8px; }
  .desk-note .desk-title { font-family: var(--font-display); font-size: 40px; font-weight: 700; margin: 0 0 10px; line-height: 1; }
  .desk-note p { margin: 0 0 12px; }
  .desk-note a { color: var(--v-nav-contrast); }
}

/* --------------------------------------------------------- app + screens */
.app::-webkit-scrollbar { display: none; }
.app {
  scrollbar-width: none;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  position: relative; scroll-behavior: smooth;
  padding-top: env(safe-area-inset-top); /* the demo strip used to sit under the notch */
}
.screen { padding: 16px var(--gutter) 28px; display: flex; flex-direction: column; gap: 14px; }
.screen > p { margin: 0; }
.ic { width: 20px; height: 20px; flex: none; }
.rot90 { transform: rotate(90deg); }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--v-muted); }
.small { font-size: 13px; }
.fine { font-size: 13px; color: var(--v-muted); text-align: center; margin: 0; }
.eyebrow {
  font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--v-muted); margin: 0;
}
.display {
  font-family: var(--font-display); font-weight: 700; font-size: 30px; line-height: 1.1; margin: 0;
  letter-spacing: -0.01em; overflow-wrap: anywhere;
}
.lede { margin: 0; font-size: 17px; }
.hl {
  background: var(--v-primary); color: var(--v-primary-contrast);
  padding: 0 8px; border-radius: 10px 8px 12px 7px; border: var(--line) solid var(--v-ink);
  display: inline-block; transform: rotate(-1.5deg); line-height: 1.25;
}
.section-title {
  font-family: var(--font-display); font-weight: 700; font-size: 19px; margin: 8px 0 0;
  display: flex; align-items: center; gap: 8px;
}
.count {
  font-size: 13px; min-width: 24px; height: 24px; display: inline-grid; place-items: center; padding: 0 6px;
  background: var(--v-accent); color: var(--v-accent-contrast); border: 2px solid var(--v-ink); border-radius: 999px;
}

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--v-surface); color: var(--v-text);
  border: var(--line) solid var(--v-border); border-radius: var(--r-wobble);
  box-shadow: var(--drop);
  padding: 14px;
}
a.card { text-decoration: none; display: block; }
a.card.oath-card, a.card.duel-card { display: flex; }
a.card, button.card { cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease; }
a.card:hover, button.card:hover { transform: translateY(-1px) rotate(-0.3deg); }
a.card:active, button.card:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--v-ink); }
.list { display: flex; flex-direction: column; gap: 12px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 16px;
  font-family: var(--font-display); font-weight: 600; font-size: 16px; line-height: 1.15; text-align: center;
  color: var(--v-text); background: var(--v-surface);
  border: var(--line) solid var(--v-ink); border-radius: var(--r-wobble-sm);
  box-shadow: var(--drop); cursor: pointer; text-decoration: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--v-ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--v-primary); color: var(--v-primary-contrast); }
.btn-secondary { background: var(--v-secondary); color: var(--v-secondary-contrast); }
.btn-success { background: var(--v-success); color: var(--v-success-contrast); }
.btn-danger { background: var(--v-danger); color: var(--v-danger-contrast); }
.btn-danger-outline { background: var(--v-surface); color: var(--v-danger-text); }
.btn-ghost { background: var(--v-surface); }
.btn-lg { min-height: 56px; font-size: 19px; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; box-shadow: 0 3px 0 var(--v-ink); border-width: 2px; }
.btn-block { width: 100%; }
.btn.picked { box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18); transform: translateY(3px); }
.btn-danger-outline.picked { background: var(--v-danger); color: var(--v-danger-contrast); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > * { min-width: 0; }
.btn-back {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  background: none; border: 0; padding: 6px 8px 6px 0; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; color: var(--v-text);
}
.btn-icon {
  width: 44px; height: 44px; flex: none; display: inline-grid; place-items: center;
  background: var(--v-surface); color: var(--v-text);
  border: var(--line) solid var(--v-ink); border-radius: 50%; cursor: pointer; box-shadow: 0 3px 0 var(--v-ink);
}
.btn-icon:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--v-ink); }
.btn-icon-sm { width: 34px; height: 34px; border-width: 2px; box-shadow: none; }
.btn-icon-sm .ic { width: 18px; height: 18px; }
.btn-icon-primary { background: var(--v-primary); color: var(--v-primary-contrast); }

/* ------------------------------------------------------------ pills, chips */
.pill, .chip, .badge {
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
  font-weight: 800; font-size: 13px; line-height: 1;
  padding: 5px 10px; border-radius: 999px; border: 2px solid var(--v-ink);
  background: var(--v-surface2); color: var(--v-text);
}
.pill .ic, .chip .ic { width: 15px; height: 15px; }
.pill-sm { font-size: 11px; padding: 2px 7px; gap: 3px; vertical-align: 2px; }
.pill-sm .ic { width: 12px; height: 12px; }
.pill-success { background: var(--v-success); color: var(--v-success-contrast); }
.pill-danger { background: var(--v-danger); color: var(--v-danger-contrast); }
.pill-warning { background: var(--v-warning); color: var(--v-warning-contrast); }
.badge { background: var(--v-accent); color: var(--v-accent-contrast); align-self: flex-start; font-family: var(--font-display); font-weight: 600; }
.chip-valor { background: var(--v-surface); }
.chip-valor .ic { width: 17px; height: 17px; }
.chip-lg { font-size: 18px; padding: 6px 12px; }
.chip-lg .ic { width: 22px; height: 22px; }
.chip-iou { background: var(--v-accent); color: var(--v-accent-contrast); white-space: normal; line-height: 1.2; }
.chip-accent { background: var(--v-accent); color: var(--v-accent-contrast); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-choice { cursor: pointer; padding: 8px 12px; font-size: 14px; min-height: 36px; }
.chip-choice.on { background: var(--v-secondary); color: var(--v-secondary-contrast); box-shadow: 0 2px 0 var(--v-ink); }

/* ------------------------------------------------------------------ mascot */
.mascot { user-select: none; -webkit-user-drag: none; pointer-events: none; }
.plate {
  background: var(--v-plate); border: var(--line) solid var(--v-border); border-radius: 50%;
  display: grid; place-items: center; aspect-ratio: 1;
}
.bubble {
  position: relative; background: var(--v-surface); color: var(--v-text);
  border: var(--line) solid var(--v-ink); border-radius: 18px 16px 20px 14px;
  padding: 8px 12px; font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.25;
  box-shadow: 0 3px 0 var(--v-ink);
}
.bubble::after {
  content: ""; position: absolute; width: 14px; height: 14px; background: inherit;
  border: var(--line) solid var(--v-ink); border-top: 0; border-right: 0;
}
.bubble-left::after { left: -9px; bottom: 14px; transform: rotate(45deg) skew(10deg, 10deg); }
.bubble-up { align-self: center; }
.bubble-up::after { left: calc(50% - 7px); top: -9px; transform: rotate(135deg); }

@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-8px) rotate(2deg); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-7deg); } 40% { transform: rotate(6deg); } 60% { transform: rotate(-3deg); } 80% { transform: rotate(2deg); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 15% { transform: translateY(0) scale(1.06, 0.92); } 45% { transform: translateY(-26px) scale(0.96, 1.05) rotate(-4deg); } 70% { transform: translateY(0) scale(1.04, 0.95); } }
@keyframes slump { 0% { transform: rotate(0) translateY(0); } 100% { transform: rotate(14deg) translateY(10px); } }
@keyframes stamp { 0% { transform: scale(2.4) rotate(-30deg); opacity: 0; } 60% { transform: scale(0.9) rotate(-12deg); opacity: 1; } 100% { transform: scale(1) rotate(-14deg); } }
@keyframes pop-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.bob { animation: bob 2.6s ease-in-out infinite; }
.wiggle { animation: wiggle 1.4s ease-in-out infinite; transform-origin: 50% 85%; }
.hop { animation: hop 1.1s ease-in-out infinite; transform-origin: 50% 100%; }
.slump { animation: slump 1.2s ease-out forwards; transform-origin: 50% 90%; }
@media (prefers-reduced-motion: reduce) {
  .bob, .wiggle, .hop, .slump, .seal { animation: none !important; }
  .app { scroll-behavior: auto; }
}

/* -------------------------------------------------------------- splash */
.splash {
  position: absolute; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 8px;
  background: var(--v-background); color: var(--v-text);
  font-family: var(--font-display); font-weight: 600; font-size: 18px; transition: opacity 0.35s ease;
}
.splash img { width: 180px; height: 180px; }
.splash.gone { opacity: 0; pointer-events: none; }

/* -------------------------------------------------------------- invite */
.invite { padding-top: 22px; }
.invite-hero { position: relative; display: flex; justify-content: center; padding: 6px 0 4px; }
.invite-hero .plate { width: 210px; }
.hero-mascot { width: 92%; height: auto; }
.invite-hero .bubble { position: absolute; right: 0; top: 4px; max-width: 150px; transform: rotate(3deg); }
.invite-hero .bubble-left::after { left: -9px; bottom: 10px; }
.member-row { display: flex; align-items: center; gap: 12px; }
.stack-avatars { display: flex; }
.stack-avatars .avatar + .avatar { margin-left: -10px; }
.how { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.how li { display: flex; gap: 10px; align-items: center; }
.how .ic { width: 34px; height: 34px; padding: 6px; border: 2px solid var(--v-ink); border-radius: 50%; background: var(--v-accent); color: var(--v-accent-contrast); }

/* ---------------------------------------------------------------- avatar */
.avatar {
  --size: 40px;
  width: var(--size); height: var(--size); flex: none;
  display: inline-grid; place-items: center; border-radius: 50%;
  background: var(--av-bg); color: var(--av-fg);
  border: var(--line) solid var(--v-ink);
  font-family: var(--font-display); font-weight: 700; font-size: calc(var(--size) * 0.45);
}
.avatar.xs { --size: 22px; border-width: 2px; font-size: 11px; }
.avatar.sm { --size: 32px; border-width: 2px; }
.avatar.lg { --size: 52px; }
.avatar.xl { --size: 68px; }

/* ----------------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
.label { font-family: var(--font-display); font-weight: 600; font-size: 16px; padding: 0; }
input[type="text"], input[type="email"], input[type="datetime-local"] {
  width: 100%; min-height: 48px; padding: 10px 12px;
  background: var(--v-surface2); color: var(--v-text);
  border: var(--line) solid var(--v-ink); border-radius: 12px 10px 13px 9px;
}
input::placeholder { color: var(--v-muted); opacity: 1; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.inline-field input { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.check input {
  appearance: none; flex: none; width: 26px; height: 26px; margin: 0; cursor: pointer;
  border: var(--line) solid var(--v-ink); border-radius: 8px; background: var(--v-surface2);
  display: grid; place-items: center;
}
.check input:checked { background: var(--v-success); }
.check input:checked::after {
  content: ""; width: 7px; height: 13px; border: solid var(--v-success-contrast); border-width: 0 3px 3px 0;
  transform: translateY(-2px) rotate(45deg);
}
.check input[type="radio"] { border-radius: 50%; }
.check input[type="radio"]:checked::after { width: 10px; height: 10px; border: 0; border-radius: 50%; background: var(--v-success-contrast); transform: none; }
.check span { padding-top: 2px; }
.reasons { gap: 10px; }
.form-error {
  margin: 0; padding: 8px 12px; border-radius: 12px; border: 2px solid var(--v-ink);
  background: var(--v-danger); color: var(--v-danger-contrast); font-weight: 700;
}
.notice { margin: 0; padding: 10px 12px; border-radius: 12px; border: 2px dashed var(--v-border); }
.signup-head { display: flex; align-items: center; gap: 12px; }
.signup-mascot { width: 104px; height: 104px; }
.signup-head .bubble { transform: rotate(-2deg); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px var(--gutter);
  background: var(--v-background);
  border-bottom: var(--line) solid var(--v-border);
}
.topbar-mascot { width: 44px; height: 44px; }
.topbar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar-title .eyebrow { font-size: 11px; }
.group-name, .group-switch {
  font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1.15;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.group-switch {
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  display: inline-flex; align-items: center; gap: 2px; color: var(--v-text);
}
.group-switch .ic { width: 18px; height: 18px; }
.purse {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  padding: 6px 12px 6px 8px; border: var(--line) solid var(--v-ink); border-radius: 999px;
  background: var(--v-surface); color: var(--v-text); box-shadow: 0 3px 0 var(--v-ink);
  font-family: var(--font-display); font-size: 18px;
}
.purse .ic { width: 24px; height: 24px; }

/* ---------------------------------------------------------------- group */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px;
  border: var(--line) solid var(--v-ink); border-radius: 16px; background: var(--v-surface2);
}
.segmented button {
  border: 0; background: none; padding: 8px; border-radius: 11px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--v-text);
}
.segmented button.on {
  background: var(--v-secondary); color: var(--v-secondary-contrast); font-weight: 700;
  /* The inset ring keeps the selected tab obvious in palettes where secondary sits close to the surface. */
  box-shadow: inset 0 0 0 2px var(--v-border), 0 2px 0 var(--v-ink);
}
#panel { display: flex; flex-direction: column; gap: 14px; }
.cta {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--v-primary); color: var(--v-primary-contrast); padding: 10px 14px 10px 8px;
  font: inherit;
}
.cta .muted { color: inherit; opacity: 1; display: block; font-size: 14px; }
.cta-mascot { width: 64px; height: 64px; transform: rotate(-6deg); }
.cta-title { font-family: var(--font-display); font-size: 20px; display: block; }
.cta-plus { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--v-surface); color: var(--v-text); border: var(--line) solid var(--v-ink); }
.invite-card { display: flex; align-items: center; gap: 10px; background: var(--v-surface2); }
.oath-card { display: flex; flex-direction: column; gap: 10px; color: var(--v-text); }
.oath-card-top { display: flex; align-items: flex-start; gap: 10px; }
.who { display: block; font-size: 13px; color: var(--v-muted); font-weight: 700; }
.oath-title { display: block; font-family: var(--font-display); font-weight: 600; font-size: 18px; line-height: 1.2; overflow-wrap: anywhere; }
.oath-card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.oath-card.kept { background: var(--v-surface2); }
.oath-card.broken { background: var(--v-surface2); }
.progress { display: flex; gap: 5px; }
.seg {
  flex: 1; height: 16px; border: 2px solid var(--v-ink); border-radius: 6px 5px 7px 4px; background: var(--v-surface2);
}
.seg.done { background: var(--v-success); }
.seg.pending {
  background: repeating-linear-gradient(-45deg, var(--v-warning) 0 5px, var(--v-surface2) 5px 10px);
}
.progress-label { font-size: 14px; line-height: 1.3; }
.duel-card { display: flex; align-items: center; gap: 12px; background: var(--v-surface2); border-style: dashed; box-shadow: none; }
.duel-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; border: var(--line) solid var(--v-ink); background: var(--v-surface); }
.duel-card .muted { display: block; font-size: 13px; }
.duel-card .badge { align-self: center; }

.board-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.board-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.board-row.me { background: var(--v-surface2); border-width: 4px; }
.board-name { text-decoration: none; color: var(--v-text); }
.board-name .muted { display: block; font-size: 13px; font-weight: 700; }
.place {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 50%;
  border: 2px solid var(--v-ink); font-family: var(--font-display); font-weight: 700; background: var(--v-surface2);
}
.place-1 { background: var(--v-warning); color: var(--v-warning-contrast); }
.place-2 { background: var(--v-accent); color: var(--v-accent-contrast); }
.place-3 { background: var(--v-primary); color: var(--v-primary-contrast); }

/* ---------------------------------------------------------------- empty */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 8px 8px 4px; }
.empty p { margin: 0; max-width: 300px; }
.mascot-empty { width: 110px; height: 110px; }
.empty-sm { flex-direction: row; justify-content: center; padding: 0; }
.empty-sm .mascot-empty { width: 64px; height: 64px; }
.empty-sm .bubble-up::after { left: -9px; top: calc(50% - 7px); transform: rotate(45deg); }

/* ---------------------------------------------------------------- swear */
.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tpl {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px 10px;
  border: var(--line) solid var(--v-ink); border-radius: var(--r-wobble-sm); background: var(--v-surface);
  cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 14px; line-height: 1.1; text-align: center;
  box-shadow: 0 3px 0 var(--v-ink);
}
.tpl img { width: 56px; height: 56px; border-radius: 50%; border: 2px solid var(--v-ink); object-fit: cover; }
.tpl.on { background: var(--v-secondary); color: var(--v-secondary-contrast); transform: translateY(2px) rotate(-1deg); box-shadow: 0 1px 0 var(--v-ink); }
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper .btn { width: 44px; font-size: 22px; padding: 0; }
.stepper output { font-size: 17px; min-width: 90px; text-align: center; }
.stake-row { display: flex; align-items: center; gap: 12px; }
input[type="range"] {
  --fill: 30%;
  flex: 1; min-width: 0; height: 32px; appearance: none; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 16px; border: var(--line) solid var(--v-ink); border-radius: 10px;
  background: linear-gradient(to right, var(--v-primary) var(--fill), var(--v-surface2) var(--fill));
}
input[type="range"]::-moz-range-track { height: 12px; border: var(--line) solid var(--v-ink); border-radius: 10px; background: var(--v-surface2); }
input[type="range"]::-moz-range-progress { height: 12px; background: var(--v-primary); border-radius: 10px; }
input[type="range"]::-webkit-slider-thumb {
  appearance: none; width: 30px; height: 30px; margin-top: -10px; border-radius: 50%;
  background: var(--v-warning); border: var(--line) solid var(--v-ink); box-shadow: 0 2px 0 var(--v-ink);
}
input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--v-warning); border: var(--line) solid var(--v-ink); }
.witness-row { display: flex; align-items: center; gap: 10px; }

/* ------------------------------------------------------------- ceremony */
.ceremony { align-items: stretch; text-align: center; padding-top: 22px; }
.ceremony-stage { position: relative; display: flex; justify-content: center; }
.plate-xl { width: 230px; }
.ceremony-mascot, .result-mascot { width: 92%; height: auto; }
.scroll-card { background: var(--v-surface); text-align: left; transform: rotate(-0.6deg); }
.vow { font-size: 18px; margin: 6px 0; line-height: 1.5; }
.seal {
  position: absolute; right: 18px; bottom: -6px; width: 108px; height: 108px; border-radius: 50%;
  display: grid; place-items: center; background: var(--v-danger); color: var(--v-danger-contrast);
  border: 4px solid var(--v-ink); box-shadow: 0 0 0 5px var(--v-danger), 0 0 0 8px var(--v-ink);
  font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: 0.06em;
  animation: stamp 0.5s cubic-bezier(.2,1.6,.4,1) both; transform: rotate(-14deg);
}
.ceremony-line { margin: 0; font-family: var(--font-display); font-weight: 600; font-size: 18px; }

/* ---------------------------------------------------------------- thread */
.topbar-thread { gap: 8px; }
.oath-hero { display: flex; flex-direction: column; gap: 10px; }
.oath-title-lg { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
.hero-pills { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.iou-line { margin: 0; padding: 8px 10px; border-radius: 12px; border: 2px dashed var(--v-border); background: var(--v-surface2); }
.oath-hero p { margin: 0; }
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.feed-item { animation: pop-in 0.25s ease both; }
.feed-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.proof-card { padding: 8px; display: flex; flex-direction: column; gap: 10px; }
.photo { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border: var(--line) solid var(--v-ink); border-radius: 14px 12px 16px 11px; background: var(--v-surface2); }
.photo-sm { width: 180px; max-width: 100%; }
/* Photos come from signed URLs; a shimmer holds the space until the image arrives. */
.photo-loading {
  background: linear-gradient(100deg, var(--v-surface2) 30%, var(--v-surface) 50%, var(--v-surface2) 70%) 0 0 / 300% 100%;
  animation: shimmer 1.2s linear infinite; color: transparent;
}
.photo-gone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  color: var(--v-muted); font-weight: 700; font-size: 14px;
}
.photo-gone .ic { width: 32px; height: 32px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) { .photo-loading { animation: none; } }
.caption { margin: 0 4px; font-weight: 700; }
.verdict { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 0 4px; }
.vote-row { display: flex; gap: 10px; }
.vote-row .btn { min-width: 0; }
.reactions { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 2px 2px; }
.react {
  border: 2px solid var(--v-ink); border-radius: 999px; padding: 4px 11px; min-height: 32px;
  background: var(--v-surface2); color: var(--v-text); cursor: pointer; font-weight: 800; font-size: 13px;
}
.react.on { background: var(--v-accent); color: var(--v-accent-contrast); }
.msg { display: flex; align-items: flex-end; gap: 8px; }
.msg.mine { flex-direction: row-reverse; }
.msg-body { display: flex; flex-direction: column; gap: 4px; max-width: 78%; min-width: 0; }
.msg.mine .msg-body { align-items: flex-end; }
.msg-meta { font-size: 13px; }
.bubble-msg {
  background: var(--v-surface); border: var(--line) solid var(--v-ink); border-radius: 18px 18px 18px 6px;
  padding: 8px 12px; box-shadow: 0 3px 0 var(--v-ink); display: flex; flex-direction: column; gap: 6px;
}
.bubble-msg p { margin: 0; overflow-wrap: anywhere; }
.msg.mine .bubble-msg { background: var(--v-secondary); color: var(--v-secondary-contrast); border-radius: 18px 18px 6px 18px; }
.msg-nudge .bubble-msg { background: var(--v-warning); color: var(--v-warning-contrast); flex-direction: row; align-items: center; }
.nudge-mascot { width: 64px; height: 64px; flex: none; }
.msg .btn-icon-sm { align-self: center; }
.system { text-align: center; }
.system span {
  display: inline-block; font-family: var(--font-display); font-weight: 600; padding: 4px 12px;
  border-radius: 999px; border: 2px solid var(--v-ink); background: var(--v-surface2);
}
.hidden-item {
  display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 14px;
  border: 2px dashed var(--v-border); color: var(--v-muted); font-weight: 700; font-size: 14px; background: var(--v-surface2);
}
.composer {
  position: sticky; bottom: 0; z-index: 4;
  display: flex; align-items: center; gap: 8px; padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
  background: var(--v-background); border-top: var(--line) solid var(--v-border);
}
.composer input { flex: 1; min-width: 0; min-height: 44px; border-radius: 999px; padding: 8px 16px; }

/* --------------------------------------------------------------- capture */
.viewfinder { position: relative; padding: 8px; overflow: hidden; }
.viewfinder video { display: none; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; border: var(--line) solid var(--v-ink); background: var(--v-ink); }
.viewfinder video.live { display: block; }
.cam-fallback {
  aspect-ratio: 4 / 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: var(--line) dashed var(--v-border); border-radius: 12px; padding: 20px; text-align: center; background: var(--v-surface2);
}
.cam-fallback[hidden] { display: none; }
.cam-fallback p { margin: 0; font-weight: 700; }
.cam-mascot { width: 130px; height: 130px; }
.stamp-preview { display: none; }
video.live ~ .stamp-preview {
  display: block;
  position: absolute; left: 8px; right: 8px; bottom: 8px; padding: 10px 14px; border-radius: 0 0 12px 12px;
  background: rgba(20, 18, 26, 0.82); color: #fff; font-family: var(--font-display); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.capture-actions { display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.shutter {
  align-self: center; width: 76px; height: 76px; border-radius: 50%; padding: 6px; cursor: pointer;
  background: var(--v-surface); border: 4px solid var(--v-ink); box-shadow: 0 4px 0 var(--v-ink);
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: var(--v-primary); border: var(--line) solid var(--v-ink); }
.shutter:disabled { display: none; }
.capture-actions label.btn { position: relative; }

/* ---------------------------------------------------------------- result */
.result { text-align: center; align-items: stretch; }
.result .btn-back { text-align: left; }
.result-stage { position: relative; display: flex; justify-content: center; margin-top: 4px; }
.result-stage .bubble { position: absolute; right: 0; top: 0; max-width: 140px; transform: rotate(4deg); }
.result.broken .result-stage .bubble { right: auto; left: 0; transform: rotate(-4deg); }
.result.broken .result-stage .bubble-left::after { left: auto; right: -9px; transform: rotate(-135deg) skew(10deg, 10deg); }
.cloud {
  position: absolute; top: 4px; right: 34px; width: 92px; height: 40px; border-radius: 30px;
  background: var(--v-muted); border: var(--line) solid var(--v-ink);
}
.cloud::before {
  content: ""; position: absolute; left: 18px; top: -24px; width: 46px; height: 46px; border-radius: 50%;
  background: var(--v-muted); border: var(--line) solid var(--v-ink); border-bottom-color: transparent; border-right-color: transparent; transform: rotate(45deg);
}
.result-title { font-size: 28px; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; text-align: left; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 12px; }
.stat-label { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; color: var(--v-muted); }
.stat-num { font-family: var(--font-display); font-weight: 700; font-size: 32px; line-height: 1; }
.stat-delta { font-weight: 800; font-size: 13px; }
.stat-delta.up { color: var(--v-success-text); }
.stat-delta.down { color: var(--v-danger-text); }
.honor-bar { height: 12px; border: 2px solid var(--v-ink); border-radius: 8px; background: var(--v-surface2); overflow: hidden; }
.honor-bar span { display: block; height: 100%; background: var(--v-success); transition: width 1s cubic-bezier(.3,1.4,.5,1); }
.result.broken .honor-bar span { background: var(--v-danger); }
.rankup { display: flex; align-items: center; gap: 12px; text-align: left; background: var(--v-warning); color: var(--v-warning-contrast); }
.rankup .eyebrow, .rankup .muted { color: inherit; }
.rankup-mascot { width: 84px; height: 84px; }
.rankup-title { font-family: var(--font-display); font-size: 20px; margin: 2px 0; }
.iou-result { margin: 0; text-align: left; }
.card-preview { padding: 8px; }
.card-preview canvas { width: 100%; height: auto; display: block; border-radius: 12px; }

/* --------------------------------------------------------------- profile */
.profile-card { display: flex; flex-direction: column; gap: 10px; }
.profile-top { display: flex; align-items: center; gap: 12px; }
.profile-name { font-size: 26px; }
.profile-mascot { width: 76px; height: 76px; }
.rank-badge {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; padding: 3px 10px;
  border: 2px solid var(--v-ink); border-radius: 999px; background: var(--v-warning); color: var(--v-warning-contrast);
  font-family: var(--font-display); font-weight: 600;
}
.rank-ladder { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.rung {
  text-align: center; font-size: 12px; font-weight: 800; padding: 4px 2px; border-radius: 8px;
  border: 2px solid var(--v-border); color: var(--v-muted); background: var(--v-surface2);
}
.rung.past { color: var(--v-text); }
.rung.on { background: var(--v-secondary); color: var(--v-secondary-contrast); border-color: var(--v-ink); }
.rank-progress { height: 16px; border: var(--line) solid var(--v-ink); border-radius: 10px; background: var(--v-surface2); overflow: hidden; }
.rank-progress span { display: block; height: 100%; background: var(--v-primary); }
.profile-card p { margin: 0; }
.stats-grid.four .stat-num { font-size: 28px; }
.menu { padding: 4px; display: flex; flex-direction: column; }
.menu a, .menu-btn, .menu-row {
  display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 52px; text-align: left;
  color: var(--v-text); text-decoration: none; font-weight: 700; border-radius: 12px;
  background: none; border: 0; width: 100%; cursor: pointer;
}
.menu > * + *:is(a, .menu-btn, .menu-row) { border-top: 2px dashed var(--v-border); border-radius: 0; }
.menu-btn.danger { color: var(--v-danger-text); }
.menu-btn.on { background: var(--v-surface2); }
.menu-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.rules ul { margin: 6px 0 0; padding-left: 20px; }
.rules p { margin: 0; }

/* ----------------------------------------------------------------- theme */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.swatch-chip { width: 54px; height: 54px; border-radius: 14px 12px 15px 11px; background: var(--sw); border: var(--line) solid var(--v-ink); }
.preview { display: flex; flex-direction: column; gap: 10px; }
.preview p { margin: 0; }
.contrast-table { display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.crow { display: flex; align-items: center; gap: 10px; }
.cpair {
  width: 44px; height: 30px; flex: none; display: grid; place-items: center; border-radius: 8px;
  background: var(--bg); color: var(--fg); border: 2px solid var(--v-ink); font-weight: 800;
}
.ok { color: var(--v-success-text); font-weight: 800; }
.bad { color: var(--v-danger-text); font-weight: 800; }

/* ------------------------------------------------------------------- duel */
.duel { text-align: center; align-items: center; }
.duel .badge { align-self: center; }
.duel .btn-back { align-self: flex-start; }
.duel .result-stage { width: 100%; }

/* ---------------------------------------------------------------- tabbar */
.tabbar {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: end;
  padding: 6px 18px calc(8px + env(safe-area-inset-bottom));
  background: var(--v-nav); color: var(--v-nav-contrast);
}
.tabbar[hidden] { display: none; }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 2px;
  color: var(--v-nav-contrast); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 13px;
  border-radius: 14px;
}
.tab .ic { width: 26px; height: 26px; }
.tab.active span { text-decoration: underline; text-decoration-thickness: 3px; text-underline-offset: 5px; }
.tab-swear {
  margin-top: -26px; padding: 10px 18px 6px; background: var(--v-primary); color: var(--v-primary-contrast);
  border: var(--line) solid var(--v-ink); border-radius: 24px 20px 26px 19px; box-shadow: 0 4px 0 var(--v-ink);
}
.tab-swear .ic { width: 30px; height: 30px; }
.tabbar :focus-visible { outline-color: var(--v-nav-contrast); box-shadow: none; }

/* ------------------------------------------------------- toasts + sheets */
.toasts {
  position: absolute; left: 12px; right: 12px; top: 48px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px 8px 8px; background: var(--v-surface); color: var(--v-text);
  border: var(--line) solid var(--v-ink); border-radius: 16px; box-shadow: var(--drop);
  font-weight: 700; font-size: 14px; animation: pop-in 0.25s ease both; transition: opacity 0.3s, transform 0.3s;
}
.toast.success { background: var(--v-success); color: var(--v-success-contrast); }
.toast.danger { background: var(--v-danger); color: var(--v-danger-contrast); }
.toast.out { opacity: 0; transform: translateY(-8px); }
.toast-mascot { width: 36px; height: 36px; }
.toast-link { color: inherit; white-space: nowrap; }
.layer { position: absolute; inset: 0; z-index: 30; }
.layer[hidden] { display: none; }
.scrim { position: absolute; inset: 0; background: rgba(10, 10, 20, 0.45); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88%; overflow-y: auto;
  background: var(--v-background); color: var(--v-text);
  border-top: var(--line) solid var(--v-ink); border-radius: 26px 26px 0 0;
  padding: 10px var(--gutter) calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; animation: pop-in 0.22s ease both;
}
.sheet-grip { width: 48px; height: 6px; border-radius: 3px; background: var(--v-border); align-self: center; }
.sheet-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; margin: 0; display: flex; align-items: center; gap: 8px; }
.sheet p { margin: 0; }
.welcome { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.welcome-mascot { width: 150px; height: 150px; }
.purse-big { font-family: var(--font-display); font-size: 34px; display: inline-flex; align-items: center; gap: 8px; }
.purse-big .ic { width: 40px; height: 40px; }
.noscript { padding: 24px; color: var(--v-nav-contrast); }

/* --------------------------------------------------- dark palette tweaks */
[data-palette-mode="dark"] .scrim { background: rgba(0, 0, 0, 0.6); }
/* Valli's outline and floating marks (zzz, ?, ...) are dark ink drawn for paper.
   On a dark palette a thin light sticker edge keeps every line readable. */
[data-palette-mode="dark"] .mascot, [data-palette-mode="dark"] .splash img, [data-palette-mode="dark"] .desk-note img {
  filter: drop-shadow(0 0 0.6px rgba(255, 246, 232, 0.92)) drop-shadow(0 0 0.6px rgba(255, 246, 232, 0.92)) drop-shadow(0 0 1.4px rgba(255, 246, 232, 0.92));
}

/* ------------------------------------------------------- shared app (M1) */
.is-pending { opacity: 0.7; cursor: progress; }
.is-pending::after {
  content: ""; width: 16px; height: 16px; margin-left: 8px; border-radius: 50%;
  border: 3px solid currentColor; border-right-color: transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 48px; color: var(--v-muted); font-weight: 700; }
.notice-warning { display: flex; gap: 10px; align-items: flex-start; border-style: solid; background: var(--v-surface2); }
.notice-warning .ic { margin-top: 2px; color: var(--v-warning-text); }
.invite-link { font-family: ui-monospace, monospace; font-size: 14px; }
.topbar-invite { margin-left: auto; }

/* ------------------------------------------------------- account (M2) */
.save-card { display: flex; align-items: flex-start; gap: 10px; background: var(--v-surface2); }
.save-card p { margin: 2px 0 8px; }
.save-mascot { width: 64px; height: 64px; flex: none; }
.account-state { display: flex; align-items: flex-start; gap: 10px; }
.account-state p { margin: 2px 0 0; overflow-wrap: anywhere; }
.code-input { font-size: 24px; letter-spacing: 6px; font-variant-numeric: tabular-nums; }

/* --------------------------------------------- privacy and terms (M2) */
.doc .card { display: flex; flex-direction: column; gap: 8px; }
.doc .card p, .doc .card ul { margin: 0; }
.doc .card ul { padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.doc .section-title { margin: 0; }
.doc a { overflow-wrap: anywhere; }
.doc .btn-back { text-decoration: none; color: var(--v-text); }
