/**
 * Dungeon Explorer - CSS Styles
 * All classes prefixed with 'dex-' to avoid conflicts
 */

/* CSS Variables - inherit from theme where possible */
.dex-app-container {
    /* Classic dungeon map colors */
    --dex-color-solid: #4a90d9;
    --dex-color-solid-dark: #3a7bc8;
    --dex-color-open: #f5f5f0;
    --dex-color-grid: #c0c0c0;
    --dex-color-grid-dark: #a0a0a0;

    /* Fog of war (matches wall tile color) */
    --dex-color-fog: #4a90d9;

    /* UI colors */
    --dex-color-bg: #2a2a2a;
    --dex-color-panel: #3a3a3a;
    --dex-color-panel-light: #4a4a4a;
    --dex-color-text: #e0e0e0;
    --dex-color-text-muted: #a0a0a0;
    --dex-color-accent: #4a90d9;
    --dex-color-accent-hover: #5aa0e9;
    --dex-color-border: #555;
    --dex-color-success: #4caf50;
    --dex-color-danger: #f44336;
    --dex-color-warning: #ff9800;

    /* PC marker color */
    --dex-color-pc: #e53935;

    /* Dimensions */
    --dex-panel-width: 280px;
}

/* App Container */
.dex-app-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--dex-color-bg);
    color: var(--dex-color-text);
    border-radius: 8px;
    overflow: visible;
    margin: 20px 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.dex-app-container *,
.dex-app-container *::before,
.dex-app-container *::after {
    box-sizing: border-box;
}

/* Accessibility - Focus States */
.dex-app-container button:focus-visible,
.dex-app-container select:focus-visible,
.dex-app-container input:focus-visible,
.dex-app-container textarea:focus-visible,
.dex-app-container [tabindex]:focus-visible {
    outline: 2px solid var(--dex-color-accent);
    outline-offset: 2px;
}

/* First-time Hint Banner */
.dex-hint-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: linear-gradient(135deg, rgba(74, 144, 217, 0.15) 0%, rgba(74, 144, 217, 0.05) 100%);
    border-left: 4px solid var(--dex-color-accent);
    border-radius: 0 4px 4px 0;
    margin: 0 0 1px 0;
}

.dex-hint-banner.hidden {
    display: none;
}

.dex-hint-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.dex-hint-text {
    flex: 1;
    font-size: 0.85rem;
    color: var(--dex-color-text);
    line-height: 1.4;
}

.dex-hint-text strong {
    color: var(--dex-color-accent);
}

.dex-hint-dismiss {
    background: none;
    border: none;
    color: var(--dex-color-text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.dex-hint-dismiss:hover {
    opacity: 1;
    color: var(--dex-color-text);
}

/* Main Content Layout */
.dex-main-content {
    display: flex;
    min-height: 700px;
    max-height: 90vh;
    position: relative;
}

/* Explorer Area (Center) */
.dex-explorer-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background-color: var(--dex-color-bg);
    min-width: 0;
    overflow: auto;
}

/* Toolbar */
.dex-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px 15px;
    background-color: var(--dex-color-panel);
    border-radius: 4px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
}

.dex-tool-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dex-tool-group::after {
    content: '';
    width: 1px;
    height: 30px;
    background-color: var(--dex-color-border);
    margin: 0 8px;
}

.dex-tool-group:last-child::after {
    display: none;
}

.dex-tool-group-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--dex-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Canvas Wrapper */
.dex-canvas-wrapper {
    position: relative;
    background-color: var(--dex-color-fog);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    line-height: 0;
    overflow: hidden;
    width: 100%;
    height: calc(90vh - 150px);
    min-height: 400px;
}

#dex-map-canvas {
    display: block;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

/* Explorer Info Bar */
.dex-explorer-info {
    margin-top: 15px;
    display: flex;
    gap: 20px;
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    flex-wrap: wrap;
    justify-content: center;
}

.dex-rooms-explored {
    color: var(--dex-color-success);
    font-weight: 600;
}

/* Control Panel (Right) */
.dex-control-panel {
    width: var(--dex-panel-width);
    background-color: var(--dex-color-panel);
    border-left: 1px solid var(--dex-color-border);
    padding: 15px;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 90vh;
}

.dex-panel-section {
    margin-bottom: 20px;
}

.dex-panel-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--dex-color-text-muted);
    margin: 0 0 12px 0;
    padding: 0 0 8px 0;
    border-bottom: 1px solid var(--dex-color-border);
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Form Elements */
.dex-form-group {
    margin-bottom: 12px;
}

.dex-form-group label {
    display: block;
    font-size: 0.8rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 4px;
}

.dex-select {
    width: 100%;
    padding: 8px 10px;
    background-color: var(--dex-color-panel-light);
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    color: var(--dex-color-text);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
}

.dex-select:focus {
    outline: none;
    border-color: var(--dex-color-accent);
}

.dex-select option {
    background-color: var(--dex-color-panel);
    color: var(--dex-color-text);
}

/* Action Buttons */
.dex-action-btn {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background-color: var(--dex-color-panel-light);
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    color: var(--dex-color-text);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

.dex-action-btn:hover {
    background-color: var(--dex-color-accent);
    border-color: var(--dex-color-accent);
}

.dex-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.dex-action-btn.dex-small-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    width: auto;
}

.dex-action-btn.dex-danger-btn {
    background-color: var(--dex-color-danger);
    border-color: var(--dex-color-danger);
}

.dex-action-btn.dex-danger-btn:hover:not(:disabled) {
    background-color: #d32f2f;
    border-color: #d32f2f;
}

.dex-action-btn.dex-success-btn {
    background-color: var(--dex-color-success);
    border-color: var(--dex-color-success);
}

.dex-action-btn.dex-success-btn:hover:not(:disabled) {
    background-color: #43a047;
    border-color: #43a047;
}

.dex-action-btn.dex-warning-btn {
    background-color: var(--dex-color-warning);
    border-color: var(--dex-color-warning);
    color: #000;
}

.dex-action-btn.dex-warning-btn:hover:not(:disabled) {
    background-color: #f57c00;
    border-color: #f57c00;
}

/* ==========================================
   Standardized Button System
   Pattern: .dex-btn-{variant}
   ========================================== */

/* Primary Button - Main actions (blue) */
.dex-btn-primary,
.dex-action-btn.dex-btn-primary {
    background-color: var(--dex-color-accent);
    border-color: var(--dex-color-accent);
    color: #fff;
}

.dex-btn-primary:hover:not(:disabled),
.dex-action-btn.dex-btn-primary:hover:not(:disabled) {
    background-color: var(--dex-color-accent-hover);
    border-color: var(--dex-color-accent-hover);
}

/* Success Button - Positive actions (green) */
.dex-btn-success,
.dex-action-btn.dex-success-btn {
    background-color: var(--dex-color-success);
    border-color: var(--dex-color-success);
    color: #fff;
}

.dex-btn-success:hover:not(:disabled),
.dex-action-btn.dex-success-btn:hover:not(:disabled) {
    background-color: #43a047;
    border-color: #43a047;
}

/* Danger Button - Destructive actions (red) */
.dex-btn-danger,
.dex-action-btn.dex-danger-btn {
    background-color: var(--dex-color-danger);
    border-color: var(--dex-color-danger);
    color: #fff;
}

.dex-btn-danger:hover:not(:disabled),
.dex-action-btn.dex-danger-btn:hover:not(:disabled) {
    background-color: #d32f2f;
    border-color: #d32f2f;
}

/* Warning Button - Caution actions (orange) */
.dex-btn-warning,
.dex-action-btn.dex-btn-warning {
    background-color: var(--dex-color-warning);
    border-color: var(--dex-color-warning);
    color: #000;
}

.dex-btn-warning:hover:not(:disabled),
.dex-action-btn.dex-btn-warning:hover:not(:disabled) {
    background-color: #f57c00;
    border-color: #f57c00;
}

/* Small Button Variant */
.dex-btn-small,
.dex-action-btn.dex-small-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
    width: auto;
}

/* Secondary Button - Less prominent actions */
.dex-btn-secondary,
.dex-action-btn.dex-btn-secondary {
    background-color: transparent;
    border-color: var(--dex-color-border);
    color: var(--dex-color-text);
}

.dex-btn-secondary:hover:not(:disabled),
.dex-action-btn.dex-btn-secondary:hover:not(:disabled) {
    background-color: var(--dex-color-panel-light);
    border-color: var(--dex-color-text-muted);
}

/* Exploration Status */
.dex-status-box {
    background-color: var(--dex-color-panel-light);
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.dex-status-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.dex-status-row:last-child {
    margin-bottom: 0;
}

.dex-status-label {
    color: var(--dex-color-text-muted);
}

.dex-status-value {
    font-weight: 600;
    color: var(--dex-color-text);
}

.dex-status-value.explored {
    color: var(--dex-color-success);
}

.dex-status-value.pc-location {
    color: var(--dex-color-pc);
}

/* Exit Markers Legend */
.dex-legend {
    background-color: var(--dex-color-panel-light);
    border-radius: 4px;
    padding: 10px;
    margin-top: 10px;
}

.dex-legend-title {
    font-size: 0.75rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dex-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.dex-legend-item:last-child {
    margin-bottom: 0;
}

.dex-legend-marker {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.dex-legend-marker.exit-marker {
    color: var(--dex-color-warning);
}

.dex-legend-marker.pc-marker {
    color: var(--dex-color-pc);
}

/* Exit Point Markers */
.dex-exit-marker {
    position: absolute;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
}

.dex-exit-marker:hover {
    transform: scale(1.3);
}

.dex-exit-marker.clickable {
    animation: dex-pulse 2s infinite;
}

@keyframes dex-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* PC Marker */
.dex-pc-marker {
    font-size: 1.5rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

/* Room explored animation */
@keyframes dex-reveal {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.dex-room-revealed {
    animation: dex-reveal 0.5s ease-out;
}

/* Modal Styles - Theme matching */
.dex-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 100000;
    align-items: center;
    justify-content: center;
}

.dex-modal.active {
    display: flex;
}

.dex-modal-content {
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, var(--blue-dark, #1a3a5c) 0%, var(--blue-darker, #0f2847) 100%);
    border: 2px solid var(--gold, #d4a84b);
    border-radius: 8px;
}

.dex-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(90deg, var(--blue-primary, #1e4d8c) 0%, var(--blue-dark, #1a3a5c) 100%);
    border-bottom: 2px solid var(--gold, #d4a84b);
}

.dex-modal-header h2 {
    font-family: var(--font-heading, 'Cinzel', serif);
    font-size: 1.4rem;
    color: var(--cream, #f5f0e1);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    margin: 0;
    padding: 0;
}

.dex-modal-close {
    background: none;
    border: none;
    color: var(--cream, #f5f0e1);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.dex-modal-close:hover {
    color: var(--gold, #d4a84b);
}

.dex-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.dex-room-section {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--gold-dark, rgba(184, 146, 47, 0.3));
}

.dex-room-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.dex-room-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dex-room-section-header h3 {
    font-family: var(--font-heading, 'Cinzel', serif);
    font-size: 1rem;
    color: var(--gold-light, #e8c36b);
    margin: 0;
    padding: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dex-room-text {
    font-family: var(--font-body, Georgia, serif);
    font-size: 0.95rem;
    color: var(--cream, #f5f0e1);
    line-height: 1.6;
    margin: 0;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    border-left: 3px solid var(--gold, #d4a84b);
}

/* Encounter section */
.dex-room-encounter-section {
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    padding: 15px;
    margin-left: -15px;
    margin-right: -15px;
    margin-bottom: 0;
    border-bottom: none;
    border: 1px solid var(--gold-dark, rgba(184, 146, 47, 0.3));
}

.dex-btn-reveal {
    width: 100%;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--blue-primary, #1e4d8c) 0%, var(--blue-dark, #1a3a5c) 100%);
    border: 2px solid var(--gold, #d4a84b);
    color: var(--cream, #f5f0e1);
    font-family: var(--font-heading, 'Cinzel', serif);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.dex-btn-reveal:hover {
    background: linear-gradient(135deg, var(--blue-medium, #2563a8) 0%, var(--blue-primary, #1e4d8c) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.dex-hidden {
    display: none !important;
}

/* Modal footer */
.dex-modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-top: 1px solid var(--gold-dark, rgba(184, 146, 47, 0.3));
}

.dex-btn {
    padding: 10px 20px;
    border: 1px solid var(--gold, #d4a84b);
    background-color: transparent;
    color: var(--gold-light, #e8c36b);
    font-family: var(--font-body, 'Crimson Text', Georgia, serif);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.dex-btn:hover {
    background-color: rgba(212, 168, 75, 0.2);
}

.dex-btn-primary {
    background: linear-gradient(135deg, var(--blue-primary, #1e4d8c) 0%, var(--blue-dark, #1a3a5c) 100%);
    color: var(--cream, #f5f0e1);
    border: 2px solid var(--gold, #d4a84b);
}

.dex-btn-primary:hover {
    background: linear-gradient(135deg, var(--blue-medium, #2563a8) 0%, var(--blue-primary, #1e4d8c) 100%);
}

/* Load Modal Grid */
.dex-load-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.dex-load-item {
    background-color: var(--dex-color-panel-light);
    border-radius: 4px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dex-load-item:hover {
    background-color: var(--dex-color-accent);
    transform: translateY(-2px);
}

.dex-load-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--dex-color-text);
}

.dex-load-item-date {
    font-size: 0.7rem;
    color: var(--dex-color-text-muted);
}

.dex-load-item-actions {
    display: flex;
    gap: 5px;
    margin-top: 10px;
}

.dex-load-item-btn {
    flex: 1;
    padding: 6px 10px;
    border: none;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.dex-load-item-btn-load {
    background-color: var(--dex-color-accent);
    color: white;
}

.dex-load-item-btn-load:hover {
    background-color: var(--dex-color-accent-hover);
}

/* Notifications */
.dex-notification {
    position: fixed;
    top: 50px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: #fff;
    font-weight: 500;
    z-index: 100001;
    animation: dex-slideIn 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.dex-notification-success {
    background-color: var(--dex-color-success);
}

.dex-notification-error {
    background-color: var(--dex-color-danger);
}

.dex-notification-info {
    background-color: #2196f3;
}

@keyframes dex-slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes dex-slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Empty/Loading Messages */
.dex-empty-message,
.dex-loading {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px;
    grid-column: 1 / -1;
}

/* Checkbox styling */
.dex-checkbox-group {
    margin-bottom: 8px;
}

.dex-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
}

.dex-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--dex-color-accent);
}

/* Scrollbar Styling */
.dex-app-container ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.dex-app-container ::-webkit-scrollbar-track {
    background: var(--dex-color-panel);
}

.dex-app-container ::-webkit-scrollbar-thumb {
    background: var(--dex-color-border);
    border-radius: 4px;
}

.dex-app-container ::-webkit-scrollbar-thumb:hover {
    background: var(--dex-color-text-muted);
}

/* ==========================================
   Mobile Optimization Styles
   ========================================== */

/* Mobile Panel Toggle Buttons */
.dex-mobile-toggle {
    display: none;
    position: fixed !important;
    z-index: 2147483647 !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background-color: #4a90d9 !important;
    border: none !important;
    color: white !important;
    font-size: 1.5rem !important;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
    transition: transform 0.2s ease, background-color 0.2s ease;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dex-mobile-toggle:hover {
    transform: scale(1.1);
    background-color: var(--dex-color-accent-hover);
}

.dex-mobile-toggle-panel {
    bottom: 80px;
    right: 16px;
}

/* Mobile Bottom Toolbar */
.dex-mobile-toolbar {
    display: none;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px !important;
    background-color: #3a3a3a !important;
    border-top: 1px solid #555 !important;
    padding: 8px 12px !important;
    z-index: 2147483646 !important;
    justify-content: space-around;
    align-items: center;
    gap: 4px;
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .dex-mobile-toolbar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        height: calc(64px + env(safe-area-inset-bottom));
    }
}

.dex-mobile-toolbar-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    height: 48px;
    padding: 4px 8px;
    background-color: transparent;
    border: none;
    border-radius: 8px;
    color: var(--dex-color-text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dex-mobile-toolbar-btn:hover,
.dex-mobile-toolbar-btn.active {
    background-color: rgba(74, 144, 217, 0.2);
    color: var(--dex-color-accent);
}

.dex-mobile-toolbar-btn .dex-tool-icon {
    font-size: 1.3rem;
    margin-bottom: 2px;
}

.dex-mobile-toolbar-btn .dex-tool-label {
    font-size: 0.6rem;
    margin-top: 0;
}

/* Mobile Zoom Controls */
.dex-mobile-zoom-controls {
    display: none;
    position: fixed !important;
    right: 16px !important;
    bottom: 140px !important;
    flex-direction: column;
    gap: 8px;
    z-index: 2147483645 !important;
}

.dex-mobile-zoom-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: var(--dex-color-panel);
    border: 1px solid var(--dex-color-border);
    color: var(--dex-color-text);
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.dex-mobile-zoom-btn:hover,
.dex-mobile-zoom-btn:active {
    background-color: var(--dex-color-accent);
    color: white;
}

.dex-mobile-zoom-level {
    text-align: center;
    font-size: 0.7rem;
    color: var(--dex-color-text-muted);
    background-color: var(--dex-color-panel);
    padding: 4px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile Panel Overlay */
.dex-mobile-overlay {
    display: none;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    z-index: 2147483640 !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.dex-mobile-overlay.active {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto;
}

/* Mobile Edge Swipe Peek Indicators */
.dex-swipe-indicator {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 80px;
    background: linear-gradient(to bottom, transparent, rgba(74, 144, 217, 0.6), transparent);
    border-radius: 3px;
    z-index: 2147483638;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.dex-swipe-indicator-left {
    left: 0;
    border-radius: 0 3px 3px 0;
}

.dex-swipe-indicator-right {
    right: 0;
    border-radius: 3px 0 0 3px;
}

.dex-swipe-indicator.visible {
    opacity: 1;
    animation: dex-peek-pulse 2s ease-in-out infinite;
}

@keyframes dex-peek-pulse {
    0%, 100% { opacity: 0.4; transform: translateY(-50%) scaleY(1); }
    50% { opacity: 0.8; transform: translateY(-50%) scaleY(1.1); }
}

/* Mobile Panel Close Button */
.dex-panel-close-btn {
    display: none;
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--dex-color-text);
    font-size: 1.2rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
}

.dex-panel-close-btn:hover,
.dex-panel-close-btn:active {
    background-color: rgba(229, 57, 53, 0.8);
    color: white;
    transform: scale(1.1);
}

/* Mobile Toolbar Separator */
.dex-toolbar-separator {
    display: none;
    width: 1px;
    height: 32px;
    background: linear-gradient(to bottom, transparent, rgba(255, 255, 255, 0.3), transparent);
    margin: 0 4px;
}

/* Mobile Navigation Menu Button */
.dex-mobile-nav-btn {
    display: none;
    position: fixed !important;
    top: 16px;
    left: 16px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: rgba(58, 58, 58, 0.95);
    border: 1px solid #555;
    color: white;
    font-size: 1.3rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
}

.dex-mobile-nav-btn:active {
    transform: scale(0.95);
    background-color: var(--dex-color-accent);
}

/* Mobile Navigation Menu */
.dex-mobile-nav-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    background-color: #2a2a2a;
    z-index: 2147483648;
    transform: translateX(-100%);
    pointer-events: none;
    transition: transform 0.3s ease;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    flex-direction: column;
    overflow-y: auto;
}

.dex-mobile-nav-menu.open {
    transform: translateX(0);
    pointer-events: auto;
}

.dex-mobile-nav-header {
    padding: 20px 16px;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dex-mobile-nav-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
}

.dex-mobile-nav-close {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #999;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dex-mobile-nav-close:active {
    background-color: rgba(255, 255, 255, 0.1);
}

.dex-mobile-nav-items {
    padding: 12px 0;
    flex: 1;
}

.dex-mobile-nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    color: #ccc;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.dex-mobile-nav-item:hover,
.dex-mobile-nav-item:active {
    background-color: rgba(74, 144, 217, 0.15);
    color: white;
    border-left-color: var(--dex-color-accent);
}

.dex-mobile-nav-item.active {
    background-color: rgba(74, 144, 217, 0.2);
    color: var(--dex-color-accent);
    border-left-color: var(--dex-color-accent);
}

.dex-mobile-nav-item-icon {
    font-size: 1.3rem;
    width: 28px;
    text-align: center;
}

.dex-mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 2147483647;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.dex-mobile-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Desktop Slide-Out Tab */
.dex-desktop-tab {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 144px;
    background-color: var(--dex-color-panel);
    border: 1px solid var(--dex-color-border);
    color: var(--dex-color-text);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    z-index: 1000;
    transition: background-color 0.2s ease, transform 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.dex-desktop-tab:hover {
    background-color: var(--dex-color-accent);
    color: white;
}

.dex-desktop-tab.active {
    background-color: var(--dex-color-accent);
    color: white;
}

.dex-desktop-tab-panel {
    right: 0;
    border-right: none;
    border-radius: 6px 0 0 6px;
}

.dex-desktop-tab-panel.panel-open {
    right: var(--dex-panel-width);
}

/* Desktop overlay - hidden */
.dex-desktop-overlay {
    display: none !important;
}

/* Desktop slide-out mode */
.dex-app-container.desktop-slide-mode .dex-main-content {
    display: block;
    position: relative;
}

.dex-app-container.desktop-slide-mode .dex-control-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--dex-panel-width);
    height: 100vh;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    border-left: 1px solid var(--dex-color-border);
    background-color: var(--dex-color-panel);
    overflow-y: auto;
}

.dex-app-container.desktop-slide-mode .dex-control-panel.panel-open {
    transform: translateX(0);
}

.dex-app-container.desktop-slide-mode .dex-explorer-area {
    width: 100%;
    padding: 20px 50px;
}

/* Responsive Design - Mobile */
@media screen and (max-width: 600px) {
    .dex-mobile-toggle {
        display: flex !important;
    }

    .dex-mobile-toolbar {
        display: flex !important;
    }

    .dex-mobile-zoom-controls {
        display: flex !important;
        left: 16px !important;
        right: auto !important;
    }

    /* Show new mobile navigation elements */
    .dex-swipe-indicator {
        display: block !important;
    }

    .dex-panel-close-btn {
        display: flex !important;
    }

    .dex-toolbar-separator {
        display: block !important;
    }

    .dex-mobile-nav-btn {
        display: flex !important;
    }

    .dex-mobile-nav-menu {
        display: flex !important;
    }

    .dex-mobile-nav-overlay {
        display: block !important;
    }

    .dex-toolbar {
        display: none !important;
    }

    .dex-control-panel {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        width: 85% !important;
        max-width: 320px !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: none !important;
        border-left: 1px solid var(--dex-color-border) !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s ease !important;
        z-index: 2147483641 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        background-color: #3a3a3a !important;
    }

    .dex-control-panel.mobile-open {
        transform: translateX(0) !important;
    }

    .dex-explorer-area {
        padding: 10px;
        padding-bottom: 74px;
        min-height: calc(100vh - 74px);
    }

    .dex-canvas-wrapper {
        max-height: calc(100vh - 120px);
    }

    .dex-action-btn {
        padding: 12px;
        min-height: 44px;
        font-size: 0.9rem;
    }

    .dex-select {
        padding: 10px 12px;
        min-height: 44px;
        font-size: 0.9rem;
    }

    .dex-checkbox {
        width: 24px;
        height: 24px;
    }

    .dex-modal-content {
        width: 95%;
        max-height: 90vh;
    }

    .dex-explorer-info {
        flex-direction: column;
        gap: 5px;
        text-align: center;
        font-size: 0.8rem;
    }
}

/* iOS Safe Area Support */
@supports (bottom: env(safe-area-inset-bottom)) {
    .dex-mobile-toggle-panel {
        bottom: calc(80px + env(safe-area-inset-bottom));
    }

    .dex-mobile-zoom-controls {
        bottom: calc(140px + env(safe-area-inset-bottom));
    }
}

/* ==========================================
   Dice Roller Slide-Out Panel Styles
   ========================================== */

/* Dice Roller Tab Button */
.dex-dice-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    background: linear-gradient(135deg, var(--dex-color-accent) 0%, #3a7bc8 100%);
    border: none;
    border-radius: 8px 0 0 8px;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px;
    z-index: 1000;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.dex-dice-tab:hover {
    width: 60px;
    background: linear-gradient(135deg, #5aa0e9 0%, var(--dex-color-accent) 100%);
}

.dex-dice-tab.active {
    right: 300px;
}

.dex-dice-tab-icon {
    font-size: 1.7rem;
    margin-bottom: 5px;
}

.dex-dice-tab-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    writing-mode: vertical-lr;
    text-orientation: mixed;
}

/* Dice Roller Slide-Out Panel */
.dex-dice-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--dex-color-panel);
    border-left: 2px solid var(--dex-color-accent);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
}

.dex-dice-panel.open {
    transform: translateX(0);
}

.dex-dice-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, var(--dex-color-accent) 0%, #3a7bc8 100%);
    border-bottom: 1px solid var(--dex-color-border);
}

.dex-dice-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dex-dice-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.dex-dice-panel-close:hover {
    opacity: 1;
}

.dex-dice-panel-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Dice Button Grid */
.dex-dice-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.dex-dice-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 10px;
    background-color: var(--dex-color-panel-light);
    border: 2px solid var(--dex-color-border);
    border-radius: 8px;
    color: var(--dex-color-text);
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    min-height: 50px;
}

.dex-dice-btn:hover {
    background-color: var(--dex-color-accent);
    border-color: var(--dex-color-accent);
    color: white;
    transform: scale(1.05);
}

.dex-dice-btn:active {
    transform: scale(0.95);
    background-color: #3a7bc8;
}

.dex-dice-btn-wide {
    grid-column: span 3;
}

/* Modifier Input */
.dex-dice-modifier {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.dex-dice-modifier label {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    white-space: nowrap;
}

.dex-input {
    width: 70px;
    padding: 8px 10px;
    background-color: var(--dex-color-panel-light);
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    color: var(--dex-color-text);
    font-size: 0.9rem;
    font-family: inherit;
    text-align: center;
}

.dex-input:focus {
    outline: none;
    border-color: var(--dex-color-accent);
}

/* Help Text - consistent across all modules */
.dex-help-text,
.dex-form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: var(--dex-color-text-muted);
    line-height: 1.4;
}

.dex-dice-modifier .dex-small-btn {
    margin-left: auto;
    padding: 8px 12px;
    font-size: 0.8rem;
}

/* Dice Result Display */
.dex-dice-result {
    background-color: var(--dex-color-panel-light);
    border: 1px solid var(--dex-color-border);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
    min-height: 80px;
}

.dex-dice-result-placeholder {
    color: var(--dex-color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 20px 0;
    font-size: 0.85rem;
}

.dex-dice-result-total {
    font-size: 2rem;
    font-weight: 700;
    color: var(--dex-color-success);
    text-align: center;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dex-dice-result-breakdown {
    font-size: 0.8rem;
    color: var(--dex-color-text-muted);
    text-align: center;
    line-height: 1.5;
}

.dex-dice-result-dice {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
    margin-top: 8px;
}

.dex-dice-result-die {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    background-color: var(--dex-color-panel);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--dex-color-text);
}

.dex-dice-result-die.max-roll {
    background-color: var(--dex-color-success);
    color: #fff;
}

.dex-dice-result-die.min-roll {
    background-color: var(--dex-color-danger);
    color: #fff;
}

.dex-dice-result-modifier {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 8px;
    background-color: var(--dex-color-warning);
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #000;
}

/* Roll animation */
@keyframes dex-roll-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes dex-roll-spin {
    0% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.05) rotate(5deg); }
    50% { transform: scale(1.1) rotate(0deg); }
    75% { transform: scale(1.05) rotate(-5deg); }
    100% { transform: scale(1) rotate(0deg); }
}

@keyframes dex-number-flash {
    0%, 100% { opacity: 1; color: var(--dex-color-text); }
    50% { opacity: 0.7; color: var(--dex-color-accent); }
}

.dex-dice-result-total.rolling {
    animation: dex-roll-bounce 0.15s ease-in-out 3;
}

.dex-dice-result-total.rolling-animation {
    animation: dex-roll-spin 0.1s ease-in-out infinite;
    color: var(--dex-color-accent);
}

.dex-dice-result-die.rolling-animation {
    animation: dex-number-flash 0.1s ease-in-out infinite;
}

/* Disabled dice buttons during roll */
.dex-dice-btn.disabled,
.dex-dice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Dice History */
.dex-dice-history {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    padding: 10px;
}

.dex-dice-history-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--dex-color-text-muted);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.dex-dice-history-list {
    max-height: 120px;
    overflow-y: auto;
}

.dex-dice-history-empty {
    color: var(--dex-color-text-muted);
    font-style: italic;
    font-size: 0.8rem;
    text-align: center;
    padding: 10px 0;
}

.dex-dice-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background-color: var(--dex-color-panel-light);
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.dex-dice-history-item:last-child {
    margin-bottom: 0;
}

.dex-dice-history-notation {
    color: var(--dex-color-text-muted);
}

.dex-dice-history-result {
    font-weight: 600;
    color: var(--dex-color-success);
}

/* Mobile Dice Roller Adjustments */
@media screen and (max-width: 600px) {
    .dex-dice-tab {
        top: auto;
        bottom: 140px;
        transform: none;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        right: 16px;
        padding: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .dex-dice-tab.active {
        right: 16px;
    }

    .dex-dice-tab-label {
        display: none;
    }

    .dex-dice-tab-icon {
        margin: 0;
        font-size: 1.5rem;
    }

    .dex-dice-panel {
        width: 100%;
        max-width: 320px;
    }

    .dex-dice-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .dex-dice-btn {
        min-height: 45px;
        padding: 12px 8px;
        font-size: 1rem;
    }

    .dex-dice-result-total {
        font-size: 1.6rem;
    }

    .dex-dice-modifier {
        flex-wrap: wrap;
    }

    .dex-dice-modifier .dex-small-btn {
        margin-left: 0;
        flex: 1;
    }
}

/* iOS Safe Area for dice tab */
@supports (bottom: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 600px) {
        .dex-dice-tab {
            bottom: calc(140px + env(safe-area-inset-bottom));
        }
    }
}

/* ==========================================
   Tokens Slide-Out Panel Styles (Left Side)
   ========================================== */

/* Tokens Tab Button */
.dex-tokens-tab {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
    border: none;
    border-radius: 0 8px 8px 0;
    color: white;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 10px;
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.dex-tokens-tab:hover {
    width: 60px;
    background: linear-gradient(135deg, #ef5350 0%, #e53935 100%);
}

.dex-tokens-tab.active {
    left: 300px;
}

.dex-tokens-tab-icon {
    font-size: 1.7rem;
    margin-bottom: 5px;
}

.dex-tokens-tab-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform: rotate(180deg);
}

/* Tokens Slide-Out Panel */
.dex-tokens-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 300px;
    height: 100vh;
    background-color: var(--dex-color-panel);
    border-right: 2px solid #e53935;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4);
}

.dex-tokens-panel.open {
    transform: translateX(0);
}

.dex-tokens-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
    border-bottom: 1px solid var(--dex-color-border);
}

.dex-tokens-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.dex-tokens-panel-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.dex-tokens-panel-close:hover {
    opacity: 1;
}

.dex-tokens-panel-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Token Sections */
.dex-tokens-section {
    margin-bottom: 20px;
}

.dex-tokens-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
    padding: 6px 10px;
    border-radius: 4px;
}

.dex-tokens-section-title.dex-tokens-red {
    background-color: rgba(229, 57, 53, 0.2);
    color: #ef5350;
}

.dex-tokens-section-title.dex-tokens-green {
    background-color: rgba(76, 175, 80, 0.2);
    color: #66bb6a;
}

/* Token Grid */
.dex-tokens-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

/* Individual Tokens */
.dex-token {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 700;
    cursor: grab;
    transition: all 0.15s ease;
    user-select: none;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dex-token:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.dex-token:active {
    cursor: grabbing;
    transform: scale(1.1);
}

.dex-token-red {
    background: linear-gradient(135deg, #e53935 0%, #c62828 100%);
    color: white;
}

.dex-token-green {
    background: linear-gradient(135deg, #4caf50 0%, #388e3c 100%);
    color: white;
}

/* Token being dragged */
.dex-token.dragging {
    opacity: 0.5;
}

/* Tokens Actions */
.dex-tokens-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--dex-color-border);
}

.dex-tokens-actions .dex-action-btn {
    width: 100%;
}

/* Tokens Help Text */
.dex-tokens-help {
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.dex-tokens-help p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--dex-color-text-muted);
    line-height: 1.4;
}

/* Mobile Tokens Adjustments */
@media screen and (max-width: 600px) {
    .dex-tokens-tab {
        top: auto;
        bottom: 200px;
        transform: none;
        width: 48px;
        height: 48px;
        border-radius: 50%;
        left: 16px;
        padding: 0;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .dex-tokens-tab.active {
        left: 16px;
    }

    .dex-tokens-tab-label {
        display: none;
    }

    .dex-tokens-tab-icon {
        margin: 0;
        font-size: 1.5rem;
        transform: none;
    }

    .dex-tokens-panel {
        width: 100%;
        max-width: 320px;
    }

    .dex-tokens-grid {
        grid-template-columns: repeat(5, 1fr);
        gap: 6px;
    }

    .dex-token {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }
}

/* iOS Safe Area for tokens tab */
@supports (bottom: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 600px) {
        .dex-tokens-tab {
            bottom: calc(200px + env(safe-area-inset-bottom));
        }
    }
}

/* ==========================================
   Custom Tokens Styles
   ========================================== */

.dex-custom-tokens-section {
    border-top: 1px solid var(--dex-color-border);
    padding-top: 15px;
}

.dex-tokens-section-title.dex-tokens-custom {
    background-color: rgba(100, 149, 237, 0.2);
    color: #6495ed;
}

.dex-custom-tokens-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    min-height: 50px;
}

.dex-custom-tokens-empty {
    grid-column: span 4;
    text-align: center;
    color: var(--dex-color-text-muted);
    font-size: 0.8rem;
    font-style: italic;
    padding: 15px 0;
}

.dex-custom-token-item {
    position: relative;
}

.dex-custom-token {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    cursor: grab;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: all 0.15s ease;
    background: linear-gradient(135deg, #7986cb 0%, #3f51b5 100%);
}

.dex-custom-token img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dex-custom-token:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.dex-custom-token:active {
    cursor: grabbing;
}

.dex-custom-token.dragging {
    opacity: 0.5;
}

.dex-custom-token-delete {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--dex-color-danger);
    color: white;
    border: none;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dex-custom-token-item:hover .dex-custom-token-delete {
    opacity: 1;
}

.dex-custom-token-delete:hover {
    background-color: #f44336;
}

.dex-custom-token-upload {
    margin-top: 10px;
}

.dex-custom-token-upload .dex-action-btn {
    width: 100%;
    background: linear-gradient(135deg, #7986cb 0%, #5c6bc0 100%);
    border-color: #5c6bc0;
}

.dex-custom-token-upload .dex-action-btn:hover {
    background: linear-gradient(135deg, #9fa8da 0%, #7986cb 100%);
}

.dex-custom-tokens-login-notice {
    margin-top: 10px;
    padding: 10px;
    background-color: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    border-radius: 4px;
}

.dex-custom-tokens-login-notice p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--dex-color-warning);
    text-align: center;
}

/* Mobile adjustments for custom tokens */
@media screen and (max-width: 600px) {
    .dex-custom-tokens-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
    }

    .dex-custom-token {
        width: 45px;
        height: 45px;
    }
}

/* ==========================================
   Custom Token Upload Modal
   ========================================== */

.dex-token-upload-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.dex-token-upload-modal.open {
    display: flex;
}

.dex-token-upload-modal-content {
    background-color: var(--dex-color-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.dex-token-upload-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #7986cb 0%, #5c6bc0 100%);
    color: white;
}

.dex-token-upload-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.dex-token-upload-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.dex-token-upload-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.dex-token-upload-modal-body {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.dex-token-upload-preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.dex-token-upload-preview {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: width 0.2s ease, height 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #7986cb 0%, #3f51b5 100%);
}

.dex-token-upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dex-token-upload-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dex-token-upload-name label,
.dex-token-upload-size label {
    display: block;
    font-size: 0.9rem;
    color: var(--dex-color-text);
    margin-bottom: 5px;
}

.dex-token-upload-name .dex-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    background-color: var(--dex-color-bg-panel);
    color: var(--dex-color-text);
    font-size: 0.9rem;
}

.dex-token-upload-size input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--dex-color-border);
    border-radius: 4px;
    outline: none;
}

.dex-token-upload-size input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #7986cb 0%, #5c6bc0 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dex-token-upload-size input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #7986cb 0%, #5c6bc0 100%);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.dex-token-upload-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px 20px;
    background-color: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--dex-color-border);
}

.dex-token-upload-modal-footer .dex-secondary-btn {
    background-color: transparent;
    border: 1px solid var(--dex-color-border);
    color: var(--dex-color-text);
}

.dex-token-upload-modal-footer .dex-secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dex-token-upload-modal-footer .dex-primary-btn {
    background: linear-gradient(135deg, #7986cb 0%, #5c6bc0 100%);
    border: none;
    color: white;
}

.dex-token-upload-modal-footer .dex-primary-btn:hover {
    background: linear-gradient(135deg, #9fa8da 0%, #7986cb 100%);
}

/* Mobile adjustments for modal */
@media screen and (max-width: 600px) {
    .dex-token-upload-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .dex-token-upload-modal-header {
        padding: 12px 15px;
    }

    .dex-token-upload-modal-body {
        padding: 15px;
    }

    .dex-token-upload-modal-footer {
        padding: 12px 15px;
    }
}

/* ==========================================
   Share Session Styles
   ========================================== */

/* Share Section */
.dex-share-section {
    border-top: 1px solid var(--dex-color-border);
    margin-top: 10px;
    padding-top: 10px;
}

.dex-share-help {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 10px;
}

.dex-share-inactive,
.dex-share-active {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dex-share-link-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.dex-share-link-container label {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
}

.dex-share-link-container .dex-input {
    width: 100%;
    padding: 8px 10px;
    font-size: 0.8rem;
    background-color: var(--dex-color-bg);
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    color: var(--dex-color-text);
}

.dex-share-link-container .dex-input:focus {
    outline: none;
    border-color: var(--dex-color-accent);
}

/* Viewers List */
.dex-share-viewers {
    margin-top: 10px;
}

.dex-share-viewers > label {
    display: block;
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 5px;
}

.dex-viewers-list {
    background-color: var(--dex-color-bg);
    border: 1px solid var(--dex-color-border);
    border-radius: 4px;
    padding: 8px;
    max-height: 120px;
    overflow-y: auto;
}

.dex-no-viewers {
    font-size: 0.8rem;
    color: var(--dex-color-text-muted);
    font-style: italic;
    text-align: center;
    padding: 5px;
}

.dex-viewer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 8px;
    background-color: var(--dex-color-panel-light);
    border-radius: 3px;
    margin-bottom: 4px;
}

.dex-viewer-item:last-child {
    margin-bottom: 0;
}

.dex-viewer-name {
    font-size: 0.85rem;
    color: var(--dex-color-text);
}

.dex-viewer-tokens-count {
    font-size: 0.75rem;
    color: var(--dex-color-accent);
    background-color: rgba(74, 144, 217, 0.2);
    padding: 2px 6px;
    border-radius: 10px;
}

/* Viewer Section */
.dex-viewer-section {
    border-top: 1px solid var(--dex-color-border);
    margin-top: 10px;
    padding-top: 10px;
}

.dex-viewer-info p {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 10px;
}

.dex-viewer-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 15px;
}

.dex-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.dex-status-connected {
    background-color: var(--dex-color-success);
}

.dex-status-disconnected {
    background-color: var(--dex-color-danger);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

#dex-connection-status {
    font-size: 0.85rem;
    color: var(--dex-color-text);
}

/* Assigned Tokens */
.dex-viewer-tokens label {
    display: block;
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    margin-bottom: 5px;
}

.dex-assigned-tokens {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.dex-no-tokens {
    font-size: 0.8rem;
    color: var(--dex-color-text-muted);
    font-style: italic;
}

.dex-assigned-token {
    background-color: var(--dex-color-accent);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
}

/* Join Modal */
.dex-modal-small .dex-modal-content {
    max-width: 400px;
}

.dex-join-info {
    font-size: 0.85rem;
    color: var(--dex-color-text-muted);
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(74, 144, 217, 0.1);
    border-radius: 4px;
    border-left: 3px solid var(--dex-color-accent);
}

/* Token Assignment Modal */
.dex-token-preview {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    margin-bottom: 15px;
    background-color: var(--dex-color-bg);
    border-radius: 4px;
    min-height: 60px;
}

/* Primary Button */
.dex-primary-btn {
    background: linear-gradient(135deg, var(--dex-color-accent) 0%, #3a7bc8 100%);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.dex-primary-btn:hover {
    background: linear-gradient(135deg, var(--dex-color-accent-hover) 0%, #4a90d9 100%);
}

.dex-primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Secondary Button */
.dex-secondary-btn {
    background-color: transparent;
    border: 1px solid var(--dex-color-border);
    color: var(--dex-color-text);
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.dex-secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Danger Button */
.dex-danger-btn {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.dex-danger-btn:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
}

/* Modal footer spacer for button alignment */
.dex-modal-footer-spacer {
    flex: 1;
}

/* Disabled state for viewer mode */
.dex-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

/* Token ownership indicators on canvas */
.dex-token-owned {
    box-shadow: 0 0 0 3px var(--dex-color-success);
}

.dex-token-viewer-owned {
    box-shadow: 0 0 0 3px #2196f3;
}

.dex-token-locked {
    position: relative;
}

.dex-token-locked::after {
    content: '🔒';
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 10px;
}

/* Mobile adjustments */
@media screen and (max-width: 600px) {
    .dex-share-section {
        padding: 10px;
    }

    .dex-viewers-list {
        max-height: 80px;
    }

    .dex-viewer-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
