:root {
  --bg: #fbf7f0;
  --card: #ffffff;
  --ink: #1d1838;
  --muted: #6b6680;
  --line: #e9e3d8;
  --brand: #5b3df5;
  --brand-ink: #4127d6;
  --brand-soft: #efebff;
  --gold: #ffc53d;
  --gold-soft: #fff3d1;
  --gold-ink: #8a5a00;
  --pink: #ff5c7a;
  --green: #12a150;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(29, 24, 56, .06), 0 6px 24px rgba(29, 24, 56, .06);
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { min-height: 100vh; line-height: 1.45; }
a { color: var(--brand-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.narrow { max-width: 620px; }

/* Header and footer */
.top { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; }
.logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; text-decoration: none; color: var(--ink); letter-spacing: -.01em; }
.logo img { width: 30px; height: 30px; }
.foot { border-top: 1px solid var(--line); margin-top: 56px; padding-top: 22px; padding-bottom: 40px; color: var(--muted); font-size: 14px; }
.foot a { color: var(--muted); }
.foot .row { display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }

/* Type */
h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.05; letter-spacing: -.025em; margin: 18px 0 14px; }
h2 { font-size: 23px; letter-spacing: -.015em; margin: 0 0 10px; }
h3 { font-size: 17px; margin: 0 0 6px; }
.lead { font-size: 18.5px; color: #3d3857; margin: 0 0 22px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.hl { background: linear-gradient(transparent 60%, var(--gold) 60%); padding: 0 2px; }

/* Panels and forms */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 16px 0; }
.panel.tint { background: var(--brand-soft); border-color: #ddd5ff; box-shadow: none; }
label { display: block; font-weight: 650; font-size: 15px; margin: 0 0 6px; }
.field { margin: 0 0 16px; }
input[type=text], input[type=date], textarea, select {
  width: 100%; border: 1.5px solid #ddd6ca; background: #fff; border-radius: 12px; padding: 12px 14px; font-size: 16px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: none; min-height: 84px; }
input:focus, textarea:focus, select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(91, 61, 245, .14); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 20px;
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; background: var(--brand); color: #fff;
  transition: transform .06s, background .15s, opacity .15s; min-height: 48px;
}
.btn:hover { background: var(--brand-ink); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--ink); border: 1.5px solid #ddd6ca; }
.btn.ghost:hover { background: #f6f2ea; }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn.soft:hover { background: #e3dcff; }
.btn.danger { background: #fff; color: #c2253f; border: 1.5px solid #f2c4cd; }
.btn.small { padding: 8px 13px; min-height: 38px; font-size: 14.5px; border-radius: 10px; }
.btn.wa { background: #1fa855; }
.btn.wa:hover { background: #178a45; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; text-align: center; border: 1.5px solid #ddd6ca; border-radius: 12px; padding: 10px 6px; background: #fff; cursor: pointer;
  font-weight: 650; font-size: 15px;
}
.seg span small { display: block; font-weight: 500; color: var(--muted); font-size: 12.5px; }
.seg input:checked + span { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-ink); }
.seg input:focus-visible + span { box-shadow: 0 0 0 4px rgba(91, 61, 245, .2); }
.error { color: #c2253f; font-weight: 600; font-size: 15px; margin: 8px 0 0; min-height: 0; }
.error:empty { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0 0; }
.chip { text-decoration: none; color: var(--ink); border: 1px solid #e2dbcf; background: #fff; border-radius: 999px; padding: 6px 11px; font-size: 14px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand-ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 5px 11px; font-size: 14px; font-weight: 650; background: var(--gold-soft); color: var(--gold-ink); }
.pill.live { background: #e3f7eb; color: #0b7a3b; }

/* Home */
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; padding: 12px 0 8px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 8px 0; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.step b { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; margin-bottom: 8px; }
.step p { margin: 0; color: #3d3857; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 8px 0; }
.faq summary { font-weight: 700; cursor: pointer; }
.faq p { margin: 8px 0 0; color: #3d3857; }
.mylist a { display: flex; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 650; }
.mylist a:first-of-type { border-top: 0; }

/* Bingo card */
.card {
  --n: 5; display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 6px; background: var(--ink); padding: 8px; border-radius: 18px;
  aspect-ratio: 1 / 1; width: 100%; max-width: 560px; margin: 0 auto;
}
.cell {
  position: relative; background: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 4px; font-size: clamp(10px, 2.6vw, 14.5px); line-height: 1.15; font-weight: 600; overflow: hidden; border: 0; cursor: pointer;
  word-break: break-word; hyphens: auto; min-width: 0;
}
.card.n4 .cell { font-size: clamp(11px, 3vw, 16px); }
.card.n3 .cell { font-size: clamp(13px, 3.8vw, 19px); }
.cell .t { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cell.empty { background: #f4f0e8; color: #a59f93; font-weight: 500; }
.cell.empty .t::before { content: "+"; font-size: 1.6em; font-weight: 400; }
.cell.friend { background: var(--gold-soft); }
.cell.friend.empty { background: repeating-linear-gradient(45deg, #fff3d1, #fff3d1 6px, #ffecb8 6px, #ffecb8 12px); color: var(--gold-ink); }
.cell.friend.empty .t::before { content: "🎁"; font-size: 1.4em; }
.cell.friend.hidden { background: var(--gold); color: var(--ink); }
.cell.friend.hidden .t::before { content: "🎁"; font-size: 1.6em; }
.cell .by { position: absolute; left: 0; right: 0; bottom: 2px; font-size: .68em; font-weight: 700; color: var(--gold-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; }
.cell.friend:not(.empty):not(.hidden) .t { margin-bottom: .7em; }
.cell.free { background: var(--brand); color: #fff; font-weight: 800; cursor: default; }
.cell.free .t::before { content: "★"; display: block; font-size: 1.7em; line-height: 1; }
.cell.done::after {
  content: ""; position: absolute; inset: 9%; border-radius: 50%; background: rgba(255, 92, 122, .2); border: 3px solid rgba(255, 92, 122, .75);
  transform: rotate(-8deg); pointer-events: none; animation: stamp .25s ease-out;
}
.cell.free.done::after { display: none; }
.cell.waiting::after {
  content: "⏳"; position: absolute; top: 2px; right: 4px; font-size: 13px;
}
.cell:focus-visible { outline: 3px solid var(--pink); outline-offset: 1px; }
.cell.flip { animation: flip .7s ease both; }
.card.readonly .cell { cursor: default; }
@keyframes stamp { from { transform: scale(1.6) rotate(-20deg); opacity: 0; } to { transform: rotate(-8deg); opacity: 1; } }
@keyframes flip { 0% { transform: rotateY(90deg); } 100% { transform: rotateY(0); } }
.card-legend { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: 13.5px; color: var(--muted); margin: 10px 0 0; }
.card-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 5px; }

/* Mini cards on the board */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.mini { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; cursor: pointer; text-align: left; }
.mini:hover { border-color: var(--brand); }
.mini .card { gap: 2px; padding: 3px; border-radius: 8px; }
.mini .cell { border-radius: 3px; padding: 0; font-size: 0; cursor: pointer; }
.mini .cell .t, .mini .cell .by { display: none; }
.mini .cell.done::after { inset: 15%; border-width: 2px; animation: none; }
.mini .cell.waiting::after { display: none; }
.mini .who { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin: 0 0 8px; font-weight: 750; }
.mini .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini .stat { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: .04em; padding: 2px 7px; border-radius: 999px; background: var(--pink); color: #fff; }
.badge.first { background: var(--gold); color: var(--ink); }

/* Group page */
.ghead { padding: 6px 0 2px; }
.ghead h1 { font-size: clamp(28px, 5.5vw, 40px); margin: 6px 0 8px; }
.invite { display: grid; gap: 10px; }
.invite .link { display: flex; gap: 8px; }
.invite .link input { font-size: 14.5px; color: var(--muted); }
.friends .row { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line); }
.friends .row:first-child { border-top: 0; padding-top: 4px; }
.friends .name { font-weight: 750; }
.friends .wrote { background: var(--gold-soft); border-radius: 10px; padding: 9px 12px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.friends .inline { display: flex; gap: 8px; }
.friends .inline input { flex: 1; min-width: 0; }
.confirm-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.confirm-row:first-of-type { border-top: 0; }
.banner { background: linear-gradient(120deg, var(--brand), #8a3df5); color: #fff; border-radius: var(--radius); padding: 18px 20px; margin: 14px 0; }
.banner h2 { margin: 0 0 4px; }
.banner p { margin: 0; opacity: .92; }
.progress { height: 8px; background: #eee8dd; border-radius: 99px; overflow: hidden; margin: 10px 0 0; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.sectionhead { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }
.sectionhead h2 { margin: 0; }
.cta { text-align: center; }
.cta .chips { justify-content: center; }
.hidden { display: none !important; }

/* Dialog */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(460px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); }
dialog::backdrop { background: rgba(29, 24, 56, .45); }
dialog .in { padding: 22px; }
dialog h2 { margin: 0 0 4px; }
dialog .close { position: absolute; top: 10px; right: 10px; background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); padding: 6px 10px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(30px); background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 12px; font-weight: 600; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; max-width: calc(100vw - 30px); text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; gap: 18px; }
  .steps { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  .card { gap: 4px; padding: 5px; border-radius: 14px; }
  .cell { border-radius: 7px; padding: 2px; }
  .board { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
