/* ---------- Word Tiles ---------- */
.wboard {
  --wc: clamp(26px, min((100cqi - 80px) / 11, (100vh - 290px) / 11), 56px); --wg: 3px;
  position: relative; padding: 12px 14px 14px 10px; border-radius: 28px;
  background: linear-gradient(160deg, #fdf7f1, #f2e6ee);
  box-shadow: 0 14px 0 -2px #e3cfdc, 0 30px 50px -24px rgba(73, 52, 110, 0.55);
  transform: rotateX(8deg); transform-origin: 50% 100%;
}
.w-grid { display: grid; grid-template-columns: 20px auto; grid-template-rows: 20px auto; gap: 4px; }
.w-cols { grid-column: 2; display: grid; grid-template-columns: repeat(11, var(--wc)); gap: var(--wg); text-align: center; color: var(--ink-soft); font-size: 13px; align-items: end; }
.w-rows { grid-row: 2; display: grid; grid-template-rows: repeat(11, var(--wc)); gap: var(--wg); align-items: center; text-align: center; color: var(--ink-soft); font-size: 13px; }
.w-squares { grid-column: 2; grid-row: 2; display: grid; grid-template-columns: repeat(11, var(--wc)); grid-template-rows: repeat(11, var(--wc)); gap: var(--wg); }
.wsq {
  position: relative; border: 0; padding: 0; border-radius: 9px; background: #f3e7dc; cursor: default;
  box-shadow: inset 0 -2px 0 rgba(120, 90, 70, 0.08); display: grid; place-items: center; overflow: visible;
}
.wsq.b-l2 { background: #d8ecfb; }
.wsq.b-l3 { background: #a9d2f3; }
.wsq.b-w2 { background: #ffd9cd; }
.wsq.b-w3 { background: #ffb09e; }
.wsq.b-star { background: #d9c9f5; }
.blabel { display: flex; flex-direction: column; align-items: center; line-height: 1; color: rgba(61, 53, 83, 0.7); pointer-events: none; }
.blabel b { font-size: calc(var(--wc) * 0.32); font-weight: 600; }
.blabel small { font-size: calc(var(--wc) * 0.2); margin-top: 1px; }
.b-star .blabel b { font-size: calc(var(--wc) * 0.5); color: #8a6fd1; }
.wboard.armed .wsq:not(.has) { cursor: pointer; }
.wboard.armed .wsq:not(.has):hover { filter: brightness(1.05); box-shadow: inset 0 0 0 3px rgba(185, 164, 240, 0.8); }
.wsq:focus-visible { outline: 3px solid var(--coral); outline-offset: 1px; z-index: 3; }
.wsq.has .blabel { visibility: hidden; }

.tile {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 22%;
  background: linear-gradient(180deg, #fff7df, #f4e0aa); color: var(--ink);
  box-shadow: 0 3px 0 #d6b874, 0 6px 10px -6px rgba(120, 90, 40, 0.5);
  font-weight: 600; z-index: 2;
}
.tile b { font-size: calc(var(--t, var(--wc)) * 0.56); line-height: 1; }
.tile i { position: absolute; right: 10%; bottom: 6%; font-style: normal; font-size: calc(var(--t, var(--wc)) * 0.24); font-weight: 500; color: #8c7a5a; }
.tile.star b { color: #8a6fd1; }
.tile.recent { box-shadow: 0 3px 0 #d6b874, 0 0 0 3px rgba(255, 190, 90, 0.85), 0 6px 12px -4px rgba(255, 170, 60, 0.6); }
.tile.tentative { background: linear-gradient(180deg, #fffdf6, #ffe9b8); box-shadow: 0 3px 0 #e6a07c, 0 0 0 3px rgba(255, 143, 122, 0.8); cursor: pointer; }
.wsq.tent { cursor: pointer; }
.tile.drop { animation: clackIn 0.42s var(--ease-spring) both; }
@keyframes clackIn { 0% { transform: translateY(-40%) scale(1.3); opacity: 0; } 60% { transform: translateY(2%) scale(0.97); opacity: 1; } 100% { transform: none; } }

.rack-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.rack { --rt: 42px; --t: var(--rt); display: flex; gap: 5px; justify-content: center; min-height: calc(var(--rt) + 8px); padding-top: 4px; }
.rtile, .rslot { position: relative; width: var(--rt); height: var(--rt); flex: none; border: 0; padding: 0; background: none; border-radius: 22%; }
.rslot { background: rgba(61, 53, 83, 0.06); }
.rtile { cursor: pointer; transition: transform 0.22s var(--ease-spring); }
.rtile.sel { transform: translateY(-8px) scale(1.06); }
.rtile.sel .tile { box-shadow: 0 3px 0 #d6b874, 0 0 0 3px var(--coral); }
.rtile.swap-sel .tile { background: linear-gradient(180deg, #e9e1fb, #cbbaf7); box-shadow: 0 3px 0 #9f86ea; }
.rack.shuffled .rtile { animation: wiggle 0.4s ease; }
@keyframes wiggle { 0%, 100% { transform: none; } 30% { transform: translateY(-6px) rotate(-6deg); } 60% { transform: translateY(-3px) rotate(5deg); } }
.preview { min-height: 24px; text-align: center; font-size: 17px; color: var(--ink-soft); line-height: 1.3; }
.preview.good { color: #2f7a57; }
.preview.good b { color: var(--ink); }
.preview.warn { color: #b0563f; }
.w-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.w-actions[hidden], .swap-bar[hidden] { display: none; }
.w-actions [data-a="play"] { grid-column: 1 / -1; min-height: 56px; }
.w-actions .btn.small { padding: 0 6px; font-size: 16px; min-height: 46px; }
.swap-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; font-size: 16px; color: var(--ink-soft); }
.swap-bar span { flex: 1 1 100%; text-align: center; }
.score-card { padding: 14px 18px; display: flex; flex-direction: column; gap: 8px; }
.scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sc { background: #f6f0f6; border-radius: 16px; padding: 8px 12px; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.sc span { font-size: 15px; color: var(--ink-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc b { font-size: 28px; font-weight: 600; line-height: 1.1; }
.sc.me { background: #fff1d6; }
.bag { font-size: 15px; color: var(--ink-soft); text-align: center; }
.plays-title { font-weight: 600; font-size: 17px; }
.plays { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; font-size: 16px; }
.plays .who { color: var(--ink-soft); display: inline-block; min-width: 4.5em; }
.plays .pts { color: #2f7a57; font-weight: 500; }
.plays .none { color: #b0a7bf; }
.legend { display: none; flex-wrap: wrap; gap: 6px; }
.lg { font-size: 13px; padding: 3px 9px; border-radius: 999px; color: var(--ink); }
.lg.b-l2 { background: #d8ecfb; }
.lg.b-l3 { background: #a9d2f3; }
.lg.b-w2 { background: #ffd9cd; }
.lg.b-w3 { background: #ffb09e; }
.score-card .link-btn { align-self: flex-start; margin-top: 2px; }
.letter-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 8px; }
.lp { min-height: 44px; border: 0; border-radius: 12px; background: linear-gradient(180deg, #fff7df, #f4e0aa); box-shadow: 0 2px 0 #d6b874; font-size: 20px; font-weight: 600; cursor: pointer; }
.idea-row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 14px; }
.idea { padding: 6px 14px; border-radius: 999px; background: #fff1d6; font-weight: 600; font-size: 19px; letter-spacing: 1px; }
/* desktop: the side column holds the rack, so keep the friend card compact */
.game-words .side { gap: 14px; }
.game-words .friend { padding: 12px 16px; }
.game-words .friend .avatar { width: 72px; height: 72px; }

@media (max-width: 1099px) {
  .wboard { --wc: clamp(24px, (100cqi - 66px) / 11, 58px); transform: none; }
  .rack { --rt: clamp(38px, (100cqi - 100px) / 7, 62px); }
  .w-actions { grid-template-columns: repeat(5, 1fr); }
  .game-words .side-main { display: flex; flex-direction: column; gap: 14px; }
  .game-words .friend .avatar { width: 64px; height: 64px; }
}
@media (max-width: 620px) {
  .wboard { --wc: clamp(22px, (100cqi - 46px) / 11, 40px); --wg: 2px; padding: 8px 8px 8px 5px; border-radius: 18px;
    box-shadow: 0 8px 0 -2px #e3cfdc, 0 20px 34px -22px rgba(73, 52, 110, 0.5); }
  .w-grid { grid-template-columns: 13px auto; grid-template-rows: 14px auto; gap: 2px; }
  .w-cols, .w-rows { font-size: 10px; }
  .wsq { border-radius: 5px; }
  .blabel small { display: none; }
  .legend { display: flex; }
  .blabel b { font-size: calc(var(--wc) * 0.4); }
  .rack { --rt: clamp(36px, (100cqi - 70px) / 7, 50px); gap: 4px; }
  .w-actions { grid-template-columns: repeat(3, 1fr); }
  .letter-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .tile.drop, .rack.shuffled .rtile { animation: none !important; }
}

/* desktop: if the side column is taller than the screen, let it scroll by itself */
@media (min-width: 1100px) {
  .game-words .side { overflow-y: auto; margin: 0 -12px; padding: 0 12px 12px; scrollbar-width: thin; }
  .game-words .plays li:nth-child(n + 4) { display: none; }
}
.w-actions .short { display: none; }
@media (min-width: 1100px) {
  .game-words .w-actions { grid-template-columns: repeat(5, 1fr); gap: 6px; }
  .game-words .w-actions .btn.small { font-size: 15px; padding: 0 2px; }
  .game-words .w-actions .long { display: none; }
  .game-words .w-actions .short { display: inline; }
  .game-words .rack-card { gap: 8px; padding: 14px; }
}
@media (min-width: 1100px) {
  .game-words .w-actions .btn.small { white-space: nowrap; gap: 4px; }
}
