/* «Карта сокровищ» — пиратский нуар: морская карта, доски пути, тайники.
   Картинки берутся из /sprites/tr-*.webp; пока их нет, работают градиенты и эмодзи (body без .ts-art). */
.theme-ts {
  --gold: #e2c27a; --gold-2: #f6e8c4; --line: rgba(226, 194, 122, .22); --toxic: #7fd6c8;
  --panel: rgba(8, 12, 14, .93); --sea: #0d2a30; --plank: #b38a52; --cell: 64px;
  background: #06090b;
}
.theme-ts .btn-gold { background: linear-gradient(180deg, #2f8a86, #12403f); color: #effbf6; border-color: #8fe0d2; box-shadow: 0 6px 24px rgba(40, 150, 140, .3), inset 0 1px 0 rgba(255, 255, 255, .3); }
.theme-ts .btn-gold:hover { background: linear-gradient(180deg, #38a09b, #164c4a); }
.theme-ts .logo h1 { font-size: 3.1rem; line-height: 1; background: linear-gradient(180deg, #fbf3dc, #e2c27a 55%, #6a4a1a); -webkit-background-clip: text; background-clip: text; }
.theme-ts .logo-rule::after { content: '✕'; color: #c8402a; }
.theme-ts #scene .h-bg { background: url(/sprites/tr-bg.webp) center / cover, radial-gradient(ellipse at 50% 35%, #123036, #05090b 72%); filter: brightness(.6); }
body.theme-ts.in-game #scene .h-bg { filter: brightness(.34) saturate(.9) blur(1.5px); }
.theme-ts .h-lamp { background: radial-gradient(circle, rgba(140, 220, 210, .12), transparent 60%); }
.theme-ts .tr-fg { stroke: var(--gold); }

/* ---------- раскладка ---------- */
.ts-stage { align-items: stretch; }
.ts-center { flex: 1; min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 4px; padding: 4px 6px 0; }
.ts-seats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px; padding-top: 4px; }
.theme-ts .ts-seats .seat { position: relative; left: auto; top: auto; transform: none; width: 6.4rem; cursor: default; pointer-events: auto; }
.theme-ts .ts-seats .seat .ava-wrap { width: 3.3rem; height: 3.3rem; }
.theme-ts .ts-seats .seat .name { font-size: .78rem; margin-top: .2rem; padding: 0 .4rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-ts .seat.turn .ava { border-color: var(--toxic); box-shadow: 0 0 0 4px rgba(127, 214, 200, .25), 0 0 24px 6px rgba(127, 214, 200, .45); }
.theme-ts .seat.turn::before { content: '⚓'; top: -16px; font-size: .9rem; color: var(--toxic); }
.theme-ts .seat.pickable { cursor: pointer; } .theme-ts .seat.pickable .ava { animation: tsPick 1s ease-in-out infinite; }
body.ts-picking .ts-seats .seat:not(.pickable) { opacity: .45; }
@keyframes tsPick { 50% { box-shadow: 0 0 0 5px rgba(226, 194, 122, .5), 0 0 26px 8px rgba(226, 194, 122, .5); } }
.ts-meta { display: flex; justify-content: center; gap: 6px; font-size: .72rem; margin-top: 2px; color: var(--muted); }
.ts-meta b { color: var(--gold-2); font-weight: 800; }
.ts-tools { display: flex; justify-content: center; gap: 2px; min-height: 1.15rem; margin-top: 1px; }
.ts-tool { position: relative; width: 1.15rem; height: 1.15rem; border-radius: 4px; display: grid; place-items: center; font-size: .78rem; background: #3a1410 center / cover no-repeat; box-shadow: 0 0 0 1px #c8402a; }
.ts-tool > b { position: absolute; right: -4px; bottom: -5px; z-index: 2; font-size: .55rem; line-height: 1; padding: 1px 3px; border-radius: 6px; background: #0b1a1c; color: #ffd7a0; box-shadow: 0 0 0 1px #c8402a; }
.ts-tool::after { content: ''; position: absolute; inset: 0; background: linear-gradient(45deg, transparent 44%, #ff5a3a 44% 56%, transparent 56%); }
body.ts-art .ts-tool > span { display: none; }
body.ts-art .ts-tool::after { display: none; }
.ts-rolebadge { position: absolute; left: 50%; bottom: -6px; transform: translateX(-50%); white-space: nowrap; z-index: 4; font-size: .62rem; font-weight: 800; padding: 1px 5px; border-radius: 7px; letter-spacing: .04em; }
.ts-rolebadge.sailor { background: #1d5f5a; color: #dffaf4; border: 1px solid #8fe0d2; }
.ts-rolebadge.traitor { background: #6a1a10; color: #ffe2d6; border: 1px solid #ff8a6a; }
.ts-votemark { position: absolute; left: -6px; top: -4px; z-index: 4; font-size: .9rem; }

/* ---------- поле ---------- */
.ts-boardwrap { position: relative; min-height: 0; overflow: hidden; display: grid; place-items: center; }
.ts-board { position: relative; display: grid; grid-template-columns: repeat(11, var(--cell)); grid-template-rows: repeat(7, var(--cell)); gap: 2px; padding: 8px; border-radius: 14px;
  background: url(/sprites/tr-board.webp) center / cover, radial-gradient(ellipse at 50% 50%, #1b4a50, #0b2226 75%); border: 1px solid rgba(226, 194, 122, .35); box-shadow: 0 20px 60px rgba(0, 0, 0, .7), inset 0 0 60px rgba(0, 0, 0, .5); }
.ts-cell { position: relative; width: var(--cell); height: var(--cell); border-radius: 6px; }
.ts-cell.empty { background: rgba(255, 255, 255, .025); outline: 1px dashed rgba(226, 194, 122, .07); outline-offset: -1px; }
.ts-cell.ok { background: rgba(127, 214, 200, .16); outline: 2px dashed rgba(127, 214, 200, .7); cursor: pointer; animation: tsOk 1.2s ease-in-out infinite; }
.ts-cell.ok:hover { background: rgba(127, 214, 200, .3); }
@keyframes tsOk { 50% { outline-color: rgba(127, 214, 200, .25); } }
.ts-cell .ghost { position: absolute; inset: 0; opacity: 0; pointer-events: none; transition: opacity .12s; }
.ts-cell.ok:hover .ghost { opacity: .75; }
.ts-cell.stormable { cursor: pointer; } .ts-cell.stormable::after { content: '🌀'; position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cell) * .45); background: rgba(60, 120, 200, .25); border-radius: 6px; animation: tsOk 1s infinite; }
.ts-cell.scopeable { cursor: pointer; } .ts-cell.scopeable::after { content: '🔭'; position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cell) * .42); background: rgba(226, 194, 122, .25); border-radius: 6px; animation: tsOk 1s infinite; }
.ts-cell.fresh { animation: tsFresh .9s ease-out; }
@keyframes tsFresh { 0% { transform: scale(1.35) rotate(-6deg); filter: brightness(2); } 100% { transform: none; filter: none; } }
.ts-cell.gone { animation: tsGone .9s ease-in forwards; }
@keyframes tsGone { to { transform: scale(.2) rotate(200deg); opacity: 0; } }

/* карта пути: подложка + доски, нарисованные кодом (стороны всегда совпадают) */
.ts-tile { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; background: url(/sprites/tr-tile.webp) center / cover, linear-gradient(160deg, #2c5156, #163035); box-shadow: 0 2px 6px rgba(0, 0, 0, .6), inset 0 0 0 1px rgba(226, 194, 122, .25); }
.ts-tile svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.ts-tile .pl { stroke: var(--plank); stroke-width: 30; stroke-linecap: butt; fill: none; }
.ts-tile .pl2 { stroke: url(#tsPlank); stroke-width: 30; stroke-linecap: butt; fill: none; }
.ts-tile .edge { stroke: rgba(0, 0, 0, .45); stroke-width: 34; fill: none; }
.ts-tile .hub { fill: var(--plank); }
.ts-tile .hub2 { fill: url(#tsPlank); }
.ts-tile .pl2.h { stroke: url(#tsPlankV); }
body:not(.ts-plank) .ts-tile .pl2, body:not(.ts-plank) .ts-tile .hub2 { display: none; }
.ts-tile .rock { fill: #1a1612; stroke: #c8402a; stroke-width: 3; }
.ts-tile .x { stroke: #ff6a4a; stroke-width: 5; stroke-linecap: round; }
.ts-tile.dead { background: url(/sprites/tr-tile.webp) center / cover, linear-gradient(160deg, #3a3a38, #1a1c1c); }
.ts-tile.mine { box-shadow: 0 2px 6px rgba(0, 0, 0, .6), inset 0 0 0 2px rgba(127, 214, 200, .6); }
.ts-start { background: url(/sprites/tr-dock.webp) center / cover, linear-gradient(160deg, #6a4a24, #2a1a0c); }
.ts-goal { position: absolute; inset: -2px; border-radius: 8px; display: grid; place-items: center; text-align: center; background: url(/sprites/tr-cache.webp) center / cover, radial-gradient(circle, #5a4424, #1d150d); border: 2px solid rgba(226, 194, 122, .6); box-shadow: 0 0 18px rgba(226, 194, 122, .25); transition: transform .6s; }
.ts-goal .lbl { font: 900 calc(var(--cell) * .38) / 1 var(--serif); color: #f6e8c4; text-shadow: 0 2px 6px #000; }
.ts-goal .peek { position: absolute; right: -6px; top: -6px; font-size: calc(var(--cell) * .3); background: #0b1a1c; border-radius: 50%; padding: 2px; box-shadow: 0 0 0 1px var(--gold); }
.ts-goal.gold { background: url(/sprites/tr-treasure.webp) center / cover, radial-gradient(circle, #ffd76a, #8a5a10); border-color: #ffd76a; box-shadow: 0 0 30px rgba(255, 215, 106, .7); animation: tsGold 1.6s ease-in-out infinite alternate; }
.ts-goal.reef { background: url(/sprites/tr-reef.webp) center / cover, radial-gradient(circle, #4a4a46, #141414); border-color: #6a6a62; box-shadow: none; }
.ts-goal.shut { opacity: .75; }
.ts-goal.flip { animation: tsFlip .8s ease-out; }
@keyframes tsGold { to { box-shadow: 0 0 46px rgba(255, 215, 106, 1); } }
@keyframes tsFlip { 0% { transform: rotateY(90deg) scale(1.2); } 100% { transform: none; } }
body.ts-art .ts-goal .lbl:not(.n), body.ts-art .ts-start .lbl { display: none; }
body.ts-art .ts-goal .lbl.n { position: absolute; left: 2px; bottom: 2px; font-size: calc(var(--cell) * .22); background: rgba(8, 12, 14, .8); border-radius: 50%; width: 1.5em; height: 1.5em; display: grid; place-items: center; box-shadow: 0 0 0 1px var(--gold); }
.ts-start .lbl { position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--cell) * .45); z-index: 2; }

.ts-deck { position: absolute; left: 6px; bottom: 4px; display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); pointer-events: none; }
.ts-deck i { width: 1.9rem; height: 2.7rem; border-radius: 4px; background: url(/sprites/tr-back.webp) center / cover, repeating-linear-gradient(45deg, rgba(226, 194, 122, .14) 0 4px, transparent 4px 10px), linear-gradient(180deg, #16343a, #081416); border: 1px solid rgba(226, 194, 122, .5); box-shadow: 2px 2px 0 #0a1416, 4px 4px 0 #061012; }
.ts-deck b { color: var(--gold-2); font-size: 1rem; }
.ts-role { position: absolute; right: 6px; bottom: 4px; display: flex; align-items: center; gap: 8px; pointer-events: auto; cursor: help; }
.ts-role i { width: 2.6rem; height: 3.9rem; border-radius: 5px; background: center / cover no-repeat; border: 1px solid var(--gold); box-shadow: 0 4px 12px #000; }
.ts-role.sailor i { background-image: url(/sprites/tr-role-sailor.webp), linear-gradient(180deg, #1d5f5a, #0a2422); }
.ts-role.traitor i { background-image: url(/sprites/tr-role-traitor.webp), linear-gradient(180deg, #6a1a10, #200805); border-color: #ff8a6a; }
.ts-role span { font: 700 .95rem var(--serif); text-shadow: 0 2px 4px #000; }
.ts-role.sailor span { color: #9ff0e2; } .ts-role.traitor span { color: #ff9a7a; }

/* ---------- рука ---------- */
.theme-ts .dock.ts-dock { grid-template-columns: 1fr; min-height: 0; padding-top: .3rem; }
.theme-ts .ts-dock .dock-main { grid-template-columns: 1fr; }
.theme-ts .ts-hand { height: auto; min-height: 7.4rem; gap: 6px; padding-top: .3rem; flex-wrap: nowrap; }
.ts-card { position: relative; flex: none; width: 5rem; height: 7.4rem; border-radius: 8px; cursor: pointer; transition: transform .15s, box-shadow .15s; box-shadow: 0 6px 16px rgba(0, 0, 0, .7); border: 1px solid rgba(226, 194, 122, .45); overflow: hidden; background: #10262a; }
.ts-card:hover { transform: translateY(-6px); }
.ts-card.sel { transform: translateY(-14px); box-shadow: 0 0 0 3px var(--toxic), 0 10px 28px rgba(127, 214, 200, .45); }
.ts-card.off { filter: grayscale(.7) brightness(.7); }
.ts-card.path { display: grid; place-items: center; background: linear-gradient(180deg, #1c3a40, #0c1c1f); }
.ts-card.path .ts-tile { position: relative; inset: auto; width: 4.4rem; height: 4.4rem; transition: transform .25s; }
.ts-card.path .cap { position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: .62rem; color: var(--gold-2); }
.ts-card.act { background-size: cover; background-position: center; }
.ts-card .ic { position: absolute; top: 18%; left: 0; right: 0; text-align: center; font-size: 2.1rem; filter: drop-shadow(0 2px 4px #000); }
.ts-card .nm { position: absolute; bottom: 0; left: 0; right: 0; padding: 4px 3px 5px; font: 800 .64rem / 1.1 var(--sans); text-align: center; color: #fbf3dc; background: linear-gradient(0deg, rgba(0, 0, 0, .85), rgba(0, 0, 0, .3)); text-shadow: 0 1px 2px #000; }
.ts-card .kd { position: absolute; top: 3px; left: 0; right: 0; text-align: center; font-size: .55rem; letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .7); }
body.ts-art .ts-card .ic, body.ts-art .ts-card .kd { display: none; }
body.ts-art .ts-card.act .nm { background: none; top: auto; height: 22%; padding: 0 4px; display: grid; place-items: center; }
.ts-card.k-break { background-color: #4a1610; background-image: linear-gradient(180deg, #6a2016, #240806); }
.ts-card.k-fix { background-color: #18463a; background-image: linear-gradient(180deg, #24604f, #0a201a); }
.ts-card.k-scope { background-image: linear-gradient(180deg, #5a4a24, #1d150d); }
.ts-card.k-storm { background-image: linear-gradient(180deg, #24385a, #0a1020); }
.ts-card.rot .ts-tile { transform: rotate(180deg); }
@media (max-width: 760px) {
  .ts-card { width: 3.9rem; height: 5.8rem; } .ts-card.path .ts-tile { width: 3.4rem; height: 3.4rem; }
  .ts-card .ic { font-size: 1.6rem; } .ts-card .nm { font-size: .55rem; }
  .theme-ts .ts-hand { min-height: 5.9rem; overflow-x: auto; justify-content: flex-start; }
  .ts-seats { flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; padding: 14px 4px 2px; scrollbar-width: none; }
  .theme-ts .ts-seats .seat { width: 4.3rem; flex: none; } .theme-ts .ts-seats .seat .ava-wrap { width: 2.4rem; height: 2.4rem; }
  .theme-ts .ts-seats .seat .bot-badge, .theme-ts .ts-seats .seat .num { display: none; }
  .theme-ts .ts-seats .seat .name { font-size: .66rem; }
  .ts-deck, .ts-role span { display: none; }
  .ts-role i { width: 1.8rem; height: 2.7rem; }
  .theme-ts .ts-hand { max-width: 100vw; width: 100%; }
  .theme-ts .dock-actions .btn { padding: .45rem .8rem; font-size: .85rem; }
  .theme-ts .dock { min-height: 0; padding: .3rem .4rem .6rem; }
  .theme-ts .dock-prompt { font-size: 1.05rem; }
}

/* ---------- голосование ---------- */
.ts-vote { position: fixed; left: 50%; top: 4.6rem; transform: translateX(-50%); z-index: 870; width: min(380px, calc(100vw - 24px)); padding: 14px 16px; border-radius: 14px; text-align: center;
  background: rgba(20, 12, 8, .96); border: 1px solid #ff8a6a; box-shadow: 0 16px 50px rgba(0, 0, 0, .7); animation: tsIn .3s ease-out; }
.ts-vote h3 { margin: 0 0 4px; font: 900 1.2rem var(--serif); color: #ffb59a; }
.ts-vote p { margin: 4px 0 10px; font-size: .9rem; color: var(--muted); }
.ts-vote .row { display: flex; gap: 8px; justify-content: center; }
.ts-vote .bar { height: 4px; border-radius: 2px; background: #ff8a6a; margin-top: 10px; transition: width .25s linear; }
@keyframes tsIn { from { transform: translate(-50%, -14px); opacity: 0; } }

/* ---------- итоги ---------- */
.ts-res { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: .92rem; }
.ts-res td, .ts-res th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.ts-res th { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.ts-res .r-sailor { color: #9ff0e2; } .ts-res .r-traitor { color: #ff9a7a; }
.ts-res .g { color: #ffd76a; font-weight: 800; }
.ts-awards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.ts-awards div { padding: 6px 10px; border-radius: 10px; background: rgba(226, 194, 122, .08); border: 1px solid var(--line); display: grid; text-align: center; font-size: .8rem; }
.ts-awards b { color: var(--gold-2); }
.ts-rules p { line-height: 1.5; }
.ts-rules .cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 8px; margin: 10px 0; }
.ts-rules .cards > div { display: flex; gap: 10px; align-items: center; }
.ts-rules .cards .ts-card { width: 3.4rem; height: 5rem; cursor: default; } .ts-rules .cards .ts-card:hover { transform: none; }
.ts-rules .cards .ts-card .ic { font-size: 1.4rem; } .ts-rules .cards .ts-card .nm { display: none; }
.ts-rules small { display: block; color: var(--muted); }
.confetti { position: fixed; top: -12px; width: 9px; height: 14px; z-index: 999; animation: confFall linear forwards; pointer-events: none; }
@keyframes confFall { to { transform: translateY(105vh) rotate(720deg); } }
/* приказ: названные игроки, чёрная метка, ожидание выбора цели */
.theme-ts .seat.named .ava { border-color: #ff9a7a; box-shadow: 0 0 0 3px rgba(255, 154, 122, .35), 0 0 18px 4px rgba(255, 120, 90, .4); }
.theme-ts .seat.named .name::after { content: ' 🎯'; }
.theme-ts .seat.marked .name::before { content: '☠ '; color: #ff9a7a; }
.theme-ts .seat.turn.picking::before { content: '⏳'; animation: tsPick 1s ease-in-out infinite; }
