/* ========================================
   DnD-Hub - VIRTUAL TABLETOP
   ======================================== */

.tabletop-container {
    display: flex;
    height: calc(100vh - var(--nav-height));
    background: var(--bg-darkest);
}

.tabletop-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #1a3a2a;
    cursor: crosshair;
}

.tabletop-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
}

.tabletop-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
}

.tabletop-tab {
    flex: 1;
    padding: var(--space-md);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    border-bottom: 2px solid transparent;
}

.tabletop-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tabletop-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

/* Dice Roller */
.dice-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.dice-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-medium);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.dice-btn:hover {
    background: var(--color-primary);
    border-color: var(--color-primary);
    transform: scale(1.1);
}

/* Chat */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    max-height: 400px;
    overflow-y: auto;
}

.chat-message {
    padding: var(--space-md);
    background: var(--bg-medium);
    border-radius: var(--radius-md);
}

.chat-input {
    display: flex;
    gap: var(--space-sm);
}

.chat-input input {
    flex: 1;
}

.tabletop-app {
    min-height: calc(100vh - var(--nav-height));
}

.tabletop-full {
    min-height: calc(100vh - var(--nav-height));
    align-items: center;
    justify-content: center;
}

.tabletop-empty {
    text-align: center;
    padding: var(--space-4xl);
    max-width: 480px;
}

.tabletop-loading {
    padding: var(--space-2xl);
    text-align: center;
    color: var(--text-secondary);
}

.tabletop-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.tabletop-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border-subtle);
}

.tabletop-topbar-title {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    min-width: 0;
}

.tabletop-title {
    font-size: var(--font-size-lg);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabletop-topbar-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

.tabletop-gm-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    padding-right: var(--space-md);
    border-right: 1px solid var(--border-subtle);
    margin-right: var(--space-sm);
}

.tabletop-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.tabletop-scene-select {
    min-width: 140px;
    max-width: 200px;
}

.tabletop-stage-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0d1f16;
    cursor: grab;
}

.tabletop-stage-wrap:active {
    cursor: grabbing;
}

.tabletop-stage {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tabletop-map-layer {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.tabletop-map-inner {
    position: relative;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.03),
        rgba(255, 255, 255, 0.03) 12px,
        transparent 12px,
        transparent 24px
    );
}

.tabletop-map-img {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    user-select: none;
}

.tabletop-grid,
.tabletop-fog,
.tabletop-tokens,
.tabletop-templates,
.tabletop-measure {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.tabletop-tokens {
    pointer-events: auto;
}

.tabletop-fog.fog-player {
    pointer-events: none;
    mix-blend-mode: multiply;
}

.tabletop-token {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: grab;
    z-index: 2;
}

.tabletop-token.selected .tabletop-token-body {
    box-shadow: 0 0 0 3px var(--color-primary);
}

.tabletop-token.token-gm-hidden .tabletop-token-body {
    opacity: 0.45;
    border: 2px dashed var(--color-danger, #c44);
}

.tabletop-token-body {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-medium);
    border: 2px solid var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
}

.tabletop-token-caption {
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-primary);
    text-shadow: 0 1px 2px #000;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tabletop-sidebar-wide {
    width: min(380px, 100vw);
}

.tabletop-tab-panels {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tabletop-panel {
    display: none;
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.tabletop-panel.active {
    display: block;
}

.tabletop-panel-section {
    margin-bottom: var(--space-xl);
}

.tabletop-panel-section h4 {
    margin: 0 0 var(--space-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.tabletop-mini-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-md);
}

.tabletop-mini-list li {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.tabletop-init-list {
    padding-left: var(--space-lg);
}

.tabletop-init-list li.active {
    color: var(--color-primary);
    font-weight: 600;
}

.muted {
    color: var(--text-secondary);
}

.tabletop-roll-log {
    max-height: 220px;
    margin-top: var(--space-md);
}

.card-footer .btn-secondary {
    flex-shrink: 0;
}
