/* --tn-w: tile width, estimated here, then set by the script */
.tn-game { --tn-c: 7.07; --tn-r: 6.8; --tn-w: min(84px, (100vw - 32px) / var(--tn-c), max(42px, (100vh - 325px) / (var(--tn-r) + 1.34))); }
.tn-game[data-layout=diamond] { --tn-c: 6.07; --tn-r: 8.07; }
.tn-game[data-layout=terrace] { --tn-c: 5.87; --tn-r: 8.86; }
.tn-stats :first-child b { display: inline-block; min-width: 2ch; }
.tn-wrap { min-height: calc(var(--tn-w) * var(--tn-r) + 8px); padding: 4px 0; overflow: visible; }
.tn-board { position: relative; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.tn-tile, .tn-slot { --tn-d: calc(var(--tn-w) * .07); width: var(--tn-w); height: calc(var(--tn-w) * 4 / 3); padding: 0; cursor: pointer; }
.tn-tile {
  position: absolute; margin: 0; border: 0; border-radius: calc(var(--tn-w) * .1); transition: transform .12s, filter .15s;
  background: linear-gradient(150deg, var(--ivory), #fbf5e3 55%, var(--ivory-2)); -webkit-tap-highlight-color: transparent;
  box-shadow: inset 0 0 0 1px #7d623373, calc(var(--tn-d) / 2) calc(var(--tn-d) / 2) var(--tile-side),
    var(--tn-d) var(--tn-d) var(--tile-side), calc(var(--tn-d) + 1px) calc(var(--tn-d) + 2px) 4px #0008;
}
.tn-tile img { display: block; width: 100%; height: 100%; padding: 7% 5% 3%; pointer-events: none; }
.tn-tile:hover { filter: brightness(1.06); }
.tn-tile.is-covered { cursor: default; filter: brightness(.76) saturate(.9); }
.tn-num {
  position: absolute; left: 2px; top: 2px; min-width: 1.35em; border-radius: .35em; text-align: center; box-shadow: 0 0 0 1px var(--ivory);
  background: var(--jade-700); color: #fff; font: 700 max(11px, var(--tn-w) / 4)/1.3 system-ui, sans-serif; pointer-events: none;
}
.tn-tr .tn-num { left: auto; right: 2px; }
.tn-bl .tn-num { top: auto; bottom: 2px; }
.tn-tile.is-selected, .is-selected > .tn-tile { background: var(--gold-soft); box-shadow: inset 0 0 0 3px var(--gold), var(--tn-d) var(--tn-d) #c99a2b; }
.tn-tile.is-selected { transform: translateY(-4px); }
.is-selected .tn-num { background: #2b2205; }
.tn-tile.is-hint, .is-hint > .tn-tile { box-shadow: inset 0 0 0 3px var(--focus), 0 0 0 3px #7fffd4, var(--tn-d) var(--tn-d) 0 2px var(--tile-side); }
.is-denied { animation: tn-no .24s; }
.tn-tile.is-gone { animation: tn-gone .22s ease-in forwards; }
@keyframes tn-no { 25% { translate: -4px 0; } 75% { translate: 4px 0; } }
@keyframes tn-gone { to { opacity: 0; transform: scale(.6) translateY(-14px); } }
@keyframes tn-in { from { opacity: 0; transform: translateY(-12px); } }

.tn-tray, .tn-keep, .tn-sums { display: flex; align-items: center; justify-content: center; gap: 12px; }
.tn-tray { margin-top: 8px; }
.tn-slot { position: relative; flex: none; border: 2px dashed #a9c9b9; border-radius: 8px; background: #0004; color: #d4ecdf; font-size: .7rem; }
.tn-slot.is-ready, .tn-slot.is-hint { border-color: var(--gold); background: #e3b34138; }
.tn-slot .tn-tile { left: -2px; top: -2px; animation: tn-in .18s; }
.tn-sums { flex-wrap: wrap; gap: 5px; margin: 0; padding: 0; list-style: none; }
.tn-sums li { padding: 2px 9px; border-radius: 99px; background: #0004; color: #d9efe3; font-size: .85rem; white-space: nowrap; }
.tn-sums li.is-on { background: var(--gold); color: #2b2205; }
@media (max-width: 900px) { .tn-stats { flex: 1 0 100%; } }
@media (max-width: 760px) {
  .game-actions.tn-actions { grid-template-columns: repeat(5, 1fr); }
  .game-stats.tn-stats { display: grid; grid-template-columns: repeat(3, auto); white-space: nowrap; }
  .tn-sums { max-width: 210px; }
  .tn-status { min-height: 3.2em; }
}
@media (max-width: 360px) { .tn-actions .btn { font-size: .82rem; } }
@media (max-height: 520px) and (orientation: landscape) {
  .tn-stats { flex: auto; gap: 9px; font-size: .82rem; }
  .tn-status { margin: 0; }
  .tn-table { display: flex; align-items: center; }
  .tn-wrap { flex: 1; }
  .tn-tray { flex-direction: column; width: 160px; }
}
@media (prefers-reduced-motion: reduce) {
  .tn-tile, .is-denied { transition: none; animation: none !important; }
  .tn-tile.is-gone { display: none; }
}
