/* ---------- Word Shake ---------- */
.ws { --tray: #0f3b4a; --tray-2: #0a2732; --cube: #fffaf0; --cube-2: #eee5d2; --cube-edge: #b9ad92; --ink: #2a1f3d;
  --sel: var(--accent); --good: #4fe39a; --dup: #ffa24d; --bad: #ff6b6b; gap: .45rem; }

/* players strip */
.ws-players { display: flex; gap: .35rem; flex: none; overflow-x: auto; scrollbar-width: none; padding-top: 2px; }
.ws-players::-webkit-scrollbar { display: none; }
.wp { flex: 1 0 0; min-width: 72px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 12px;
  padding: .25rem .45rem; display: flex; flex-direction: column; line-height: 1.15; }
.wp.me { border-color: var(--accent); box-shadow: 0 0 10px #ffc14540; }
.wp .nm { font-weight: 600; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wp .ct { font-family: var(--fun); font-weight: 700; font-size: 1.05rem; display: inline-block; transform-origin: left center; }
.wp .ct small { font-family: system-ui, sans-serif; font-weight: 400; font-size: .66rem; color: var(--muted); }
.wp .ct.bump { animation: bump .45s cubic-bezier(.3, 1.8, .5, 1); color: var(--good); }
@keyframes bump { 0% { transform: scale(1.5); } 100% { transform: none; } }

/* timer */
.ws-timer { flex: none; display: flex; align-items: center; gap: .55rem; }
.ws-timer .bar { flex: 1; height: 10px; border-radius: 99px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.ws-timer .bar i { display: block; height: 100%; transform-origin: left; border-radius: 99px;
  background: linear-gradient(90deg, #2bd4c4, #4fe39a); transition: transform .12s linear, background .4s; }
.ws-timer .clock { font-family: var(--fun); font-weight: 700; font-size: 1.15rem; min-width: 3.1em; text-align: right;
  font-variant-numeric: tabular-nums; }
.ws-timer.warn .bar i { background: linear-gradient(90deg, #ffb340, #ffd36b); }
.ws-timer.warn .clock { color: var(--accent); }
.ws-timer.panic .bar i { background: linear-gradient(90deg, #ff4d6d, #ff6b6b); }
.ws-timer.panic .clock { color: var(--bad); animation: throb 1s infinite; }
@keyframes throb { 0%, 100% { transform: scale(1); } 15% { transform: scale(1.25); } }

/* current word */
.ws-word { flex: none; height: 2.5rem; display: grid; place-items: center; }
.ws-word .txt { font-family: var(--fun); font-weight: 700; font-size: 1.55rem; letter-spacing: .1em; padding: .05em .7em;
  border-radius: 99px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; transition: background .12s, color .12s; }
.ws-word.idle .txt { font-family: system-ui, sans-serif; font-weight: 500; font-size: .9rem; letter-spacing: 0; color: var(--muted); }
.ws-word.live .txt { background: var(--panel-2); }
.ws-word.live.good .txt { background: #4fe39a26; color: var(--good); }
.ws-word.live.dup .txt { background: #ffa24d22; color: var(--dup); }
.ws-word.live.bad .txt { color: var(--bad); }
.ws-word.fb .txt { font-size: 1.3rem; }
.ws-word.fb.good .txt { background: var(--good); color: #062a17; animation: wpop .35s cubic-bezier(.3, 1.8, .5, 1); }
.ws-word.fb.dup .txt { background: var(--dup); color: #301500; animation: wobble2 .4s; }
.ws-word.fb.bad .txt { background: #ff6b6b30; color: var(--bad); animation: shakex .4s; }
@keyframes wpop { 0% { transform: scale(.7); } 100% { transform: none; } }
@keyframes shakex { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes wobble2 { 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }

/* board */
.ws-boardwrap { flex: 1 1 auto; min-height: 150px; display: grid; place-items: center; }
.ws-board { --bs: 300px; width: var(--bs); height: var(--bs); position: relative; display: grid;
  grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  gap: calc(var(--bs) * .022); padding: calc(var(--bs) * .03); border-radius: calc(var(--bs) * .06);
  background: radial-gradient(ellipse at 50% 30%, var(--tray), var(--tray-2)); border: 3px solid #072029;
  box-shadow: inset 0 0 30px #0009, 0 8px 22px #0007; touch-action: none; user-select: none; -webkit-user-select: none;
  -webkit-touch-callout: none; cursor: pointer; }
.ws-board .wt { position: relative; border-radius: 18%; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--cube), var(--cube-2)); box-shadow: 0 calc(var(--bs) * .012) 0 var(--cube-edge), 0 4px 10px #0006;
  transition: transform .12s cubic-bezier(.3, 1.6, .5, 1), background .12s, box-shadow .12s; }
.ws-board .wt .face { font-family: var(--fun); font-weight: 700; color: var(--ink); line-height: 1;
  font-size: calc(var(--bs) / var(--n) * .5); transform: rotate(var(--r, 0deg)); transition: transform .2s; }


/* selected tiles: gold while swiping, green when it's a real new word, orange if you already have it */
.ws-board .wt.sel { transform: scale(1.07); background: linear-gradient(150deg, #ffe08a, var(--sel)); box-shadow: 0 calc(var(--bs) * .012) 0 #b9801a, 0 0 18px #ffc14588; }
.ws-board .wt.sel .face { transform: none; }
.ws-board[data-st="good"] .wt.sel { background: linear-gradient(150deg, #a5f7cc, var(--good)); box-shadow: 0 calc(var(--bs) * .012) 0 #23985a, 0 0 20px #4fe39a99; }
.ws-board[data-st="dup"] .wt.sel { background: linear-gradient(150deg, #ffd0a3, var(--dup)); box-shadow: 0 calc(var(--bs) * .012) 0 #b8621b, 0 0 16px #ffa24d88; }
.ws-board[data-st="bad"] .wt.sel { background: linear-gradient(150deg, #ffc0c0, var(--bad)); box-shadow: 0 calc(var(--bs) * .012) 0 #b23b3b, 0 0 16px #ff6b6b88; }
.ws-board.result[data-st="good"] .wt.sel { animation: cheer .4s cubic-bezier(.3, 1.8, .5, 1); }
.ws-board.result[data-st="bad"] .wt.sel { animation: shakex .35s; }
@keyframes cheer { 40% { transform: scale(1.16) translateY(-4%); } 100% { transform: scale(1.07); } }

.ws-line { position: absolute; inset: calc(var(--bs) * .03); width: calc(100% - var(--bs) * .06); height: calc(100% - var(--bs) * .06);
  pointer-events: none; overflow: visible; }
.ws-line polyline { fill: none; stroke: #ffc145; stroke-opacity: .6; stroke-width: .16; stroke-linecap: round; stroke-linejoin: round; }
.ws-board[data-st="good"] .ws-line polyline { stroke: #4fe39a; }
.ws-board[data-st="dup"] .ws-line polyline { stroke: #ffa24d; }
.ws-board[data-st="bad"] .ws-line polyline { stroke: #ff6b6b; }

/* countdown: cubes rattle, then land in a wave */
.ws-board.shaking { animation: trayshake .35s linear infinite; cursor: default; }
.ws-board.shaking .wt { animation: rattle .22s linear infinite; animation-delay: calc(var(--d) * -1); }
.ws-board.shaking .wt .face { opacity: .55; filter: blur(.6px); }
@keyframes trayshake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.4deg) translateX(-3px); } 75% { transform: rotate(1.4deg) translateX(3px); } }
.ws-board.landing .wt { animation: drop .5s cubic-bezier(.3, 1.6, .5, 1) both; animation-delay: var(--d); }
@keyframes drop { 0% { transform: translateY(-30%) scale(1.25); opacity: 0; } 100% { transform: none; opacity: 1; } }
.ws-count { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 3; }
.ws-count b { font-family: var(--fun); font-weight: 700; font-size: calc(var(--bs) * .28); color: #fff;
  text-shadow: 0 4px 0 #0008, 0 0 30px #000; animation: cpop .9s ease-out both; }
.ws-count b.go { color: var(--good); animation: gopop .9s ease-out both; }
@keyframes cpop { 0% { transform: scale(2.2); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }
@keyframes gopop { 0% { transform: scale(.4); opacity: 0; } 25% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
.ws-board.locked { filter: saturate(.4) brightness(.8); cursor: default; transition: filter .4s; }

.ws-float { position: absolute; transform: translate(-50%, -50%); z-index: 4; pointer-events: none; font-family: var(--fun);
  font-weight: 700; font-size: calc(var(--bs) * .09); color: var(--good); text-shadow: 0 2px 0 #062a17, 0 0 12px #000;
  animation: floatup .9s ease-out forwards; }
@keyframes floatup { 0% { transform: translate(-50%, -20%) scale(.6); opacity: 0; } 20% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -190%) scale(1); opacity: 0; } }

/* found words */
.ws-found { flex: 0 0 clamp(72px, 19dvh, 170px); min-height: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .4rem .5rem; display: flex; flex-direction: column; }
.ws-found .head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); padding: 0 .1rem .3rem; flex: none; }
.ws-found .head b { color: var(--text); font-family: var(--fun); font-weight: 600; font-size: .95rem; }
.ws-found .chips { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .3rem; }
.wchip { display: inline-flex; align-items: baseline; gap: .15em; padding: .18em .55em; border-radius: 99px; font-family: var(--fun);
  font-weight: 600; font-size: .85rem; letter-spacing: .04em; background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  position: relative; line-height: 1.3; }
.wchip sup { font-size: .65em; color: var(--muted); font-weight: 600; letter-spacing: 0; }
.wchip.long { border-color: #4fe39a88; }
.wchip.long sup { color: var(--good); }
.wchip.pop { animation: chipin .4s cubic-bezier(.3, 1.8, .5, 1); background: #4fe39a33; border-color: var(--good); }
.wchip.again { animation: again .6s; }
@keyframes chipin { 0% { transform: scale(.3); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes again { 0%, 100% { background: var(--panel-2); } 20%, 60% { background: var(--dup); color: #301500; transform: scale(1.12); } }

/* ---------- results ---------- */
.ws-res .statusbar { padding-top: .2rem; }
.ws-res-scroll { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: .5rem; padding-bottom: .3rem; }
.ws-mini-wrap { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: .8rem; justify-content: center;
  padding: .3rem 0 .45rem; background: linear-gradient(180deg, var(--bg) 85%, transparent); }
.ws-board.mini { --bs: clamp(118px, 24dvh, 190px); cursor: default; touch-action: auto; border-width: 2px; }
.ws-board.mini .wt .face { transform: none; }
.ws-board.mini .wt.sel { animation: minisel .3s both; animation-delay: var(--d); transform: none; }
@keyframes minisel { 0% { background: linear-gradient(150deg, var(--cube), var(--cube-2)); box-shadow: none; } }
.ws-board.mini .ws-line polyline { stroke: #ffc145; stroke-opacity: .75; stroke-width: .18; stroke-dasharray: 1; stroke-dashoffset: 0; }
.ws-board.mini.draw .ws-line polyline { animation: drawline .6s ease-out both; }
@keyframes drawline { from { stroke-dashoffset: 1; } }
.ws-mini-word { font-size: .85rem; min-width: 6.5em; text-align: center; }
.ws-mini-word b { display: block; font-family: var(--fun); font-size: 1.25rem; color: var(--accent); letter-spacing: .06em; word-break: break-all; }

.ws-pc { background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--radius); padding: .5rem .6rem .6rem; }
.ws-pc.me { border-color: #ffc14588; }
.ws-pc.win { border-color: var(--accent); }
.ws-res.shown .ws-pc.win { box-shadow: 0 0 0 1px var(--accent), 0 0 22px #ffc14555; }
.ws-res.anim .ws-pc { animation: cardin .45s cubic-bezier(.2, 1.3, .5, 1) both; animation-delay: calc(var(--k, 0) * 110ms); }
@keyframes cardin { from { transform: translateY(24px); opacity: 0; } }
.pc-head { display: flex; align-items: baseline; gap: .45rem; margin-bottom: .35rem; }
.pc-head .rank { font-size: 1.1rem; min-width: 1.3em; text-align: center; font-family: var(--fun); }
.pc-head .pn { font-family: var(--fun); font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-head .rs { font-family: var(--fun); font-weight: 700; font-size: 1.45rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.pc-head .rs::after { content: " pts"; font-size: .55em; color: var(--muted); font-weight: 500; }
.pc-head .tot { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.pc-head .tot b { color: var(--text); font-variant-numeric: tabular-nums; }
.ws-pc .chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.ws-pc .wchip { cursor: pointer; }
.ws-pc .wchip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.ws-pc .wchip.on sup { color: var(--accent-ink); }
.ws-pc .wchip.best { border-color: var(--accent); }
.ws-pc .wchip.both sup::after { content: " 👥"; }
.ws-res.anim .ws-pc .wchip { animation: chipin .3s both; animation-delay: calc(var(--k, 0) * 110ms + 200ms + min(var(--j, 0), 30) * 18ms); }
/* crossed-out shared words */
.ws-pc .wchip.shared::after { content: ""; position: absolute; left: 6%; right: 6%; top: 52%; height: 2px; background: var(--bad);
  border-radius: 2px; transform-origin: left; transform: scaleX(1); }
.ws-pc .wchip.shared { opacity: .5; }
.ws-pc .wchip.shared sup { text-decoration: line-through; }
.ws-res.anim .ws-pc .wchip.shared:not(.cut) { opacity: 1; }
.ws-res.anim .ws-pc .wchip.shared:not(.cut)::after { transform: scaleX(0); }
.ws-res.anim .ws-pc .wchip.shared.cut { transition: opacity .4s .2s; }
.ws-res.anim .ws-pc .wchip.shared.cut::after { transition: transform .25s ease-out; }
.ws-pc.missed { border-style: dashed; background: transparent; }
.ws-pc.missed .wchip { background: transparent; border-style: dashed; color: var(--muted); }
.ws-pc.missed .wchip.on { color: var(--accent-ink); border-style: solid; }
.ws-pc .allcount { width: 100%; margin-top: .2rem; }
.ws-res .endbar { flex: none; }
.ws-res .endbar button { margin-top: .1rem; }

@media (min-width: 700px) {
  .ws-word .txt { font-size: 1.8rem; }
  .wchip { font-size: .92rem; }
}

/* countdown scrim + fixes */
.ws-count.on { background: #0b1a22b8; border-radius: inherit; }
.ws-count.on b { animation: cpop2 1s ease-out both; }
.ws-count b.word { font-size: calc(var(--bs) * .17); color: var(--accent); transform: rotate(-6deg); }
@keyframes cpop2 { 0% { transform: scale(2.4); opacity: 0; } 18% { transform: scale(1); opacity: 1; } 85% { opacity: 1; } 100% { transform: scale(.85); opacity: .2; } }
.ws-line polyline { stroke: #b9801a; stroke-opacity: .55; stroke-width: .2; }
.ws-board[data-st="good"] .ws-line polyline { stroke: #17904f; }
.ws-board[data-st="dup"] .ws-line polyline { stroke: #b8621b; }
.ws-board[data-st="bad"] .ws-line polyline { stroke: #b23b3b; }
.ws-pc.missed .wchip.on { background: var(--accent); color: var(--accent-ink); }
.ws-res .headline { display: inline-block; }
.ws-res .headline.pop { animation: wpop .45s cubic-bezier(.3, 1.8, .5, 1); color: var(--accent); }

/* ---------- Battle Royale + Last Word Standing ---------- */
.wp { border-left: 4px solid var(--pc, var(--line)); }
.wp.turn { border-color: var(--pc); box-shadow: 0 0 0 1px var(--pc), 0 0 14px color-mix(in srgb, var(--pc) 45%, transparent); }
.wp.turn .nm::before { content: "▶ "; color: var(--pc); }
.wp.out { opacity: .45; }
.wp.out .nm { text-decoration: line-through; }

/* the shared word feed: every chip wears its owner's colour */
.wchip i { font-style: normal; font-size: .68em; font-weight: 700; display: inline-grid; place-items: center; width: 1.35em; height: 1.35em;
  border-radius: 50%; background: var(--pc); color: #1a1326; margin-right: .2em; letter-spacing: 0; align-self: center; }
.wchip.mine { border-color: var(--pc); }
.wchip.theirs { opacity: .78; }
.wchip.theirs-pop { animation: chipin .4s cubic-bezier(.3, 1.8, .5, 1); background: color-mix(in srgb, var(--pc) 25%, var(--panel-2)); border-color: var(--pc); opacity: 1; }

/* a word that someone else already has */
.ws { --taken: #b28bff; }
.ws-word.live.taken .txt { background: #b28bff22; color: var(--taken); text-decoration: line-through; }
.ws-word.fb.taken .txt { background: var(--taken); color: #1a1030; animation: shakex .4s; }
.ws-word.fb.other .txt { background: color-mix(in srgb, var(--pc) 22%, transparent); color: var(--pc); font-size: 1.15rem; animation: wpop .35s cubic-bezier(.3, 1.8, .5, 1); }
.ws-board[data-st="taken"] .wt.sel { background: linear-gradient(150deg, #dccbff, var(--taken)); box-shadow: 0 calc(var(--bs) * .012) 0 #6c4bb5, 0 0 16px #b28bff88; }
.ws-board[data-st="taken"] .ws-line polyline { stroke: #6c4bb5; }

/* an opponent just grabbed these tiles */
.ws-board .wt.snipe { animation: snipe .9s ease-out; }
@keyframes snipe { 0%, 40% { box-shadow: 0 0 0 3px var(--pc), 0 0 18px var(--pc); transform: scale(1.06); } 100% { box-shadow: 0 calc(var(--bs) * .012) 0 var(--cube-edge), 0 4px 10px #0006; } }

/* not your turn: board stays readable so you can plan ahead */
.ws-board.waiting { filter: saturate(.55) brightness(.82); cursor: default; transition: filter .3s; }
.ws-found .head { align-items: center; gap: .5rem; }
.ws-found .head .pts { margin-left: auto; }
.ws-found .giveup { padding: .2rem .6rem; font-size: .8rem; }

.pc-head .rs.words::after { content: " words"; }
.ws-turns .ws-pc { border-left: 4px solid var(--pc, var(--line)); }
