:root {
  --page: #0E0D12;
  --bg: #15131A;
  --text: #F4F1EA;
  --muted: #B3ADBF;
  --dim: #8E879B;
  --placeholder: #7D7689;
  --soft: #D9D4E2;
  --surface: #221F29;
  --surface-2: #1C1A22;
  --surface-3: #26232D;
  --raised: #2E2A37;
  --border: #3A3545;
  --border-2: #332F3C;
  --line: #26232D;
  --footer: #1A1820;
  --accent: #E4FF5C;
  --accent-hover: #F2FFA8;
  --accent-soft: #2E3318;
  --warn: #FF9B4A;
  --error: #FF6B6B;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  --body: 'DM Sans', system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
button { cursor: pointer; font-family: inherit; color: inherit; }
button:disabled { cursor: default; opacity: 0.5; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input::placeholder { color: var(--placeholder); }
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app {
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  padding-top: env(safe-area-inset-top);
}
@media (min-width: 460px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pad { padding: 0 24px 24px; display: flex; flex-direction: column; gap: 28px; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack-12 { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }

/* typografie */
.h1 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 52px; line-height: 1; letter-spacing: -1.5px; }
.h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 32px; line-height: 1.05; letter-spacing: -0.5px; overflow-wrap: anywhere; }
.lead { margin: 0; font-size: 17px; line-height: 1.45; color: var(--muted); }
.sub { margin: 0; font-size: 15px; color: var(--muted); }
.label { font-size: 14px; font-weight: 700; }
.hint { font-size: 13px; color: var(--dim); }
.overline { font-size: 13px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--dim); }
.error { font-size: 14px; color: var(--error); margin: 0; }

/* knoppen & velden */
.btn {
  height: 56px; border-radius: 16px; font-size: 17px; font-weight: 700;
  border: 1px solid var(--border); background: transparent; color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px;
  transition: transform .08s ease, background-color .15s ease;
}
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn-primary { border: 0; background: var(--accent); color: var(--bg); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-small {
  height: 44px; padding: 0 14px; border-radius: 12px; font-size: 14px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn-ghost { border: 0; background: transparent; color: var(--accent); font-size: 13px; font-weight: 700; height: 32px; padding: 0 4px; }
.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--text);
  display: flex; align-items: center; justify-content: center; border-radius: 12px; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--surface); }

.input {
  height: 52px; width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); padding: 0 16px; font-size: 17px; font-family: inherit;
}
.input-code {
  height: 60px; color: var(--accent); font-size: 26px; font-weight: 700; letter-spacing: 3px;
  text-transform: uppercase; font-family: var(--display);
}
.input[aria-invalid="true"] { border-color: var(--error); }

.topbar { display: flex; align-items: center; gap: 8px; padding: 20px 16px 8px; min-height: 72px; }
.topbar .hint { font-size: 14px; }
.topbar.no-back { padding-left: 24px; }

/* home */
.home { padding: 72px 24px 32px; gap: 40px; overflow-y: auto; }
.logo { display: flex; gap: 6px; align-items: flex-end; height: 40px; }
.logo i { display: block; width: 6px; height: 40px; background: var(--accent); border-radius: 3px; }
.logo b { display: block; width: 40px; height: 6px; background: var(--warn); border-radius: 3px; margin-left: -38px; margin-bottom: 17px; transform: rotate(-28deg); }
.divider { display: flex; align-items: center; gap: 12px; color: var(--dim); font-size: 14px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border-2); }
.my-groups { display: flex; flex-direction: column; gap: 8px; }
.group-link {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 16px; padding: 14px 16px;
}
.group-link:hover { border-color: var(--border); }
.group-link .name { flex: 1; min-width: 0; font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-link .meta { font-size: 13px; color: var(--dim); }

/* setup */
.emoji-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.emoji-opt {
  height: 50px; border: 1px solid var(--border-2); border-radius: 14px; background: var(--surface-2);
  font-size: 24px; padding: 0; opacity: 0.55; transition: opacity .12s ease;
}
.emoji-opt[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-soft); opacity: 1; }
.input-sm { height: 46px; border-radius: 12px; font-size: 16px; padding: 0 14px; flex: 1; min-width: 0; }
.btn-add { height: 46px; padding: 0 16px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); font-size: 15px; font-weight: 700; }
.footer-bar { padding: 12px 24px calc(28px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.footer-bar .btn { width: 100%; }

/* invite */
.code-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 28px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
}
.code-card .code { font-family: var(--display); font-weight: 800; font-size: 54px; letter-spacing: 4px; color: var(--accent); }
.link-box {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-2);
  border-radius: 14px; padding: 6px 6px 6px 14px;
}
.link-box span { flex: 1; min-width: 0; font-size: 15px; color: var(--soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-box button { height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--raised); font-size: 14px; font-weight: 700; }

/* join */
.preview { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); min-height: 20px; }
.preview b { color: var(--text); }

/* groep */
.group-head { padding: 18px 16px 14px 20px; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); }
.group-head .titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.group-head h2 { margin: 0; font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-head .hint { display: flex; align-items: center; gap: 6px; }
@media (max-width: 400px) {
  .wide-only { display: none; }
  .group-head .btn-small { width: 44px; padding: 0; justify-content: center; }
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); flex: 0 0 auto; }
.live-dot.on { background: #7BE495; box-shadow: 0 0 0 3px rgba(123, 228, 149, .15); }
.group-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.member { background: var(--surface-2); border: 1px solid #2A2732; border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.member.me { background: #211F28; border-color: #4A4556; }
.member-head { display: flex; align-items: center; gap: 10px; }
.avatar { width: 36px; height: 36px; border-radius: 18px; background: var(--raised); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; flex: 0 0 auto; }
.member-name { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.member-name span:first-child { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-me { font-size: 12px; font-weight: 700; color: var(--bg); background: var(--accent); border-radius: 6px; padding: 1px 6px; }
.entries { display: flex; flex-wrap: wrap; gap: 6px; }
.entry { width: 46px; display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--surface-3); border-radius: 10px; padding: 6px 0 5px; }
.entry.pending { opacity: .5; }
.entry { position: relative; }
.entry .e { font-size: 22px; line-height: 1; }
.entry .frac {
  position: absolute; top: -5px; right: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--bg); font-size: 12px; font-weight: 800; line-height: 18px; text-align: center;
}
.totals { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.total {
  display: inline-flex; align-items: center; gap: 4px; background: var(--raised); border-radius: 10px; padding: 3px 8px 3px 6px;
  font-family: var(--display); font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums;
}
.total span { font-size: 16px; }
.entry .t { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entry.new { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 70% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

.feed { display: flex; flex-direction: column; gap: 8px; padding: 8px 4px 4px; }
.feed .overline { letter-spacing: 1px; }
.feed-row { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.feed-row .t { width: 42px; color: var(--dim); font-variant-numeric: tabular-nums; }
.feed-row .e { font-size: 18px; }
.feed-row .n { color: var(--soft); }
.feed-row .n b { color: var(--accent); }

.dock { border-top: 1px solid var(--line); background: var(--footer); padding: 12px 16px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.dock-row { display: flex; justify-content: space-between; align-items: center; min-height: 32px; }
.step { font-size: 13px; color: var(--muted); }
.step b { color: var(--accent); }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.amount {
  height: 48px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-3); color: var(--text);
  font-family: var(--display); font-weight: 800; font-size: 22px;
}
.amount[aria-checked="true"] { border-color: var(--accent); }
.emoji-bar.locked .emoji-btn { opacity: .35; }
.emoji-btn:disabled { cursor: default; }
.amount[aria-checked="true"] { background: var(--accent); color: var(--bg); }
.emoji-btn { position: relative; }
.emoji-btn::after {
  content: var(--frac, ''); position: absolute; top: 3px; right: 4px; font-size: 12px; font-weight: 800;
  color: var(--accent); font-family: var(--display);
}
.emoji-bar { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.emoji-bar::-webkit-scrollbar { display: none; }
.emoji-btn {
  flex: 0 0 auto; width: 58px; height: 58px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface-3); font-size: 28px; padding: 0; transition: transform .08s ease;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
.emoji-btn:active { transform: scale(0.9); background: var(--raised); }

/* menu */
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; z-index: 10; }
.sheet {
  width: 100%; background: var(--footer); border-top: 1px solid var(--border); border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet .btn { width: 100%; }
.btn-danger { color: var(--error); border-color: #5A2E33; }

.toast {
  position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px; padding: 10px 16px; border-radius: 12px;
  max-width: calc(100% - 32px); z-index: 20; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.loading { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--dim); }

/* wrapped-knop */
.wrapped-btn {
  margin-top: 8px; width: 100%; height: 60px; border: 0; border-radius: 18px;
  background: linear-gradient(120deg, var(--accent) 0%, #9BD14A 55%, var(--warn) 100%);
  color: var(--bg); font-family: var(--display); font-weight: 800; font-size: 19px; letter-spacing: -0.2px;
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 0 16px;
}
.wrapped-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* wrapped-story */
.wrapped {
  position: absolute; inset: 0; z-index: 30; color: var(--text); overflow: hidden;
  display: flex; flex-direction: column; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  padding-top: env(safe-area-inset-top); transition: background .4s ease; outline: none;
}
.wrapped.dark-text { color: var(--bg); }
.wr-bars { display: flex; gap: 4px; padding: 12px 12px 0; position: relative; z-index: 2; }
.wr-seg { flex: 1; height: 3px; border-radius: 2px; background: rgba(255, 255, 255, .25); overflow: hidden; }
.dark-text .wr-seg { background: rgba(21, 19, 26, .2); }
.wr-seg span { display: block; height: 100%; width: 0; background: currentColor; }
.wr-seg.done span { width: 100%; }
.wr-seg.active span { animation: wr-fill var(--slide-ms) linear forwards; }
@keyframes wr-fill { to { width: 100%; } }
.wr-close { position: absolute; top: calc(22px + env(safe-area-inset-top)); right: 8px; z-index: 3; width: 44px; height: 44px; border: 0; background: transparent; color: inherit; display: flex; align-items: center; justify-content: center; }
.wr-stage { flex: 1; min-height: 0; position: relative; }
.wr-slide {
  position: absolute; inset: 0; padding: 72px 28px calc(36px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; justify-content: center; gap: 16px;
}
.wr-slide > * { position: relative; z-index: 1; animation: wr-in .6s cubic-bezier(.2, .8, .2, 1) both; }
.wr-slide > :nth-child(2) { animation-delay: .08s; }
.wr-slide > :nth-child(3) { animation-delay: .16s; }
.wr-slide > :nth-child(4) { animation-delay: .24s; }
.wr-slide > :nth-child(5) { animation-delay: .32s; }
@keyframes wr-in { from { opacity: 0; transform: translateY(18px); } }
.wrapped.paused *, .wrapped.paused *::before { animation-play-state: paused !important; }

.wr-kicker { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; opacity: .75; }
.wr-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: 40px; line-height: 1.02; letter-spacing: -1px; overflow-wrap: anywhere; }
.wr-huge { font-size: 56px; letter-spacing: -2px; }
.wr-wrapped { margin: -6px 0 0; font-family: var(--display); font-weight: 800; font-size: 34px; color: var(--accent); letter-spacing: -0.5px; }
.wr-line { margin: 0; font-size: 18px; line-height: 1.4; opacity: .9; }
.wr-line b { font-weight: 700; }
.wr-giant { font-size: 120px; line-height: 1; text-align: center; margin-top: 16px; }
.wr-logo { display: flex; gap: 6px; align-items: flex-end; height: 40px; }
.wr-logo i { display: block; width: 6px; height: 40px; background: var(--accent); border-radius: 3px; }
.wr-logo b { display: block; width: 40px; height: 6px; background: var(--warn); border-radius: 3px; margin-left: -38px; margin-bottom: 17px; transform: rotate(-28deg); }

.wr-confetti { position: absolute !important; inset: 0; pointer-events: none; z-index: 0 !important; overflow: hidden; animation: none !important; }
.wr-confetti span { position: absolute; top: -60px; opacity: .35; animation: wr-drop linear infinite; }
@keyframes wr-drop { to { transform: translateY(115vh) rotate(200deg); } }

.wr-totals { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.wr-total { display: flex; align-items: center; gap: 14px; animation: wr-in .6s cubic-bezier(.2, .8, .2, 1) both; }
.wr-total-e { font-size: 52px; line-height: 1; }
.wr-total-n { font-family: var(--display); font-weight: 800; font-size: 52px; letter-spacing: -1.5px; }

.wr-wall { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.wr-chip {
  position: relative; width: 52px; height: 52px; border-radius: 14px; background: rgba(255, 255, 255, .1);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  animation: wr-pop .45s cubic-bezier(.3, 1.6, .5, 1) both;
}
.dark-text .wr-chip { background: rgba(21, 19, 26, .12); }
.wr-chip small {
  position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 10px;
  background: var(--accent); color: var(--bg); font-size: 12px; font-weight: 800; line-height: 20px; text-align: center;
}
.wr-more { align-self: center; font-weight: 700; opacity: .8; }
@keyframes wr-pop { from { opacity: 0; transform: scale(.3); } }

.wr-awards { display: flex; flex-direction: column; gap: 12px; }
.wr-award {
  display: flex; align-items: center; gap: 14px; background: rgba(21, 19, 26, .28); border-radius: 16px; padding: 10px 14px;
  animation: wr-in .6s cubic-bezier(.2, .8, .2, 1) both;
}
.wr-award-icon { font-size: 32px; width: 40px; text-align: center; flex: 0 0 auto; }
.wr-award div { display: flex; flex-direction: column; min-width: 0; }
.wr-award-title { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; opacity: .8; }
.wr-award b { font-family: var(--display); font-weight: 800; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wr-award small { font-size: 13px; opacity: .85; }

.wr-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; margin-top: 16px; }
.wr-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.wr-bar span { width: 100%; max-width: 36px; border-radius: 6px 6px 3px 3px; background: rgba(255, 255, 255, .3); transform-origin: bottom; animation: wr-grow .7s cubic-bezier(.2, .8, .2, 1) both; }
.wr-bar.peak span { background: var(--accent); }
.wr-bar small { font-size: 12px; opacity: .75; font-variant-numeric: tabular-nums; }
@keyframes wr-grow { from { transform: scaleY(0); } }

.wr-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.wr-actions .btn:not(.btn-primary) { border-color: rgba(255, 255, 255, .3); background: var(--bg); }
.wr-done { height: 40px; font-size: 15px; }
@media (prefers-reduced-motion: reduce) {
  .wrapped *, .wrapped *::before { animation-duration: 0s !important; animation-delay: 0s !important; }
  .wr-seg.active span { animation-duration: var(--slide-ms) !important; }
  .wr-confetti { display: none; }
}
