/* One layout, two palettes. Light: each round's field colour behind the duel, ink words.
   Dark: true black, you in blue on the left, them in salmon on the right. */
:root {
  --g: #ffffff; --s: #f1f2f3; --s2: #e4e5e7;
  --ink: #111214; --mu: #6c7077; --on: #ffffff; --inbg: #ffffff; --inb: #111214;
  --you: var(--ink); --oth: var(--ink);
  --ok: #2f8f57; --warn: #c08a1a; --bad: #c8452f;
  --trk: rgba(17, 18, 20, .14); --n: #a0a4aa;
  --duo-ink: #111214; --duo-mu: rgba(17, 18, 20, .66);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --spring: cubic-bezier(.2, .9, .25, 1); --out: cubic-bezier(.4, 0, .2, 1);
  color-scheme: light;
}
/* Round colours; the second of each pair is the right-hand column. */
.f1 { --fa: #bccdb3; --fb: #aebfa5; } .f2 { --fa: #b6c8d7; --fb: #a6b9c9; } .f3 { --fa: #dbb8ae; --fb: #cda99f; }
.f4 { --fa: #aac6c0; --fb: #9bb9b2; } .f5 { --fa: #cbd0a2; --fb: #bcc294; }
:root[data-theme="dark"] {
  --g: #000000; --s: #161616; --s2: #272727;
  --ink: #f3f3f3; --mu: #8f8f8f; --on: #000000; --inbg: #0c0c0c; --inb: #5a5a5a;
  --you: #93b6db; --oth: #e6a593;
  --ok: #6fcf8f; --warn: #e0b048; --bad: #ef7a64;
  --trk: #333333; --n: #5f5f5f;
  --duo-ink: #f3f3f3; --duo-mu: #8f8f8f;
  color-scheme: dark;
}
:root[data-theme="dark"] :is(.f1, .f2, .f3, .f4, .f5) { --fa: #000000; --fb: #161616; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--g); }
body { margin: 0; background: var(--g); color: var(--ink); font: 16px/1.5 var(--font); transition: background-color .25s, color .25s; }
button, input { font: inherit; color: inherit; }
.app { max-width: 520px; margin: 0 auto; padding: 0 18px calc(32px + env(safe-area-inset-bottom)); }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
.muted { color: var(--mu); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--mu); display: inline-block; flex: none; }
.dot.good { background: var(--ok); } .dot.ok { background: var(--warn); } .dot.bad { background: var(--bad); }

/* controls */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 26px; background: var(--ink); color: var(--on); font-size: 16px; font-weight: 600; cursor: pointer; padding: 0 18px; text-decoration: none; transition: transform .14s var(--spring), opacity .14s, background-color .2s; }
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }
.btn.ghost { background: var(--s); color: var(--ink); }
.btn.narrow { max-width: 260px; margin: 0 auto; }
.stack > * + * { margin-top: 10px; }
.link { display: block; width: fit-content; text-decoration: none; margin: 14px auto 0; background: none; border: 0; color: var(--mu); padding: 8px 0; cursor: pointer; font-size: 15px; }
.input { width: 100%; height: 48px; border: 0; border-radius: 12px; background: var(--s); padding: 0 14px; font-size: 17px; outline: none; }
.input:focus-visible { box-shadow: inset 0 0 0 1.5px var(--ink); }
.field { margin: 0 0 16px; }
.label { display: block; font-size: 14px; color: var(--mu); margin: 0 0 6px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { flex: 1 0 auto; min-width: 56px; height: 40px; border: 0; border-radius: 20px; background: var(--s); cursor: pointer; padding: 0 12px; font-size: 15px; transition: background-color .15s, color .15s, transform .14s var(--spring); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--on); }
.seg button:active { transform: scale(.95); }
.custom-in { margin-top: 8px; }
.toggle { appearance: none; -webkit-appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--s2); position: relative; cursor: pointer; margin: 0; flex: none; transition: background-color .2s; }
.toggle::after { content: ""; position: absolute; left: 3px; top: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .24s var(--spring); }
.toggle:checked { background: var(--ink); }
.toggle:checked::after { transform: translateX(18px); background: var(--on); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) {
  .btn:hover { opacity: .88; }
  .seg button:not([aria-pressed="true"]):hover, .chip-f:not([aria-pressed="true"]):hover { background: var(--s2); }
}

/* lobby */
.top { position: sticky; top: 0; z-index: 5; background: var(--g); margin: 0 -18px; padding: 20px 18px 12px; transition: background-color .25s; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin-right: auto; white-space: nowrap; }
.brand h1 .a { color: var(--you); } .brand h1 .b { color: var(--oth); }
.net-mini { font-size: 13px; color: var(--mu); display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.theme-t { width: 40px; height: 40px; margin-right: -10px; border: 0; background: none; color: var(--ink); display: flex; align-items: center; justify-content: center; border-radius: 20px; cursor: pointer; transition: transform .25s var(--spring); }
.theme-t:active { transform: scale(.88) rotate(-25deg); }
.theme-t svg { width: 20px; height: 20px; }
.tagline { margin: 6px 0 18px; font-size: 15px; color: var(--mu); }
.nethint { margin: -8px 0 12px; font-size: 14px; color: var(--bad); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -18px; padding: 0 18px; -webkit-user-select: none; user-select: none; }
.chips::-webkit-scrollbar { display: none; }
.chip-f { flex: none; height: 36px; padding: 0 15px; border: 0; border-radius: 18px; background: var(--s); font-size: 15px; cursor: pointer; white-space: nowrap; -webkit-touch-callout: none; transition: background-color .15s, color .15s, transform .14s var(--spring); }
.chip-f[aria-pressed="true"] { background: var(--ink); color: var(--on); }
.chip-f:active { transform: scale(.95); }
.chip-f .c { opacity: .55; margin-left: 5px; font-variant-numeric: tabular-nums; }
.chip-f.add { background: none; color: var(--mu); padding: 0 8px; }
.actions { display: flex; gap: 10px; padding: 14px 0 0; }
.actions .btn { min-height: 50px; }
.actions .match { flex: 1.6; } .actions .ghost { flex: 1; }
.count { padding: 28px 0 2px; font-size: 14px; color: var(--mu); min-height: 21px; }
.ptr { height: 0; overflow: hidden; display: flex; align-items: flex-end; justify-content: center; font-size: 14px; color: var(--mu); transition: height .2s; }
.ptr span { padding-bottom: 8px; }
ul.list { list-style: none; margin: 0; padding: 0; }
.r { display: flex; align-items: center; gap: 16px; padding: 18px 0; min-height: 80px; max-height: 140px; overflow: hidden; transition: opacity .3s, max-height .35s var(--out), padding .35s var(--out); }
.r + .r { box-shadow: 0 -1px 0 var(--s); }
.r:active .info { opacity: .6; }
.r .info { flex: 1; min-width: 0; }
.r .t { font-size: 17px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r .m { font-size: 13px; color: var(--mu); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r .m .set { display: inline-block; min-width: 9em; margin-right: 6px; }
.r .m b { color: var(--ink); font-weight: 500; }
.r .join { width: auto; min-height: 38px; padding: 0 18px; font-size: 15px; flex: none; }
.r.new { animation: row-in .5s var(--spring) both; }
@keyframes row-in { from { opacity: 0; transform: translateY(-10px) scale(.98); } }
.r.full { opacity: .4; }
.r.gone { opacity: 0; max-height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; }
.r.skel .t, .r.skel .m { background: var(--s); border-radius: 6px; height: 16px; width: 60%; animation: shimmer 1.2s ease-in-out infinite; }
.r.skel .m { height: 12px; width: 40%; margin-top: 8px; }
@keyframes shimmer { 50% { opacity: .5; } }
.newpill { position: fixed; left: 50%; top: 150px; transform: translateX(-50%); z-index: 6; height: 36px; padding: 0 16px; border: 0; border-radius: 18px; background: var(--ink); color: var(--on); font-size: 14px; font-weight: 600; cursor: pointer; animation: pill-in .3s var(--spring) both; }
@keyframes pill-in { from { opacity: 0; transform: translate(-50%, -10px); } }
.end { text-align: center; color: var(--mu); font-size: 14px; padding: 20px 0 40px; }
.end p { margin: 0 0 12px; }

/* sheets */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; animation: bg-in .2s ease both; }
@keyframes bg-in { from { opacity: 0; } }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; background: var(--g); border-radius: 22px 22px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom)); z-index: 31; max-height: 90vh; overflow-y: auto; animation: up .34s var(--spring); transition: transform .3s var(--spring); }
:root[data-theme="dark"] .sheet { background: #111; }
:root[data-theme="dark"] .sheet .input, :root[data-theme="dark"] .sheet .seg button:not([aria-pressed="true"]) { background: #1f1f1f; }
@keyframes up { from { transform: translateY(100%); } }
#sheetRoot.closing .sheet { transform: translateY(100%); transition: transform .2s var(--out); }
#sheetRoot.closing .sheet-bg { opacity: 0; transition: opacity .2s; }
.grab { width: 36px; height: 5px; border-radius: 3px; background: var(--s2); margin: 0 auto 14px; }
.sheet h2 { font-size: 22px; letter-spacing: -.01em; margin-bottom: 14px; }
.sheet-sub { margin: -8px 0 14px; }
.sheet > .btn { margin-top: 6px; }
.sheet .stack { margin-top: 16px; }
.matching { text-align: center; padding: 30px 0 20px; }
.matching .big { font-size: 20px; font-weight: 650; margin: 0 0 6px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--s2); border-top-color: var(--ink); margin: 0 auto 16px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tag-on { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--ink); color: var(--on); border-radius: 17px; height: 34px; padding: 0 10px 0 13px; font-size: 15px; cursor: pointer; }
.tag-on span { opacity: .6; font-size: 17px; line-height: 1; }
.sug { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; border: 0; border-radius: 10px; background: none; padding: 0 12px; font-size: 16px; text-align: left; cursor: pointer; transition: background-color .12s; }
.sug .sl { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug:active { background: var(--s2); }
@media (hover: hover) { .sug:hover { background: var(--s2); } }
.tag-on:active { transform: scale(.95); }

/* room */
.room { position: relative; }
.rt { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 12px; min-height: 56px; font-size: 15px; }
.rt .mid { position: absolute; left: 50%; transform: translateX(-50%); font-size: 13px; color: var(--mu); white-space: nowrap; }
.back { color: var(--mu); text-decoration: none; padding: 6px 0; flex: none; }
.rt .tags { max-width: 34%; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.none { opacity: .45; font-weight: 400 !important; }

/* the duel: you left, them right */
.duo { display: grid; grid-template-columns: 1fr 1fr; position: relative; margin: 0 -18px; min-height: 112px; color: var(--duo-ink); view-transition-name: duo; }
.col { padding: 14px 18px 20px; min-width: 0; background: var(--fa); transition: background-color .4s var(--out); }
.col.o { background: var(--fb); text-align: right; }
.p { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 0; color: var(--duo-mu); white-space: nowrap; }
.col.o .p { justify-content: flex-end; }
.col .l { font-size: 13px; color: var(--duo-mu); margin: 24px 0 0; }
.col b { display: block; font-size: 32px; font-weight: 850; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; overflow-wrap: anywhere; }
.col.y b { color: var(--you); } .col.o b { color: var(--oth); }
.ring { position: absolute; left: 50%; top: 14px; width: 68px; height: 68px; margin-left: -34px; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--trk); }
.ring .arc { stroke: var(--ink); stroke-linecap: round; stroke-dasharray: 201.06; }
.clock { position: absolute; left: 50%; top: 18px; width: 60px; height: 60px; margin-left: -30px; border-radius: 50%; background: var(--ink); color: var(--on); font-size: 26px; font-weight: 850; letter-spacing: -.03em; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; transition: background-color .2s; }
.clock.low { background: var(--bad); color: #fff; animation: tick 1s steps(1) infinite; }
@keyframes tick { 50% { transform: scale(1.06); } }

.form { display: flex; flex-direction: column; gap: 10px; margin: 22px 0 28px; }
.word-input { width: 100%; height: 60px; border: 0; outline: none; border-radius: 16px; background: var(--inbg); box-shadow: inset 0 0 0 1.5px var(--inb); padding: 0 18px; font-size: 22px; font-weight: 650; caret-color: var(--you); transition: box-shadow .15s, background-color .2s; }
.word-input:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.word-input::placeholder { font-weight: 400; opacity: 1; }
.form.done .word-input { background: var(--s); box-shadow: none; color: var(--you); -webkit-text-fill-color: var(--you); opacity: 1; }
.form.done .btn { background: var(--s); color: var(--mu); opacity: 1; }

.history { margin: 0 -18px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; min-height: 46px; font-size: 16px; font-weight: 600; }
.pair > span { display: flex; align-items: center; padding: 6px 18px; min-width: 0; overflow-wrap: anywhere; }
.pair .ca { color: var(--you); gap: 10px; }
.pair .cb { color: var(--oth); background: var(--s); justify-content: flex-end; text-align: right; }
.pair .n { font-size: 12px; font-weight: 400; color: var(--n); flex: none; min-width: 1.2em; }
.pair:first-child > span { padding-top: 10px; }
.pair:last-child > span { padding-bottom: 12px; }
.dots { display: inline-flex; gap: 4px; align-items: center; height: 20px; color: var(--you); }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .3; animation: dot 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 0%, 60%, 100% { opacity: .3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.check { color: var(--ok); display: inline-flex; animation: pop .34s var(--spring) both; }
.check svg { width: 22px; height: 22px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* reveal */
.votes { margin: 22px 0 28px; }
.vote-note { text-align: center; font-size: 14px; color: var(--mu); margin: 12px 0 0; }
.duo.rv { perspective: 800px; }
.rv b { animation: flip .55s var(--spring) both; backface-visibility: hidden; }
.rv .col.o b { animation-delay: .08s; }
.rv.shown b { animation: none; }
@keyframes flip { from { transform: rotateX(80deg) translateY(10px); opacity: 0; } 60% { opacity: 1; } }

/* waiting / done */
.big-h { font-size: 26px; line-height: 1.25; letter-spacing: -.02em; margin: 10px 0 16px; }
.waiting .stack { margin-top: 24px; }
.intro { font-size: 18px; margin: 16px 0 6px; }
.result-img { width: 100%; display: block; border-radius: 18px; background: var(--s); -webkit-touch-callout: default; user-select: none; }
:root:not([data-theme="dark"]) .result-img { box-shadow: 0 0 0 1px var(--s2); }
.opts { margin: 14px 0 0; }
.end-acts { margin-top: 20px; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; font-size: 15px; }
.opt .seg { flex: none; flex-wrap: nowrap; }
.opt .seg button { height: 34px; min-width: 62px; font-size: 14px; }
.save-tip { text-align: center; font-size: 14px; color: var(--mu); margin: 6px 0 14px; }
.merge { display: grid; grid-template-columns: 1fr 1fr; position: absolute; left: -18px; right: -18px; top: 110px; z-index: 2; pointer-events: none; }
.merge span { display: flex; align-items: center; justify-content: center; min-height: 100px; font-size: 30px; font-weight: 850; padding: 0 10px; overflow-wrap: anywhere; text-align: center; color: var(--duo-ink); }
.merge .a { background: var(--fa); color: var(--you); animation: merge-a 1.1s var(--spring) both; }
.merge .b { background: var(--fb); color: var(--oth); animation: merge-b 1.1s var(--spring) both; }
@keyframes merge-a { 45%, 70% { transform: translateX(50%) scale(1.04); opacity: 1; } 100% { transform: translateX(50%) translateY(-24px) scale(.94); opacity: 0; } }
@keyframes merge-b { 45%, 70% { transform: translateX(-50%) scale(1.04); opacity: 1; } 100% { transform: translateX(-50%) translateY(-24px) scale(.94); opacity: 0; } }
.room.enter .merge ~ * { animation-delay: .75s !important; }

/* page motion */
.room.enter > * { animation: rise .4s var(--spring) both; }
.room.enter > *:nth-child(2) { animation-delay: .03s; }
.room.enter > *:nth-child(3) { animation-delay: .06s; }
.room.enter > *:nth-child(4) { animation-delay: .09s; }
.room.enter > *:nth-child(n+5) { animation-delay: .12s; }
.room.enter > .duo, .room.enter > .merge { animation-name: none; }
.room.enter > .merge { animation: none; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
::view-transition-old(root) { animation: vt-out .16s var(--out) both; }
::view-transition-new(root) { animation: vt-in .3s var(--spring) both; }
::view-transition-group(duo) { animation-duration: .42s; animation-timing-function: var(--spring); }
@keyframes vt-out { to { opacity: 0; transform: scale(.985); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

.net { position: fixed; top: 0; left: 0; right: 0; z-index: 40; background: var(--warn); color: #1b1400; font-size: 14px; text-align: center; padding: calc(6px + env(safe-area-inset-top)) 12px 6px; }
.toast { position: fixed; left: 50%; bottom: calc(28px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: var(--on); padding: 11px 18px; border-radius: 22px; font-size: 15px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .3s var(--spring); max-width: calc(100% - 36px); text-align: center; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Reduced motion: keep fades and colour changes, drop travel, flips, loops and the merge. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .room.enter > *, .room.enter .merge ~ * { animation-delay: 0s !important; }
  .merge { display: none; }
  .dots i { opacity: .7; }
  .col { transition: background-color .2s linear !important; }
}
.sug .n { flex: none; color: var(--mu); font-size: 13px; font-variant-numeric: tabular-nums; }
.sheet.tall { min-height: 80vh; display: flex; flex-direction: column; }
.sheet.tall .pick { flex: 1; margin-bottom: 14px; }
.pick-label { font-size: 14px; color: var(--mu); margin: 0 0 6px; }
.picked { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.search { position: relative; z-index: 2; }
.search-i { position: absolute; left: 15px; top: 14px; width: 20px; height: 20px; color: var(--mu); pointer-events: none; }
.tag-input { width: 100%; height: 48px; border: 0; border-radius: 24px; background: var(--s); padding: 0 16px 0 44px; font-size: 16px; outline: none; transition: box-shadow .15s; }
.tag-input:focus { box-shadow: inset 0 0 0 1.5px var(--ink); }
.tag-input:disabled { opacity: .6; }
/* The suggestion card floats over the form, like a menu. */
.pop { position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 10; background: var(--g); border-radius: 16px; padding: 6px; max-height: min(296px, 44vh); overflow-y: auto; box-shadow: 0 14px 36px rgba(0,0,0,.14), 0 0 0 1px rgba(0,0,0,.06); transform-origin: top center; animation: pop-in .2s var(--spring); }
@keyframes pop-in { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.pop-h { margin: 6px 12px 4px; font-size: 12px; color: var(--mu); }
:root[data-theme="dark"] .pop { background: #1c1c1c; box-shadow: 0 14px 36px rgba(0,0,0,.6), 0 0 0 1px #2c2c2c; }
:root[data-theme="dark"] .sheet .tag-input { background: #1f1f1f; }
:root[data-theme="dark"] .sug:active, :root[data-theme="dark"] .sug:hover { background: #2a2a2a; }
