/* Background layers paint first-on-top: the flat ground stays last or it covers the weave. */
.game-root[data-game="trios"] {
  background:
    repeating-linear-gradient(135deg, rgba(74, 92, 116, .05) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(45deg, rgba(74, 92, 116, .035) 0 1px, transparent 1px 7px),
    radial-gradient(120% 100% at 50% 0%, #eef2f7 0%, #e4e9f0 52%, #dae0e9 100%);
}
.tri { container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 10px; width: 100%; }
.tri-hud { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 20px; font-size: .88rem; color: var(--c-text-soft); }
.tri-trail { display: flex; gap: 6px; }
.tri-dot { width: 11px; height: 11px; border-radius: 50%; background: rgba(74, 92, 116, .2); transition: background .3s; }
.tri-dot.is-done { background: #8fcf93; }
/* min-height: 0, or the aspect-ratio box grows by the stage's rounding and the fit loops. */
.tri-fit { display: grid; place-items: center; width: 100%; max-width: 560px; min-height: 0; margin: 0 auto; aspect-ratio: var(--tri-ratio, 506 / 470); }
.tri-stage { position: relative; overflow: hidden; border-radius: 16px; }
.tri-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tri-table { position: absolute; inset: 0; }
.tri-tick { position: absolute; left: 0; top: 0; width: 0; height: 0; }
.tri-defs { position: absolute; width: 0; height: 0; }
.tri-card { position: absolute; width: 150px; height: 100px; margin: 0; padding: 0; border: 0; border-radius: 12px; background: #fff; box-shadow: 0 3px 0 rgba(0, 0, 0, .08), 0 1px 4px rgba(0, 0, 0, .08); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform .15s, box-shadow .15s; }
.tri-card svg { display: block; width: 100%; height: 100%; }
.tri-card.is-picked { transform: translateY(-5px); box-shadow: 0 0 0 4px #4a7fd6, 0 6px 10px rgba(0, 0, 0, .12); }
.tri-card.is-glow { animation: tri-breathe 1.6s ease-in-out infinite; }
@keyframes tri-breathe { 50% { box-shadow: 0 0 0 7px rgba(63, 174, 90, .45), 0 3px 0 rgba(0, 0, 0, .08); } }
.tri-foot { display: grid; justify-items: center; gap: 6px; }
.tri-cap { min-height: 1.5em; margin: 0; font-weight: 700; color: var(--c-text); text-align: center; }
.tri-why { display: grid; grid-template-columns: repeat(4, minmax(0, 96px)); justify-content: center; gap: 4px; min-height: 40px; }
.tri-why[hidden] { display: none; }
.tri-why .tri-v { flex-direction: column; align-items: flex-start; justify-content: center; min-height: 0; }
.tri-why .tri-v b { font-size: .62rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; opacity: .75; }
.tri-actions { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 50px; }
.tri-go { background: #3fae5a; color: #fff; box-shadow: var(--shadow); }
.tri-go:hover { background: #36994e; }
.tri-hint { background: #fff; color: var(--c-text); border: 1px solid var(--c-border); }
.tri-hint:disabled { opacity: .45; cursor: default; }
.tri-hud-end { display: flex; align-items: center; gap: 10px; }
.tri-rules-btn { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 5px; border: 1px solid var(--c-border); border-radius: 999px; background: #fff; color: var(--c-text); font: inherit; font-size: .85rem; font-weight: 700; cursor: pointer; }
.tri-rules-btn span { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: #efe7da; font-size: .8rem; }
.tri-rules { position: absolute; inset: 0; z-index: 11; display: grid; place-items: center; padding: 12px; border-radius: 14px; background: rgba(34, 52, 72, .22); }
.tri-rules[hidden] { display: none; }
.tri-rules-card { position: relative; width: min(100%, 880px); max-height: 100%; overflow: auto; padding: 18px 20px 20px; border-radius: 20px; background: #fff; box-shadow: 0 12px 32px rgba(0, 0, 0, .18); text-align: left; }
.tri-rules-x { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: #f1f1f5; color: var(--c-text); font-size: 1.3rem; line-height: 1; cursor: pointer; }
.tri-rules-card h3 { margin: 0 40px 10px 0; font-size: 1.15rem; }
.tri-rules-card h4 { margin: 16px 0 8px; font-size: .9rem; color: var(--c-text-soft); }
.tri-rules-rule { margin: 0; padding: 10px 12px; border-radius: 12px; background: #f6f1e8; color: var(--c-text); font-weight: 700; line-height: 1.4; }
.tri-rules-block.is-yes h4 { color: #2e7d44; }
.tri-rules-block.is-no h4 { color: #c2412d; }
.tri-rules-row { display: grid; grid-template-columns: 5.2em repeat(3, minmax(0, 1fr)); gap: 6px; align-items: center; margin-bottom: 6px; }
.tri-rules-label { font-size: .85rem; font-weight: 700; }
.tri-replay { margin-top: 12px; background: #fff; color: var(--c-text); border: 1px solid var(--c-border); }
.tri-rules-example { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.tri-ex { display: grid; gap: 6px; padding: 10px 0; border-top: 1px solid #f0ebe2; }
.tri-ex .tri-rules-example { max-width: 250px; }
.tri-ex.is-head { position: sticky; top: -18px; z-index: 1; gap: 0; padding: 6px 0; border-top: 0; background: #fff; }
.tri-ex.is-head + .tri-ex { padding-top: 4px; border-top: 0; }
.tri-ex.is-head b { padding: 0 5px; color: var(--c-text-soft); font-size: .64rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.tri-verdicts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.tri-v { display: flex; align-items: center; min-height: 2.9em; padding: 4px 5px; border-radius: 8px; background: #e3f5e4; color: #2e7d44; font-size: .72rem; font-weight: 700; line-height: 1.25; }
.tri-v.is-bad { background: #fde8e4; color: #c2412d; }
@container (min-width: 560px) {
  .tri-ex { grid-template-columns: minmax(0, 200px) minmax(0, 1fr); align-items: center; gap: 12px; }
}
@container (min-width: 820px) {
  .tri-rules-body { display: grid; grid-template-columns: minmax(0, 290px) minmax(0, 1fr); align-items: start; gap: 28px; }
  .tri-rules-examples > .tri-rules-block:first-child h4 { margin-top: 4px; }
}
.tri-mini { display: block; aspect-ratio: 150 / 100; border-radius: 7px; background: #fff; box-shadow: 0 0 0 1px #e4ddd0, 0 2px 0 rgba(0, 0, 0, .06); }
.tri-mini svg { display: block; width: 100%; height: 100%; }
.tri-end { position: absolute; inset: 0; z-index: 10; display: grid; place-items: center; padding: 12px; border-radius: 14px; background: rgba(34, 52, 72, .22); }
.tri-end:empty { display: none; }
.tri-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: tri-pop .34s cubic-bezier(.3, 1.4, .5, 1); }
.tri-end .result-card .result-done { font-size: 1.8rem; margin: 0 0 6px; }
.tri-end .result-card .btn { margin-top: 12px; }
.tri-end-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0 10px; }
.tri-plain { background: #fff; color: var(--c-text); border: 1px solid var(--c-border); }
@keyframes tri-pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
html.fills-window .game-root[data-game="trios"] .tri { height: 100%; }
html.fills-window .game-root[data-game="trios"] .tri-fit { flex: 1 1 0; max-width: none; aspect-ratio: auto; }
html.fills-window .game-root[data-game="trios"] .tri-hud,
html.fills-window .game-root[data-game="trios"] .tri-foot { flex: none; }
