/* Table engine styles. Loaded after engine.css. */
html, body.tbl-page { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body.tbl-page { display: flex; flex-direction: column; }
.tbl-layout { flex: 1 1 auto; display: flex; min-height: 0; }
.tbl-side { flex: 0 0 400px; display: none; flex-direction: column; border-left: 1px solid var(--line); background: var(--bg-2); min-height: 0; }
body.with-panel.panel-open .tbl-side { display: flex; }
.tbl-tabs { display: flex; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tbl-tabs button { flex: 1; background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 9px 4px; cursor: pointer; }
.tbl-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tbl-panel { flex: 1 1 auto; overflow: auto; padding: 10px 12px 40px; font-size: 14px; }
.tbl-panel .sec { margin-bottom: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; }
.tbl-panel .sec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.tbl-panel .sec p { margin: 6px 0; line-height: 1.4; }
.tbl-panel .btn-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tbl-panel .muted { color: var(--muted); }
.tbl-panel label.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; font-weight: 600; }
.tbl-panel select.ui-input, .tbl-panel input.ui-input { font-weight: 400; }
@media (max-width: 900px) {
  .tbl-layout { flex-direction: column; }
  .tbl-side { flex: 0 0 auto; border-left: 0; border-top: 1px solid var(--line); max-height: 48vh; }
}
.tbl-toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: var(--bg-2); border-bottom: 1px solid var(--line); flex: 0 0 auto; flex-wrap: wrap; }
.tbl-brand { display: flex; align-items: center; gap: 8px; }
.tbl-home { color: var(--muted); text-decoration: none; font-size: 18px; padding: 2px 8px; border-radius: 6px; }
.tbl-home:hover { background: var(--bg-3); color: var(--text); }
.tbl-title { font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); font-size: 14px; white-space: nowrap; }
.tbl-actions { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.tbl-tools { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.tbl-tools .sep { width: 1px; height: 20px; background: var(--line); }
.tbl-tools a.btn { text-decoration: none; }
.tbl-viewport { flex: 1 1 auto; position: relative; overflow: hidden; touch-action: none; outline: none; cursor: grab;
  background: #0a0e14 radial-gradient(circle at 30% 20%, #18212e 0, #0a0e14 65%); }
.tbl-viewport:active { cursor: grabbing; }
.tbl-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: rgba(255,255,255,.015); border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.tbl-obj { position: absolute; left: 0; top: 0; transform-origin: center; user-select: none; -webkit-user-select: none; will-change: transform; }
.tbl-obj:not(.static) { cursor: grab; }
.tbl-obj.dragging { cursor: grabbing; filter: drop-shadow(0 14px 18px rgba(0,0,0,.6)); transition: none; }
.tbl-obj img { display: block; pointer-events: none; }

.tbl-image img { width: 100%; height: auto; border-radius: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.55); }
.tbl-label span { white-space: nowrap; font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }

.tbl-zone { border: 2px dashed var(--zone-color); border-radius: 10px; background: color-mix(in srgb, var(--zone-color) 8%, transparent); box-sizing: border-box; }
.tbl-zone-label { position: absolute; left: 8px; top: -11px; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--bg-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.tbl-zone.trash { --zone-color: rgba(255,92,92,.6); }
.tbl-zone.grid { display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); gap: var(--gap, 10px); padding: var(--gap, 10px); }
.tbl-slot { border: 1px dashed rgba(255,255,255,.12); border-radius: 8px; }

.tbl-card.round, .tbl-deck.round .tbl-deck-stack { border-radius: 50%; }
.tbl-card.dim { opacity: .55; }
.tbl-badge { position: absolute; right: -4px; top: -4px; background: var(--accent); color: #0b1a07; font-size: 11px; font-weight: 800; border-radius: 999px; padding: 1px 6px; z-index: 2; }
.tbl-zone.quiet { border-style: solid; border-width: 1px; background: transparent; }
.tbl-zone.quiet .tbl-zone-label { opacity: .7; }
.tbl-card { border-radius: 6px; overflow: hidden; box-shadow: 0 2px 6px rgba(0,0,0,.5); perspective: 600px; }
.tbl-card img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; backface-visibility: hidden; transition: transform .25s; }
.tbl-card img.back { transform: rotateY(180deg); }
.tbl-card.down img.front { transform: rotateY(180deg); }
.tbl-card.down img.back { transform: rotateY(0); }

.tbl-deck { border-radius: 6px; }
.tbl-deck-stack { position: absolute; inset: 0; border-radius: 6px; overflow: hidden; background: var(--bg-3); box-shadow: 2px 2px 0 #0b0f15, 4px 4px 0 #1c2531, 6px 6px 0 #0b0f15, 0 8px 14px rgba(0,0,0,.5); }
.tbl-deck-stack img { width: 100%; height: 100%; object-fit: cover; }
.tbl-deck.empty .tbl-deck-stack { background: transparent; box-shadow: none; border: 2px dashed var(--line); }
.tbl-deck.empty .tbl-deck-stack img { display: none; }
.tbl-deck-label { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 12px; white-space: nowrap; cursor: move; z-index: 2; }
.tbl-deck-label .count { background: var(--accent); color: #0b1a07; font-weight: 800; border-radius: 999px; padding: 0 6px; min-width: 18px; text-align: center; }

.tbl-die { border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 800; box-shadow: inset 0 -4px 0 rgba(0,0,0,.18), 0 3px 6px rgba(0,0,0,.5); }
.tbl-die .face { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; line-height: 1; }
.tbl-die .face.img img { width: 84%; height: 84%; object-fit: contain; border-radius: 6px; }
.tbl-die.rolling { animation: tbl-shake .35s ease-in-out; }
@keyframes tbl-shake { 0%,100% { rotate: 0deg; } 25% { rotate: -14deg; } 75% { rotate: 14deg; } }
.tbl-die .lock { display: none; position: absolute; right: -6px; top: -8px; font-size: 14px; }
.tbl-die.locked { outline: 3px solid var(--accent-2); }
.tbl-die.locked .lock { display: block; }
.tbl-caption { position: absolute; left: 50%; top: -18px; transform: translateX(-50%); font-size: 11px; font-weight: 700; color: var(--muted); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; pointer-events: none; }

.tbl-token { display: flex; align-items: center; justify-content: center; font-weight: 800; box-shadow: inset 0 -3px 0 rgba(0,0,0,.25), 0 2px 5px rgba(0,0,0,.5); border: 2px solid rgba(0,0,0,.35); }
.tbl-token.supply { box-shadow: 2px 2px 0 rgba(0,0,0,.4), 4px 4px 0 rgba(0,0,0,.3), 0 2px 5px rgba(0,0,0,.5); }
.tbl-token.supply::after { content: "\221E"; position: absolute; right: -6px; bottom: -8px; font-size: 12px; background: var(--bg-2); color: var(--muted); border-radius: 999px; padding: 0 4px; border: 1px solid var(--line); }

.tbl-counter { display: flex; align-items: stretch; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tbl-counter button { width: 30px; background: var(--bg-3); color: var(--text); border: 0; font-size: 18px; cursor: pointer; }
.tbl-counter button:hover { background: var(--line); }
.tbl-counter .mid { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tbl-counter .val { font-size: 24px; font-weight: 800; color: var(--ctr); line-height: 1; }
.tbl-counter .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.tbl-menu { position: fixed; z-index: 950; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; min-width: 170px; box-shadow: 0 14px 40px rgba(0,0,0,.6); padding: 4px; display: flex; flex-direction: column; }
.tbl-menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px 4px; }
.tbl-menu-item { text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.tbl-menu-item:hover { background: var(--bg-3); }
.tbl-menu-item.danger { color: #ffb3b3; }
.tbl-help { padding-left: 18px; margin: 0 0 8px; }
.tbl-help li { margin-bottom: 6px; }
@media (max-width: 760px) {
  .tbl-toolbar { gap: 6px; padding: 6px 8px; }
  .tbl-title { display: none; }
  .tbl-tools .sep { display: none; }
  .tbl-actions { flex: 1 1 100%; order: 3; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .tbl-actions::-webkit-scrollbar { display: none; }
  .tbl-actions .btn { white-space: nowrap; }
  .tbl-tools { margin-left: auto; }
}
