/* The panel paints the scene and the stage stays see-through; the script sets --tgm-horizon to the top of the tray. */
.game-root[data-game="tangram"] {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, #f5f0e6 0, #eee6d6 var(--tgm-horizon, 63%), #e2c59c calc(var(--tgm-horizon, 63%) + 1px), #d6b384 100%);
}
.tgm { container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.tgm-hud { display: flex; justify-content: center; }
.tgm-trail { display: flex; gap: 8px; }
.tgm-dot { width: 14px; height: 14px; border-radius: 4px; background: rgba(60, 70, 90, .16); transform: rotate(45deg); transition: background .3s; }
.tgm-dot.is-clean { background: #5fb870; }
.tgm-dot.is-helped { background: #e3c46b; }
.tgm-dot.is-now { background: #fff; box-shadow: inset 0 0 0 2px #5fb870; }
/* min-height: 0, or the aspect-ratio box grows by the stage's rounding and the fit loops. */
.tgm-fit { display: grid; place-items: center; width: 100%; max-width: 520px; min-height: 0; margin: 0 auto; aspect-ratio: 560 / 720; }
.tgm-stage { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.tgm-world { position: absolute; left: 0; top: 0; width: 560px; height: 720px; transform-origin: 0 0; }
.tgm-svg { position: absolute; left: 0; top: 0; overflow: visible; }
.tgm-fx { position: absolute; inset: 0; pointer-events: none; }
.tgm-clock { position: absolute; left: 0; top: 0; width: 0; height: 0; }

.tgm-snd { position: absolute; top: 8px; right: 8px; z-index: 3; display: grid; place-items: center; width: 36px; height: 36px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .85); box-shadow: 0 2px 6px rgba(60, 80, 100, .15); color: #5b4a32; font-size: 19px; line-height: 1; cursor: pointer; }
.tgm-snd[hidden] { display: none; }
.tgm-snd.is-off { color: #a9a39a; }
.tgm-snd.is-off::after { content: ""; position: absolute; width: 22px; height: 2px; border-radius: 1px; background: #a9a39a; transform: rotate(-45deg); }

.tgm-slot { fill: rgba(255, 250, 240, .38); }
.tgm-shape { transform-box: fill-box; transform-origin: center; }
.tgm-shape polygon { fill: #3b4658; stroke: #3b4658; stroke-width: 1.5; stroke-linejoin: round; }
.tgm-lines polygon { fill: none; stroke: rgba(255, 255, 255, .6); stroke-width: 2; stroke-dasharray: 7 6; stroke-linejoin: round; }
.tgm-lines polygon.is-cue { animation: tgm-pulse 1.6s ease-in-out infinite; }
@keyframes tgm-pulse { 50% { stroke: #ffe28a; stroke-width: 4px; } }

.tgm-piece { cursor: grab; touch-action: none; }
.tgm-piece.is-held { cursor: grabbing; }
.tgm-spin { transform-box: fill-box; transform-origin: center; }
.tgm-face { stroke: rgba(0, 0, 0, .22); stroke-width: 1.5; stroke-linejoin: round; }
.tgm-shadow { fill: rgba(40, 30, 20, .2); }
.tgm-piece.is-placed .tgm-shadow { opacity: 0; }
.tgm-piece.is-held .tgm-shadow { transform: translate(4px, 12px); }
.tgm-piece.is-cue .tgm-face { animation: tgm-glow 1.6s ease-in-out infinite; }
@keyframes tgm-glow { 50% { stroke: #fff; stroke-width: 10px; } }

.tgm-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.tgm-cap { min-height: 1.5em; margin: 0; font-weight: 700; color: var(--c-text); text-align: center; }
@container (max-width: 480px) {
  .tgm-cap { min-height: 3em; }
}
.tgm-hint { background: #fff; color: var(--c-text); border: 1px solid var(--c-border); }
.tgm-hint:disabled { opacity: .5; cursor: default; }
.tgm-go { background: #3fae5a; color: #fff; box-shadow: var(--shadow); }
.tgm-go:hover { background: #36994e; }
.tgm-end { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 12px; background: rgba(34, 52, 72, .22); }
.tgm-end:empty { display: none; }
.tgm-end .result-card { width: min(100%, 340px); padding: 18px 20px 20px; border-radius: 20px; background: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); animation: tgm-pop .34s cubic-bezier(.3, 1.4, .5, 1); }
.tgm-end .result-card .result-done { font-size: 1.8rem; margin: 0 0 6px; }
.tgm-end .result-card .btn { margin-top: 12px; }
@keyframes tgm-pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

html.fills-window .game-root[data-game="tangram"] .tgm { height: 100%; }
html.fills-window .game-root[data-game="tangram"] .tgm-fit { flex: 1 1 0; max-width: none; aspect-ratio: auto; }
html.fills-window .game-root[data-game="tangram"] .tgm-hud,
html.fills-window .game-root[data-game="tangram"] .tgm-foot { flex: none; }
