:root {
  --bg: #17142e; --bg2: #211d40; --card: #2a2550; --line: #3a3470; --ink: #f4f1ff; --mute: #a29cc9;
  --yellow: #ffcf3f; --pink: #ff5d8f; --mint: #5de0c6; --violet: #8f7bff; --red: #ff6b6b;
  --display: 'Bricolage Grotesque', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
body { background: radial-gradient(120% 60% at 50% -10%, #2c2562 0%, var(--bg) 60%) fixed; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { opacity: .45; cursor: default; }
#app { max-width: 560px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; overflow-y: auto; padding: 4px 16px 16px; display: flex; flex-direction: column; }
h1 { font: 800 clamp(30px, 8vw, 40px)/1.05 var(--display); letter-spacing: -.02em; margin: 0 0 12px; }
h1 em { font-style: normal; color: var(--yellow); }
h2 { font: 700 14px var(--display); text-transform: uppercase; letter-spacing: .08em; color: var(--mute); margin: 22px 0 8px; }
.muted { color: var(--mute); font-size: 14px; }
.center { text-align: center; }

/* top + tabs */
.top { display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 8px; }
.brand { font: 800 24px var(--display); letter-spacing: -.03em; }
.brand span { color: var(--pink); }
.brand.big { font-size: 40px; margin-bottom: 28px; }
.chips { display: flex; gap: 8px; }
.chip { background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-weight: 700; font-size: 14px; }
.tabs { display: flex; border-top: 1px solid var(--line); background: rgba(23, 20, 46, .92); backdrop-filter: blur(10px); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; padding: 8px 0 10px; color: var(--mute); font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs button span { font-size: 20px; filter: grayscale(1) opacity(.6); transition: .2s; }
.tabs button.on { color: var(--ink); }
.tabs button.on span { filter: none; transform: translateY(-2px) scale(1.1); }

/* buttons */
.big { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 16px; border-radius: 16px; font: 700 18px var(--display);
  background: var(--yellow); color: #1b1630; box-shadow: 0 5px 0 #c99a10; transition: transform .08s, box-shadow .08s; }
.big:active { transform: translateY(4px); box-shadow: 0 1px 0 #c99a10; }
.big.ghost { background: var(--card); color: var(--ink); box-shadow: 0 5px 0 #15122b; }
.big.google { background: #fff; box-shadow: 0 5px 0 #b9b4d8; }
.link { color: var(--mute); text-decoration: underline; font-size: 14px; }

/* practice */
.start { margin: auto 0; padding: 24px 4px; }
.start p { color: var(--mute); margin: 0 0 28px; font-size: 17px; }
.progress { position: relative; height: 26px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin: 4px 0 10px; flex-shrink: 0; }
.progress div { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--violet), var(--pink)); border-radius: 99px; transition: width .5s cubic-bezier(.3, 1.4, .5, 1); }
.progress span { position: relative; display: block; text-align: center; font-size: 13px; font-weight: 700; line-height: 26px; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 4px 0 12px; }
main.practice { overflow: hidden; }
.b { max-width: 86%; padding: 11px 15px; border-radius: 20px; animation: pop .25s ease-out; white-space: normal; }
.b.coach { background: var(--card); border-bottom-left-radius: 6px; align-self: flex-start; }
.b.me { background: var(--violet); color: #fff; border-bottom-right-radius: 6px; align-self: flex-end; }
.b.situation { background: linear-gradient(135deg, #3a2f7a, #2a2550); border: 1px solid #5546a8; font-size: 17px; }
.b.hint { background: #3b3216; border: 1px solid #6e5b1c; color: #ffe9a6; }
.b.ask { border: 1px solid var(--mint); }
.b.done { background: linear-gradient(135deg, #5a2350, #2a2550); font-size: 17px; }
.b.intro { color: var(--mute); background: transparent; padding-left: 2px; }
.b b { color: var(--yellow); }
.b.me b { color: #fff; }
.typing { display: flex; gap: 5px; padding: 15px 18px; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); animation: bounce 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
.composer { flex-shrink: 0; padding-top: 6px; }
.tools { display: flex; gap: 8px; margin-bottom: 8px; }
.tools button { background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; padding: 7px 14px; font-size: 14px; font-weight: 600; }
.tools button small { color: var(--mute); font-weight: 400; margin-left: 4px; }
.tools button.warn { border-color: var(--pink); }
.row { display: flex; gap: 8px; align-items: flex-end; }
textarea, input { flex: 1; min-width: 0; background: var(--bg2); border: 1.5px solid var(--line); border-radius: 22px; padding: 12px 16px; resize: none; outline: none; max-height: 140px; font-size: 17px; }
textarea:focus, input:focus { border-color: var(--violet); }
.send { width: 48px; height: 48px; flex-shrink: 0; border-radius: 50%; background: var(--yellow); color: #1b1630; font-size: 20px; font-weight: 800; }

/* words */
.add { display: flex; gap: 8px; margin: 6px 0 12px; }
.add button { background: var(--violet); border-radius: 22px; padding: 0 18px; font-weight: 700; }
.pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; flex-shrink: 0; }
.pill { white-space: nowrap; background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 14px; color: var(--mute); }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.words { list-style: none; margin: 8px 0; padding: 0; }
.words li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.words li div { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.words li b { font: 700 18px var(--display); }
.words small { flex-basis: 100%; color: var(--mute); font-size: 13px; }
.tag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--card); }
.tag.due { background: #4a3a10; color: var(--yellow); } .tag.struggling { background: #4d1f33; color: var(--pink); }
.tag.known { background: #134a40; color: var(--mint); } .tag.learning { background: #2f2a66; color: #c3b8ff; }
.used { flex-shrink: 0; border: 1.5px solid var(--mint); color: var(--mint); border-radius: 99px; padding: 6px 12px; font-size: 14px; font-weight: 700; }
.used b { background: var(--mint); color: var(--bg); border-radius: 99px; padding: 0 6px; margin-left: 4px; font: inherit; }

/* friends */
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board li { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 18px; padding: 12px 14px; }
.board li.me { background: linear-gradient(135deg, #3a2f7a, #2a2550); border: 1px solid #5546a8; }
.rank { width: 28px; text-align: center; font: 800 20px var(--display); color: var(--mute); }
.who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.who b { font: 700 18px var(--display); }
.who small { color: var(--mute); font-size: 13px; }
.pts { font: 800 22px var(--display); color: var(--yellow); }
.duel { width: 44px; height: 44px; border-radius: 14px; background: var(--pink); font-size: 20px; box-shadow: 0 4px 0 #b33060; }
.duel:active { transform: translateY(3px); box-shadow: 0 1px 0 #b33060; }
.invite { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 14px; border: 1.5px dashed var(--line); border-radius: 18px; }
.invite div { flex: 1; display: flex; flex-direction: column; } .invite small { color: var(--mute); font-size: 13px; }
.invite button { background: var(--violet); border-radius: 99px; padding: 10px 16px; font-weight: 700; white-space: nowrap; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ch { display: flex; align-items: center; justify-content: space-between; background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; cursor: pointer; }
.ch div { display: flex; flex-direction: column; } .ch small { color: var(--mute); font-size: 13px; }
.ch.your-turn { border-color: var(--pink); animation: glow 2s infinite; }
.ch .go { font-weight: 700; color: var(--yellow); }
.me-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 24px; color: var(--mute); font-size: 14px; }
.me-row input { width: 130px; padding: 6px 12px; font-size: 15px; margin-left: 6px; flex: none; }
.owner { margin-top: 14px; color: var(--mute); font-size: 13px; }
.owner button { margin-top: 8px; border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; }

/* sign in */
.signin { margin: auto 0; padding: 32px 22px; display: flex; flex-direction: column; gap: 12px; }
.signin p { color: var(--mute); margin: 0 0 16px; font-size: 17px; }
.signin form { display: flex; flex-direction: column; gap: 12px; }
.or { text-align: center; color: var(--mute); font-size: 13px; }
.sent { background: var(--card); border-radius: 16px; padding: 16px; }

/* challenge overlay */
#ov { position: fixed; inset: 0; z-index: 10; background: var(--bg); background: radial-gradient(100% 50% at 50% 0%, #3d1f52 0%, var(--bg) 70%); overflow-y: auto; animation: fade .2s; }
.ch-screen { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding: calc(16px + env(safe-area-inset-top)) 18px calc(20px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; position: relative; }
.x { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 14px; width: 40px; height: 40px; border-radius: 50%; background: var(--bg2); font-size: 18px; }
.vs { font: 700 16px var(--display); color: var(--mute); margin: 24px 0 16px; }
.vs span { color: var(--pink); margin: 0 6px; }
.intro h1 { font-size: 42px; }
.rules { color: var(--mute); padding-left: 20px; margin: 4px 0 auto; line-height: 1.9; }
.intro .big, .results .big { margin-top: 24px; }
.ch-top { display: flex; justify-content: space-between; font: 700 16px var(--display); color: var(--mute); }
.ch-top .score { color: var(--yellow); font-size: 20px; }
.ring { position: relative; width: 104px; height: 104px; margin: 4px auto 14px; }
.ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 8; stroke: var(--bg2); }
.ring #arc { stroke: var(--mint); stroke-linecap: round; transition: stroke .3s; }
.ring #arc.low { stroke: var(--pink); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 800 34px var(--display); }
.sit { background: var(--card); border: 1px solid #5546a8; border-radius: 20px; padding: 16px 18px; font-size: 18px; line-height: 1.5; }
.hints { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.hint { background: #3b3216; border: 1px solid #6e5b1c; color: #ffe9a6; border-radius: 14px; padding: 8px 12px; font-size: 15px; animation: pop .25s; }
.flash { height: 0; overflow: hidden; text-align: center; transition: .2s; }
.flash.show { height: auto; padding: 10px; margin-bottom: 10px; border-radius: 16px; animation: pop .3s; }
.flash.good { background: #134a40; } .flash.bad { background: #4d1f33; }
.flash b { display: block; font: 800 28px var(--display); }
.flash.good b { color: var(--mint); } .flash.bad b { color: var(--pink); }
.flash span { font: 700 20px var(--display); }
#cans { margin-top: auto; }
#cans input { font-size: 20px; padding: 14px 18px; }
.ch-tools { display: flex; gap: 10px; margin-top: 10px; }
.ch-tools button { flex: 1; background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; font-weight: 700; }
.shake { animation: shake .35s; }
.scores { display: flex; gap: 10px; margin: 8px 0 16px; }
.scores div { flex: 1; background: var(--card); border-radius: 18px; padding: 12px; text-align: center; display: flex; flex-direction: column; }
.scores small { color: var(--mute); } .scores b { font: 800 34px var(--display); color: var(--yellow); }
.cmp { width: 100%; border-collapse: collapse; margin: 8px 0; }
.cmp th { text-align: left; color: var(--mute); font-size: 13px; font-weight: 600; padding: 6px 4px; }
.cmp td { padding: 9px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.cmp td:first-child b { font: 700 16px var(--display); }
.cmp td.ok { color: var(--mint); font-weight: 700; } .cmp td.no { color: var(--pink); } .cmp td.na { color: var(--mute); }
.cmp small { display: block; color: var(--mute); font-weight: 400; font-size: 12px; }

/* fun */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.float-pts { position: fixed; left: 50%; top: 42%; z-index: 51; transform: translateX(-50%); font: 800 44px var(--display); color: var(--yellow); text-shadow: 0 4px 20px rgba(255, 207, 63, .5); pointer-events: none; animation: rise 1.2s ease-out forwards; }
#toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60; width: max-content; max-width: 90vw; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-weight: 600; font-size: 15px; box-shadow: 0 8px 30px rgba(0, 0, 0, .4); animation: pop .2s; }
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes bounce { 50% { transform: translateY(-5px); opacity: .5; } }
@keyframes rise { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 20% { opacity: 1; transform: translate(-50%, 0) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -70px) scale(1); } }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }
@keyframes glow { 50% { box-shadow: 0 0 18px rgba(255, 93, 143, .35); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
