/* Tile Trios. The board height is reserved before the script runs. */
.tr-wrap { display: block; min-height: max(280px, min(100vh - 306px, 105vw, var(--tr-most, 690px))); overflow: visible; overflow-x: clip; }
[data-size="small"] .tr-wrap { --tr-most: 570px; }
[data-size="large"] .tr-wrap { --tr-most: 800px; }
.game:not(.is-ready) .tr-table { display: none; }
.tr-table { --tr-depth: 4px; margin: 0 auto; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tr-board { position: relative; z-index: 2; margin: 0 auto; }
.tr-rack {
  position: relative; z-index: 1; display: flex; justify-content: center; gap: 3px; width: max-content; margin: 10px auto 0; padding: 6px;
  border-radius: 12px; background: linear-gradient(180deg, #7a5230, #4d3119); border: 1px solid #a87b45;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35);
}
.tr-slot { flex: none; width: var(--tr-slot); height: calc(var(--tr-slot) * 4 / 3); border-radius: 6px; background: rgba(0, 0, 0, .34); box-shadow: inset 0 2px 5px rgba(0, 0, 0, .5); }
.tr-rack.is-tight { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 4px 10px rgba(0, 0, 0, .35); }
.tr-rack.is-last { border-color: #ff9d8a; box-shadow: 0 0 0 3px #ff9d8a, 0 4px 10px rgba(0, 0, 0, .35); }
.tr-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #f9e8c9; font-size: .88rem; font-weight: 600; text-shadow: 0 1px 2px #000; opacity: 0; }
.tr-rack.is-empty .tr-note { opacity: 1; }
.tr-tile {
  position: absolute; left: 0; top: 0; width: var(--tr-cell); height: var(--tr-high); padding: 0; border: 0; cursor: pointer;
  border-radius: calc(var(--tr-depth) * 1.4); transform-origin: 0 0;
  background: linear-gradient(150deg, var(--ivory) 0%, #fbf5e3 55%, var(--ivory-2) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(125, 98, 51, .4),
    calc(var(--tr-depth) * .5) calc(var(--tr-depth) * .5) 0 0 var(--tile-side),
    var(--tr-depth) var(--tr-depth) 0 0 var(--tile-side),
    calc(var(--tr-depth) + 1px) calc(var(--tr-depth) + 1px) 3px 0 rgba(0, 0, 0, .5);
  transition: transform .2s ease-out; -webkit-tap-highlight-color: transparent;
}
.tr-tile img { display: block; width: 100%; height: 100%; padding: 5%; pointer-events: none; }
.tr-tile::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: rgba(10, 46, 34, .46); opacity: 0; transition: opacity .2s; pointer-events: none; }
.tr-tile.is-covered { cursor: default; }
.tr-tile.is-covered::after { opacity: 1; }
.tr-tile:not(.is-covered):hover { filter: brightness(1.06); }
.tr-tile:focus-visible { outline-offset: -3px; }
.tr-tile.is-hint { background: linear-gradient(150deg, #f1fffa, #b9f2dc); animation: hint-pulse .9s ease-in-out 3; }
.tr-tile.is-hint::after { opacity: 1; background: none; box-shadow: inset 0 0 0 3px #087f5b; }
.tr-tile.in-rack { pointer-events: none; }
.tr-tile.is-pair::after { opacity: 1; background: none; box-shadow: inset 0 0 0 3px var(--gold); }
.tr-tile.is-denied { animation: shake .25s ease; }
.tr-tile.is-new { animation: tr-in .2s ease-out; }
.tr-tile.is-leaving { animation: tr-out .22s ease-in forwards; }
.tr-table.is-turning .tr-tile img { animation: tr-in .25s ease-out; }
.tr-table.is-still .tr-tile { transition: none; }
.tr-count { min-width: 1.5em; border-radius: 999px; background: rgba(0, 0, 0, .35); font-size: .78em; line-height: 1.5; text-align: center; }
/* Full screen on a phone held sideways: the rack stands beside the board. */
.is-side .tr-wrap { min-height: 0; padding: 0; }
.is-side .game-bar { flex-wrap: nowrap; margin-bottom: 6px; padding: 2px 8px; }
.is-side .game-bar > div { width: auto; }
.is-side .tr-table { display: flex; justify-content: center; align-items: center; }
.is-side .tr-board { margin: 0; }
.is-side .tr-note { text-align: center; }
.is-side .tr-rack { flex-wrap: wrap; align-content: flex-start; width: calc(2 * var(--tr-slot) + 17px); margin: 0 0 0 12px; }
@keyframes tr-in { from { opacity: 0; } }
@keyframes tr-out { to { opacity: 0; translate: 0 -16px; } }
@media (max-width: 760px) {
  .tr-wrap { padding: 0; }
  .game-actions.tr-actions { grid-template-columns: 1fr 1.15fr 1fr 1fr 1.45fr; }
}
@media (max-width: 420px) {
  .tr-actions .btn { font-size: .8rem; gap: 3px; }
  .tr-wrap ~ .game-status { min-height: 3.2em; }
}
@media (prefers-reduced-motion: reduce) {
  .tr-tile, .tr-tile::after { transition: none; }
  .tr-tile.is-hint, .tr-tile.is-denied, .tr-tile.is-new, .tr-tile.is-leaving, .tr-table.is-turning .tr-tile img { animation: none; }
}
