:root {
  --felt: #251320;
  --felt-deep: #180B15;
  --ivory: #FBF6EC;
  --ivory-dim: #EFE7D8;
  --gold: #C6A24D;
  --gold-bright: #E4C979;
  --wine: #8C3A57;
  --wine-bright: #B8567A;
  --ink: #2B1620;
  --ink-soft: #5A3F4A;
  --radius-card: 22px;
  --radius-btn: 14px;
  --shadow-card: 0 18px 40px rgba(10, 4, 9, 0.55);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--felt);
  color: var(--ivory);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(ellipse at 50% -10%, rgba(198,162,77,0.10), transparent 55%),
    radial-gradient(ellipse at 50% 110%, rgba(140,58,87,0.18), transparent 60%),
    var(--felt);
  min-height: 100vh;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

textarea, input {
  font-family: inherit;
  font-size: 1rem;
}

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top, 20px) 20px calc(env(safe-area-inset-bottom, 20px) + 20px);
  position: relative;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand .mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: var(--ivory);
  border: 2px solid var(--wine-bright);
  transform: rotate(-6deg);
  position: relative;
  flex-shrink: 0;
}
.brand .mark::after {
  content: "";
  position: absolute; inset: 5px;
  border-radius: 50%;
  background: var(--gold);
}
.brand-name {
  font-family: 'Fraunces', serif;
  font-size: 1.25rem;
  font-weight: 600;
}
.duo-label {
  font-size: 0.8rem;
  color: var(--gold-bright);
  opacity: 0.85;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(251,246,236,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.icon-btn:active { background: rgba(251,246,236,0.16); }

/* ---------- Screens ---------- */
.screen { flex: 1; display: flex; flex-direction: column; }
.center-screen { flex: 1; display: flex; flex-direction: column; justify-content: center; }

.eyebrow-free {
  color: var(--gold-bright);
  font-size: 0.85rem;
  margin-bottom: 6px;
}

.headline {
  font-size: 1.9rem;
  line-height: 1.18;
  margin-bottom: 10px;
}
.subtext {
  color: var(--ivory-dim);
  opacity: 0.75;
  font-size: 0.98rem;
  line-height: 1.5;
  margin-bottom: 22px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 15px 22px;
  border-radius: var(--radius-btn);
  font-weight: 600;
  font-size: 1rem;
  width: 100%;
  transition: transform 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(180deg, var(--gold-bright), var(--gold));
  color: var(--ink);
}
.btn-ghost {
  background: rgba(251,246,236,0.08);
  color: var(--ivory);
  border: 1px solid rgba(251,246,236,0.18);
}
.btn-wine {
  background: var(--wine);
  color: var(--ivory);
}
.btn-block-group { display: flex; flex-direction: column; gap: 10px; }
.btn-small {
  width: auto;
  padding: 10px 16px;
  font-size: 0.88rem;
}

/* ---------- Form fields ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.2);
  border-radius: 12px;
  padding: 13px 14px;
  color: var(--ivory);
  resize: none;
}
.field input::placeholder, .field textarea::placeholder { color: rgba(251,246,236,0.35); }
.field input:focus, .field textarea:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

/* ---------- Setup avatars ---------- */
.setup-vs {
  display: flex; align-items: center; gap: 10px;
  margin: 4px 0 24px;
}
.setup-vs .line { flex: 1; height: 1px; background: rgba(251,246,236,0.18); }
.setup-vs .word { font-family: 'Fraunces', serif; font-style: italic; opacity: 0.6; }

/* ---------- Table / Home ---------- */
.turn-banner {
  text-align: center;
  padding: 14px 10px;
  margin-bottom: 18px;
  border-radius: 16px;
  background: rgba(251,246,236,0.05);
  border: 1px dashed rgba(198,162,77,0.4);
}
.turn-banner .who { font-family: 'Fraunces', serif; font-size: 1.15rem; color: var(--gold-bright); }
.turn-banner .what { font-size: 0.85rem; opacity: 0.7; margin-top: 2px; }

.table-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 320px;
}

/* ---------- Playing card ---------- */
.card {
  width: 100%;
  max-width: 320px;
  background: var(--ivory);
  color: var(--ink);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 26px 24px 22px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 6px;
  background: linear-gradient(90deg, var(--wine), var(--gold));
}
.card-kind {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--wine);
  font-weight: 700;
  margin-bottom: 10px;
}
.card-body {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  line-height: 1.35;
  font-weight: 500;
  margin-bottom: 18px;
}
.card-from {
  font-size: 0.8rem;
  color: var(--ink-soft);
  border-top: 1px solid rgba(43,22,32,0.12);
  padding-top: 12px;
}

/* Sealed treat strip */
.seal-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--felt-deep);
  color: var(--gold-bright);
  border-radius: 14px;
  padding: 12px 14px;
  margin-top: 14px;
}
.seal-strip.opened { background: rgba(198,162,77,0.14); color: var(--ink); }
.seal-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--felt-deep);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform 0.4s cubic-bezier(.3,1.6,.4,1);
}
.seal-strip.opened .seal-icon { transform: rotate(25deg) scale(1.08); }
.seal-text { font-size: 0.92rem; line-height: 1.35; }
.seal-text .lbl { display:block; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.7; margin-bottom: 2px; }

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
.pop { animation: pop 0.5s ease; }

/* ---------- Deck chooser ---------- */
.deck-scroll {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 40vh;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 2px;
}
.deck-item {
  text-align: left;
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.14);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.92rem;
  line-height: 1.4;
}
.deck-item:active { background: rgba(251,246,236,0.12); }
.deck-item.selected {
  border-color: var(--gold);
  background: rgba(198,162,77,0.14);
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  background: rgba(251,246,236,0.06);
  border-radius: 12px;
  padding: 4px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 10px 6px;
  border-radius: 9px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ivory-dim);
}
.tab.active {
  background: var(--ivory);
  color: var(--ink);
}

/* ---------- Move type chooser ---------- */
.move-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.move-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.16);
  border-radius: 16px;
  padding: 16px;
}
.move-card:active { background: rgba(251,246,236,0.12); }
.move-card .glyph {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  background: var(--gold);
  color: var(--ink);
}
.move-card.spark .glyph { background: var(--wine-bright); color: var(--ivory); }
.move-card.wild .glyph { background: var(--ivory); color: var(--wine); }
.move-card.disabled { opacity: 0.4; pointer-events: none; }
.move-card h3 { font-size: 1rem; margin-bottom: 2px; }
.move-card p { font-size: 0.82rem; color: var(--ivory-dim); opacity: 0.75; margin: 0; }

/* ---------- History ---------- */
.history-item {
  background: rgba(251,246,236,0.05);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.history-item .meta {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.history-item .txt { font-size: 0.92rem; line-height: 1.4; }
.history-item .txt + .txt { margin-top: 6px; color: var(--ivory-dim); }
.empty-state {
  text-align: center;
  opacity: 0.6;
  padding: 60px 20px;
  font-size: 0.92rem;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(251,246,236,0.1);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 0.72rem;
  color: rgba(251,246,236,0.5);
  padding: 4px 14px;
}
.nav-item.active { color: var(--gold-bright); }
.nav-item .dot { font-size: 1.15rem; }

/* ---------- Pass device overlay ---------- */
.pass-overlay {
  position: fixed; inset: 0;
  background: var(--felt-deep);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 30px;
  z-index: 50;
}
.pass-overlay .display { font-size: 1.6rem; margin-bottom: 12px; }
.pass-overlay p { color: var(--ivory-dim); margin-bottom: 26px; max-width: 280px; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: rgba(251,246,236,0.2); border-radius: 3px; }

.helper-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  margin-bottom: 18px;
}
.helper-row .link-btn {
  font-size: 0.82rem;
  color: var(--gold-bright);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-note {
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.4;
  margin-top: 18px;
}

/* ---------- Share screen ---------- */
.share-box {
  background: rgba(251,246,236,0.06);
  border: 1px dashed rgba(198,162,77,0.45);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 18px;
}
.share-link-readout {
  font-size: 0.78rem;
  color: var(--gold-bright);
  word-break: break-all;
  line-height: 1.5;
  opacity: 0.85;
  font-family: ui-monospace, Menlo, monospace;
}

/* ---------- Section titles ---------- */
.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gold-bright);
  opacity: 0.8;
  margin-bottom: 10px;
}

/* ---------- Button row (multiple actions on a card) ---------- */
.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}
.btn-row .btn { width: 100%; }

/* ---------- Confession / deadline notes on pending card ---------- */
.confession-note {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: rgba(140,58,87,0.08);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 6px;
}
.deadline-note {
  font-size: 0.8rem;
  color: var(--wine);
  margin-top: 10px;
  font-weight: 600;
}

/* ---------- Ritual / IOU list items ---------- */
.ritual-item, .iou-item {
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.14);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
}
.ritual-item .meta, .iou-item .meta {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold-bright);
  margin-bottom: 6px;
}
.ritual-item .txt, .iou-item .txt {
  font-size: 0.92rem;
  line-height: 1.4;
}
.ritual-item .btn-row, .iou-item .btn-row {
  flex-direction: row;
  flex-wrap: wrap;
}
.ritual-item .btn-row .btn, .iou-item .btn-row .btn { width: auto; }

/* ---------- Toggle row (Double or Nothing) ---------- */
.toggle-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.18);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.92rem;
  color: var(--ivory);
  text-align: left;
}
.toggle-pill {
  width: 40px; height: 24px;
  border-radius: 999px;
  background: rgba(251,246,236,0.25);
  position: relative;
  flex-shrink: 0;
  margin-left: 12px;
  transition: background 0.2s ease;
}
.toggle-pill::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ivory);
  transition: transform 0.2s ease;
}
.toggle-row.on .toggle-pill { background: var(--gold); }
.toggle-row.on .toggle-pill::after { transform: translateX(16px); }

/* ---------- Chips (deadline / frequency choice) ---------- */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}
.chip {
  padding: 9px 14px;
  border-radius: 999px;
  background: rgba(251,246,236,0.08);
  border: 1px solid rgba(251,246,236,0.2);
  font-size: 0.85rem;
  color: var(--ivory);
}
.chip.selected {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
  font-weight: 600;
}

/* ---------- Paste-link fallback ---------- */
.paste-box {
  margin-top: 18px;
}
.paste-toggle {
  width: 100%;
  text-align: center;
  font-size: 0.78rem;
  color: var(--gold-bright);
  opacity: 0.75;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 6px;
}
.paste-body {
  margin-top: 10px;
}
.paste-body textarea {
  width: 100%;
  background: rgba(251,246,236,0.06);
  border: 1px solid rgba(251,246,236,0.2);
  border-radius: 12px;
  padding: 12px 13px;
  color: var(--ivory);
  font-size: 0.85rem;
  resize: none;
}
.paste-body textarea::placeholder { color: rgba(251,246,236,0.35); }
