/* Anagram Rush: a soft lilac page and six big cream letter tiles on a plum tray. Depth comes only from a
   solid side face attached under each tile (never a soft shadow), the same toy rule as Word Swipe.
   A tile you've used drops into the answer row above; the empty spot it left stays as a dimple. */
.ar-page {
  --tile: #fff8ea; --tile-side: #dfc7a1; --tile-ink: #2a1d17;
  --good: #3fbf6a; --good-side: #23854a; --dup: #f2d36b; --gold: #ffcf4a; --gold-side: #c49312;
  --tray: #4b2c7a; --tray-2: #61399c; --tray-e: #2f1a52; --plum: #7a4cd8; --plum-d: #5530a8; --coral: #ef5b3f;
}
.ar-page .cbx-title em { font-style: normal; color: var(--plum); }

.ar-tabs { display: flex; gap: 5px; margin: 0 0 12px; padding: 4px; border-radius: 15px; background: #ece2f7; box-shadow: inset 0 2px 0 rgba(0, 0, 0, .05); }
.ar-tabs button { flex: 1; border: 0; background: transparent; padding: 10px 8px; border-radius: 11px; font: 900 15px var(--cbx-body); color: var(--cbx-ink-2); cursor: pointer; }
.ar-tabs button[aria-selected="true"] { color: #fff; background: var(--plum); box-shadow: 0 3px 0 var(--plum-d); }

.ar-card { padding: 14px; }
.ar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ar-pill { padding: 6px 11px; border-radius: 99px; background: var(--cbx-soft); font: 900 14px var(--cbx-body); color: var(--cbx-ink-2); white-space: nowrap; }
.ar-pill.clock { background: var(--tray); color: #fff; font-variant-numeric: tabular-nums; min-width: 58px; text-align: center; }
.ar-pill.clock.low { background: var(--coral); animation: ar-tick 1s steps(2) infinite; }
@keyframes ar-tick { 50% { transform: scale(1.06); } }
.ar-score { text-align: center; line-height: 1; }
.ar-score b { font: 900 26px var(--cbx-body); font-variant-numeric: tabular-nums; color: var(--cbx-ink); }
.ar-score small { font: 800 13px var(--cbx-body); color: var(--cbx-muted); }
.ar-score.pop b { animation: ar-pop .35s ease-out; }
@keyframes ar-pop { 40% { transform: scale(1.18); color: var(--good-side); } }
.ar-timer { height: 7px; border-radius: 99px; background: var(--cbx-soft); margin: 10px 0 8px; overflow: hidden; }
.ar-timer i { display: block; height: 100%; width: 100%; background: var(--tray-2); border-radius: inherit; transform-origin: left; transition: transform .25s linear; }
.ar-timer.low i { background: var(--coral); }
.ar-banner { margin: 0 0 8px; padding: 10px 12px; border-radius: 12px; background: #f1ebfb; color: #35205a; font: 800 14px/1.4 var(--cbx-body); }

/* the tray: answer row, the rack, the three keys */
.ar-play { position: relative; width: min(100%, 440px); margin: 0 auto; padding: 14px 12px 14px; border-radius: 24px;
  background: linear-gradient(180deg, var(--tray-2), var(--tray)); box-shadow: 0 6px 0 var(--tray-e);
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.ar-flash { min-height: 26px; margin: -2px 0 6px; text-align: center; font: 900 16px/26px var(--cbx-body); color: #e9ddff; letter-spacing: .02em; }
.ar-flash .pts { display: inline-block; margin-left: 6px; padding: 0 8px; border-radius: 99px; background: var(--good); color: #fff; font-size: 14px; }
.ar-flash.good { color: #b6f5c9; } .ar-flash.dup { color: var(--dup); } .ar-flash.bad { color: #ffb4a6; animation: ar-shake .3s; }
.ar-flash.six { color: var(--gold); }
@keyframes ar-shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.ar-slots, .ar-rack { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.ar-slots { margin-bottom: 14px; }
.ar-slot { aspect-ratio: 1 / 1.05; border-radius: 13px; background: rgba(255, 255, 255, .12); box-shadow: inset 0 3px 0 rgba(0, 0, 0, .18); border: 0; padding: 0; }
.ar-slot.fill { background: var(--tile); color: var(--tile-ink); box-shadow: 0 5px 0 var(--tile-side); font: 900 clamp(22px, 7vw, 32px)/1 var(--cbx-body); cursor: pointer; }
.ar-slots.good .ar-slot.fill { background: var(--good); color: #fff; box-shadow: 0 5px 0 var(--good-side); }
.ar-slots.dup .ar-slot.fill { background: var(--dup); box-shadow: 0 5px 0 var(--gold-side); }
.ar-slots.bad { animation: ar-shake .3s; }
.ar-tile { position: relative; aspect-ratio: 1 / 1.08; border: 0; padding: 0; border-radius: 15px; cursor: pointer;
  background: var(--tile); color: var(--tile-ink); box-shadow: 0 7px 0 var(--tile-side);
  font: 900 clamp(28px, 9.5vw, 42px)/1 var(--cbx-body); transition: transform .1s, opacity .12s; }
.ar-tile:active { transform: translateY(3px); box-shadow: 0 4px 0 var(--tile-side); }
.ar-tile.used { background: rgba(255, 255, 255, .1); box-shadow: inset 0 4px 0 rgba(0, 0, 0, .2); color: transparent; cursor: default; }
.ar-tile.hidden { color: transparent; background: #e6dcf0; }
.ar-tile:focus-visible, .ar-key:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ar-rack.spin .ar-tile:not(.used) { animation: ar-spin .28s ease-out; }
@keyframes ar-spin { 40% { transform: translateY(-6px) rotate(-6deg); } }

.ar-keys { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 8px; margin-top: 16px; }
.ar-key { min-height: 52px; border: 0; border-radius: 14px; background: #fff; color: var(--tray); box-shadow: 0 5px 0 #c9b4e8;
  font: 900 15px var(--cbx-body); cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.ar-key i { font-style: normal; font-size: 19px; }
.ar-key.go { background: var(--good); color: #fff; box-shadow: 0 5px 0 var(--good-side); }
.ar-key:active { transform: translateY(3px); box-shadow: 0 2px 0 #c9b4e8; }
.ar-key.go:active { box-shadow: 0 2px 0 var(--good-side); }

.ar-start { position: absolute; inset: 0; z-index: 3; display: grid; place-content: center; gap: 12px; text-align: center; border-radius: inherit;
  background: rgba(40, 22, 70, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.ar-start p { margin: 0; color: #fff; font: 900 18px var(--cbx-body); text-shadow: 0 2px 0 rgba(0, 0, 0, .25); padding: 0 16px; }
.ar-start .cbx-btn { justify-self: center; min-width: 160px; }
.ar-play.done .ar-tile, .ar-play.done .ar-key { cursor: default; opacity: .7; }

/* words found, grouped by length */
.ar-found { margin: 14px 0 2px; display: grid; gap: 6px; }
.ar-found .row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: center; }
.ar-found .n { font: 900 12px var(--cbx-body); color: var(--cbx-muted); min-width: 22px; }
.ar-found span { padding: 4px 9px; border-radius: 9px; background: var(--cbx-soft); font: 900 13px var(--cbx-body); letter-spacing: .04em; text-transform: uppercase; color: var(--cbx-ink-2); }
.ar-found span.n { padding: 0 2px 0 0; background: none; letter-spacing: 0; color: var(--cbx-muted); }
.ar-found span.six { background: #fff1c4; color: #6b4d00; }
.ar-found span.new { background: var(--good); color: #fff; }

/* results */
.ar-result { margin-top: 14px; padding-top: 14px; border-top: 2px dashed var(--cbx-line); }
.ar-compare { font: 900 17px var(--cbx-body); margin: 6px 0; }
.ar-duel { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; text-align: left; }
.ar-duel:empty { display: none; }
.ar-duel .side { padding: 10px 12px; border-radius: 14px; background: var(--cbx-soft); }
.ar-duel .side.win { background: #e3f6ea; box-shadow: inset 0 0 0 2px var(--good); }
.ar-duel .nm { font: 900 14px var(--cbx-body); color: var(--cbx-ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ar-duel .pts { font: 900 28px var(--cbx-body); font-variant-numeric: tabular-nums; }
.ar-duel .ws { font: 800 12px/1.5 var(--cbx-body); color: var(--cbx-muted); text-transform: uppercase; word-break: break-word; }
.ar-duel .ws b { color: var(--good-side); }
.ar-missed { margin: 8px 0 12px; font: 800 14px/1.5 var(--cbx-body); color: var(--cbx-muted); }
.ar-missed:empty { display: none; }
.ar-missed b { color: var(--cbx-ink-2); letter-spacing: .04em; }
.ar-missed .six { color: #8a6200; }
.ar-link { margin: 10px auto 0; display: block; border: 0; background: none; font: 900 14px var(--cbx-body); color: var(--plum-d); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.ar-dlg { border: 0; padding: 0; border-radius: 22px; width: min(420px, calc(100vw - 32px)); color: var(--cbx-ink); background: #fff; box-shadow: 0 8px 0 #d6c6ec; }
.ar-dlg::backdrop { background: rgba(32, 16, 56, .5); }
.ar-dlg-card { padding: 22px; }
.ar-dlg h2 { margin: 0 0 8px; font: 900 22px var(--cbx-display); }
.ar-dlg p { margin: 0 0 14px; font: 800 15px/1.45 var(--cbx-body); color: var(--cbx-ink-2); }
.ar-field { display: grid; gap: 5px; margin: 0 0 12px; font: 900 13px var(--cbx-body); color: var(--cbx-muted); }
.ar-field input { min-height: 46px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--cbx-line); font: 800 16px var(--cbx-body); color: var(--cbx-ink); }
.ar-dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; flex-wrap: wrap; }

@media (max-width: 420px) {
  .ar-card { padding: 10px; }
  .ar-play { padding: 12px 9px; } .ar-slots, .ar-rack { gap: 6px; }
  .ar-score b { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { .ar-pill.clock.low, .ar-flash.bad, .ar-slots.bad, .ar-score.pop b, .ar-rack.spin .ar-tile { animation: none; } }
