:root {
  --pink: #ff6fa8;
  --pink-soft: #ffe0ee;
  --yellow: #ffd43b;
  --yellow-soft: #fff6cf;
  --green: #2fbf71;
  --green-soft: #d8f8e6;
  --red: #ff5a5f;
  --red-soft: #ffe1e2;
  --blue: #4dabf7;
  --purple: #9775fa;
  --ink: #3d2c35;
  --muted: #8a7480;
  --card: #ffffff;
  --radius: 26px;
  --shadow: 0 6px 0 rgba(61, 44, 53, .12), 0 10px 24px rgba(61, 44, 53, .08);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at 10% 10%, #fff3b0 0 60px, transparent 61px),
    radial-gradient(circle at 90% 30%, #d0ebff 0 80px, transparent 81px),
    radial-gradient(circle at 20% 90%, #e5dbff 0 90px, transparent 91px),
    linear-gradient(180deg, #ffe4f1 0%, #fff5fa 60%, #f3f0ff 100%);
  background-attachment: fixed;
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; position: sticky; top: 0; z-index: 5;
  background: rgba(255, 245, 250, .85); backdrop-filter: blur(8px);
}
.logo { font-weight: 900; font-size: 1.5rem; display: flex; align-items: center; gap: 6px; color: var(--pink); }
.logo-icon { width: 52px; height: 52px; animation: wobble 3s ease-in-out infinite; }
.logo-text { display: flex; flex-direction: column; line-height: .95; text-align: left; font-size: 1.6rem; color: var(--pink);
  text-shadow: 2px 2px 0 #fff, -2px 2px 0 #fff, 2px -2px 0 #fff, -2px -2px 0 #fff; }
.logo-text small { font-size: .8rem; color: var(--purple); letter-spacing: 2px; text-transform: uppercase; }
.me-chip {
  background: #fff; border-radius: 999px; padding: 6px 14px 6px 8px; font-weight: 800;
  display: flex; align-items: center; gap: 6px; box-shadow: var(--shadow);
}
.me-chip .av { font-size: 1.6rem; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 120px; }

h1 { font-size: 2rem; margin: 12px 0 4px; text-align: center; }
h2 { font-size: 1.5rem; margin: 24px 0 10px; }
.sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 1.15rem; }
.center { text-align: center; }

/* ---------- read-aloud ---------- */
.say {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: var(--shadow);
  font-size: 1.3rem; vertical-align: middle; margin-left: 8px;
}

/* ---------- big buttons ---------- */
.big-btns { display: grid; gap: 16px; margin-top: 12px; }
.big {
  display: flex; align-items: center; gap: 16px; width: 100%;
  padding: 20px 22px; border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow); text-align: left; font-weight: 900; font-size: 1.5rem;
  transition: transform .1s;
}
.big:active { transform: translateY(4px) scale(.99); box-shadow: 0 2px 0 rgba(61, 44, 53, .12); }
.big .icon { font-size: 3rem; flex: none; }
.big small { display: block; font-weight: 600; font-size: 1rem; color: var(--muted); }
.big.pink { background: linear-gradient(135deg, #ff8cc0, #ff6fa8); color: #fff; }
.big.pink small { color: #ffe6f2; }
.big.yellow { background: linear-gradient(135deg, #ffe066, #ffc929); }
.big.purple { background: linear-gradient(135deg, #b197fc, #9775fa); color: #fff; }
.big.purple small { color: #efe9ff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 12px 22px; border-radius: 999px; font-weight: 900; font-size: 1.2rem;
  background: #fff; box-shadow: var(--shadow); transition: transform .1s;
}
.btn:active { transform: translateY(3px); }
.btn.primary { background: var(--pink); color: #fff; }
.btn.go { background: var(--green); color: #fff; }
.btn.stop { background: var(--red); color: #fff; }
.btn.add { background: var(--yellow); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.link-btn { color: var(--muted); text-decoration: underline; font-weight: 700; padding: 12px; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }

/* ---------- squishy tiles ---------- */
.squish {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  width: 100%; padding: 8px; border-radius: 20px; background: #fff;
  font-weight: 800; font-size: .9rem; text-align: center; line-height: 1.15;
}
.squish .pic { width: 100%; aspect-ratio: 1; display: grid; place-items: center; }
.squish .pic svg { width: 92%; height: 92%; }
.squish .pic img { width: 92%; height: 92%; object-fit: cover; border-radius: 18px; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.squish.mini { padding: 4px; font-size: .75rem; }
.squish.hero { max-width: 260px; margin: 0 auto; font-size: 1.3rem; background: transparent; }
.squish.hero .pic { animation: squeeze 2.4s ease-in-out infinite; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.grid .squish { box-shadow: var(--shadow); transition: transform .1s; position: relative; }
.grid .squish:active { transform: scale(.94); }
.grid .squish.on { outline: 5px solid var(--pink); }
.grid .squish .count {
  position: absolute; top: -6px; right: -6px; background: var(--pink); color: #fff; border-radius: 999px;
  min-width: 30px; height: 30px; display: grid; place-items: center; font-size: 1rem;
}
.photo-tile { background: linear-gradient(135deg, #d0ebff, #e5dbff) !important; }
.photo-tile .pic { font-size: 3.4rem; }

.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.tab {
  flex: none; padding: 10px 16px; border-radius: 999px; background: #fff; font-weight: 800;
  box-shadow: 0 3px 0 rgba(61, 44, 53, .1);
}
.tab.on { background: var(--pink); color: #fff; }

/* ---------- profile ---------- */
.name-big { font-size: 2.2rem; font-weight: 900; text-align: center; margin: 8px 0; color: var(--pink); }
.av-big { font-size: 5rem; text-align: center; animation: bounce 1.8s ease-in-out infinite; }
.pick-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
.pick {
  font-size: 2.2rem; padding: 8px; border-radius: 18px; background: #fff; box-shadow: 0 3px 0 rgba(61,44,53,.1);
}
.pick.on { outline: 4px solid var(--pink); background: var(--pink-soft); }
.word { font-size: 1rem; font-weight: 800; }

/* ---------- code pad ---------- */
.code-slots { display: flex; gap: 10px; justify-content: center; margin: 12px 0 20px; }
.slot {
  width: 68px; height: 68px; border-radius: 20px; background: #fff; display: grid; place-items: center;
  font-size: 2.4rem; box-shadow: inset 0 3px 0 rgba(61,44,53,.1); border: 3px dashed #f3c4d9;
}
.slot.filled { border: 3px solid var(--pink); animation: pop .25s; }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; }
.pad button { font-size: 2.4rem; aspect-ratio: 1; border-radius: 20px; background: #fff; box-shadow: var(--shadow); }
.pad button:active { transform: scale(.92); }
.code-show { display: flex; gap: 8px; justify-content: center; font-size: 2.6rem; }
.code-show span { background: #fff; border-radius: 16px; width: 64px; height: 64px; display: grid; place-items: center; box-shadow: var(--shadow); }

/* ---------- trade mat ---------- */
.mat {
  position: relative; border-radius: 34px; padding: 18px 14px 22px; margin: 8px 0 18px;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 14px, transparent 14px 28px),
    linear-gradient(135deg, #c3fae8, #d0ebff);
  border: 5px dashed #fff; box-shadow: var(--shadow);
}
.mat .label { text-align: center; font-weight: 900; color: #1c7ed6; }
.hot { text-align: center; font-weight: 900; font-size: 1.1rem; margin-top: 4px; }
.hot .flame { display: inline-block; animation: wobble 1s infinite; }

.invite { text-align: center; }
.invite p { margin: 6px 0 10px; font-weight: 700; }

.offer {
  border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); padding: 14px; margin-bottom: 16px;
  border: 4px solid transparent;
}
.offer.fresh { animation: slidein .4s ease-out, flash 1.6s ease-out; }
.new-tag { background: var(--pink); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: .8rem; animation: pop .3s; }
.live-row { display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 900; margin-top: 4px; }
.live { display: inline-flex; align-items: center; gap: 6px; background: #fff; color: var(--red); padding: 4px 12px; border-radius: 999px; box-shadow: 0 3px 0 rgba(61,44,53,.1); font-size: .9rem; letter-spacing: 1px; }
.live .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--red); animation: blink 1.2s infinite; }
.watching { background: #fff; padding: 4px 12px; border-radius: 999px; box-shadow: 0 3px 0 rgba(61,44,53,.1); font-size: .95rem; }
.offer.mine { border-color: var(--purple); }
.offer.st-accepted { border-color: var(--green); background: var(--green-soft); }
.offer.st-no_thanks, .offer.st-not_picked { opacity: .6; }
.offer.st-add_more { border-color: var(--yellow); background: var(--yellow-soft); }
.offer-who { display: flex; align-items: center; gap: 8px; font-weight: 900; font-size: 1.15rem; }
.offer-who .av { font-size: 2rem; }
.offer-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; margin: 10px 0; }
.offer-items .squish { background: #f8f4ff; }
.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-weight: 900; font-size: .95rem; margin-left: auto; }
.badge.waiting { background: #eef; }
.badge.add_more { background: var(--yellow); }
.badge.no_thanks { background: var(--red-soft); }
.badge.accepted { background: var(--green); color: #fff; }
.badge.not_picked { background: #eee; }

/* The three mat zones: ✓ ➕ ✗ */
.zones { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 84px; border-radius: 22px; font-weight: 900; font-size: 1rem; color: #fff;
  box-shadow: 0 5px 0 rgba(0,0,0,.15); transition: transform .1s;
}
.zone .z { font-size: 2.2rem; line-height: 1; }
.zone:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }
.zone.trade { background: var(--green); }
.zone.addmore { background: var(--yellow); color: var(--ink); }
.zone.no { background: var(--red); }

.status-box { text-align: center; border-radius: var(--radius); padding: 18px; font-size: 1.3rem; font-weight: 900; margin: 12px 0; }
.status-box.waiting { background: #eef3ff; }
.status-box.add_more { background: var(--yellow-soft); border: 4px solid var(--yellow); }
.status-box.no_thanks { background: var(--red-soft); }
.status-box.accepted { background: var(--green-soft); border: 4px solid var(--green); }
.status-box.not_picked { background: #f1f1f1; }
.status-box .e { font-size: 3rem; display: block; }

/* tray of squishies being offered */
.tray {
  position: sticky; bottom: 0; background: #fff; border-radius: 26px 26px 0 0; padding: 12px;
  box-shadow: 0 -6px 20px rgba(61,44,53,.15); margin: 16px -16px -120px;
}
.tray-items { display: flex; gap: 8px; overflow-x: auto; min-height: 84px; align-items: center; }
.tray-items .squish { width: 78px; flex: none; background: #f8f4ff; position: relative; }
.tray-items .x { position: absolute; top: -4px; right: -4px; background: var(--red); color: #fff; border-radius: 50%; width: 26px; height: 26px; font-size: .9rem; }
.tray-empty { color: var(--muted); font-weight: 700; padding: 0 8px; }

/* trade history */
.trade-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.trade-row .side { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.trade-row .arrow { font-size: 2rem; }
.trade-meta { color: var(--muted); font-weight: 700; font-size: .95rem; margin-top: 6px; text-align: center; }

.empty { text-align: center; color: var(--muted); padding: 24px; font-weight: 700; }
.empty .e { font-size: 3.5rem; display: block; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20; background: rgba(61, 44, 53, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal[hidden] { display: none; }
.sheet {
  background: #fff7fb; width: 100%; max-width: 760px; max-height: 92vh; overflow-y: auto;
  border-radius: 30px 30px 0 0; padding: 18px 16px 28px; animation: up .25s ease-out;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; }
.close-x { width: 48px; height: 48px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 1.4rem; flex: none; }
.confirm { text-align: center; }
.confirm .swap { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin: 12px 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 999px; font-weight: 800;
  box-shadow: var(--shadow); max-width: 92vw; text-align: center;
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100%; height: 100%; }

.spinner { text-align: center; font-size: 3rem; padding: 40px; animation: bounce 1s infinite; }
.grownup { margin-top: 32px; font-size: .9rem; color: var(--muted); text-align: center; }

/* ---------- animations ---------- */
@keyframes squeeze { 0%, 100% { transform: scale(1, 1); } 45% { transform: scale(1.06, .92); } 60% { transform: scale(.96, 1.05); } }
@keyframes wobble { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes pop { 0% { transform: scale(.6); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes slidein { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes flash { 0% { box-shadow: 0 0 0 6px var(--yellow), var(--shadow); } 100% { box-shadow: var(--shadow); } }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (max-width: 420px) {
  .big { font-size: 1.3rem; padding: 16px; }
  .big .icon { font-size: 2.5rem; }
  .zone { min-height: 76px; font-size: .9rem; }
  .slot { width: 60px; height: 60px; }
}
.me-chip[hidden] { display: none; }
.logo-text, .logo-text small { white-space: nowrap; }

/* ---------- username ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.name-field input {
  display: block; width: 100%; margin: 8px 0 6px; padding: 14px 18px; text-align: center;
  font: inherit; font-size: 1.9rem; font-weight: 900; color: var(--pink);
  border: 4px solid var(--pink-soft); border-radius: 22px; background: #fffafd; outline: none;
}
.name-field input:focus { border-color: var(--pink); }
.name-field input::placeholder { color: #f3b8d2; }
.name-status { min-height: 1.6em; text-align: center; font-weight: 900; font-size: 1.1rem; }
.name-status.good { color: var(--green); }
.name-status.bad { color: var(--red); }
.name-status.wait { color: var(--muted); }
.ideas { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 6px 0; font-weight: 800; }
.idea { background: var(--yellow-soft); border: 3px solid var(--yellow); border-radius: 999px; padding: 8px 14px; font-weight: 900; }
.name-tip { text-align: center; font-weight: 700; color: var(--muted); margin: 12px 0 0; }

/* ---------- phones & iPads ---------- */
html { -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, a, input, .squish, .pick, .zone { touch-action: manipulation; }   /* no double-tap zoom */
button { -webkit-user-select: none; user-select: none; }
.topbar { padding-top: max(12px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
main { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: calc(120px + env(safe-area-inset-bottom)); }
.sheet { max-height: 92dvh; padding-bottom: calc(28px + env(safe-area-inset-bottom)); }
.tray { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.toast { bottom: calc(24px + env(safe-area-inset-bottom)); }
.link-btn { min-height: 48px; }

/* iPad / tablets: bigger tiles, centered sheets, two-column offers */
@media (min-width: 700px) {
  body { font-size: 20px; }
  main { max-width: 900px; }
  .big-btns { grid-template-columns: repeat(3, 1fr); }
  .big { flex-direction: column; text-align: center; padding: 26px 18px; }
  .big .icon { font-size: 3.6rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .modal { align-items: center; }
  .sheet { border-radius: 30px; max-width: 860px; max-height: 88dvh; }
  .tray { margin: 16px -16px -28px; border-radius: 26px; }
  #offersList { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; align-items: start; }
  .squish.hero { max-width: 300px; }
  .pad { max-width: 440px; }
  .slot { width: 80px; height: 80px; }
}
@media (min-width: 700px) and (orientation: landscape) {
  .mat-layout { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
  .mat-layout > .mat-side { position: sticky; top: 90px; }
  main { max-width: 1180px; }
  .mat-layout #offersList { grid-template-columns: 1fr 1fr; }
}

/* ---------- my completed trades ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 18px; }
.stat { background: #fff; border-radius: 20px; box-shadow: var(--shadow); padding: 12px 6px; text-align: center; }
.stat b { display: block; font-size: 1.9rem; color: var(--pink); line-height: 1.1; }
.stat span { font-size: .8rem; font-weight: 800; color: var(--muted); }
.trade-with { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; margin-bottom: 10px; }
.trade-with .av { font-size: 2.2rem; }
.trade-with small { display: block; color: var(--muted); font-weight: 700; font-size: .85rem; }
.badge.big-trade { background: var(--yellow); }
.tag { font-weight: 900; margin-top: 4px; }
.tag.got { color: var(--green); }
.tag.gave { color: var(--purple); }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.trade-row .side { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.trade-row .side .squish { width: 84px; }
.name-status.warn { color: #c77700; }
