/* WOD Dice Roller - Standalone styles */
:root {
    --bg-primary: #0f0f12;
    --bg-secondary: #1a1a1f;
    --bg-tertiary: #252530;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --border-primary: rgba(255, 255, 255, 0.12);
    --color-primary: #8b5cf6;
    --color-primary-dark: #6d28d9;
    --color-accent: #8b5cf6;
    --color-white: #ffffff;
    --color-success: #22c55e;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    --color-gray-400: #6b7280;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.35);
}

/* Light theme */
body.theme-light {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef1f7;
    --text-primary: #1a1a24;
    --text-secondary: #5a5a6e;
    --border-primary: rgba(0, 0, 0, 0.1);
    --color-primary: #6d28d9;
    --color-primary-dark: #5b21b6;
    --color-accent: #7c3aed;
}

/* Dark theme (default) */
body.theme-dark {
    --bg-primary: #0f0f12;
    --bg-secondary: #1a1a1f;
    --bg-tertiary: #252530;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b0;
    --border-primary: rgba(255, 255, 255, 0.12);
    --color-primary: #8b5cf6;
    --color-primary-dark: #6d28d9;
    --color-accent: #8b5cf6;
}

/* Crimson theme */
body.theme-crimson {
    --bg-primary: #1a0f0f;
    --bg-secondary: #251515;
    --bg-tertiary: #351a1a;
    --text-primary: #ffe6e6;
    --text-secondary: #d4a4a4;
    --border-primary: rgba(248, 113, 113, 0.2);
    --color-primary: #f87171;
    --color-primary-dark: #dc2626;
    --color-accent: #f87171;
}

/* Noir theme */
body.theme-noir {
    --bg-primary: #0d0d10;
    --bg-secondary: #15151a;
    --bg-tertiary: #1e1e28;
    --text-primary: #e8e6ed;
    --text-secondary: #8a8899;
    --border-primary: rgba(148, 163, 184, 0.15);
    --color-primary: #94a3b8;
    --color-primary-dark: #64748b;
    --color-accent: #94a3b8;
}


* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Crimson Text', Georgia, 'Times New Roman', serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.app-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-top: 1.5rem;
}

.header-logo {
    max-height: 6rem;
    width: auto;
    object-fit: contain;
}

.theme-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.theme-selector select {
    font-family: inherit;
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
}

.theme-selector select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Custom dropdown (theme-styled, replaces native select) */
.custom-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
    max-width: 100%;
}

.custom-dropdown-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: inherit;
    text-align: left;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.custom-dropdown-trigger:hover {
    border-color: var(--color-primary);
    background: var(--bg-secondary);
}

.custom-dropdown-trigger:focus {
    outline: none;
    border-color: var(--color-primary);
}

.custom-dropdown-trigger:focus-visible {
    box-shadow: 0 0 0 2px var(--color-primary);
}

.custom-dropdown-label {
    flex: 1;
    text-align: left;
    min-width: 0;
}

.custom-dropdown-chevron {
    font-size: 0.6em;
    opacity: 0.8;
    transition: transform 0.2s ease;
}

.custom-dropdown.open .custom-dropdown-chevron {
    transform: rotate(180deg);
}

.custom-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 1000;
    max-height: 12rem;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
    display: none;
}

.custom-dropdown-menu.open {
    display: block;
}

.custom-dropdown-option {
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: inherit;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: background 0.15s ease;
}

.custom-dropdown-option:hover {
    background: var(--bg-tertiary);
}

.custom-dropdown-option.selected {
    background: var(--color-primary);
    color: var(--color-white);
}

.custom-dropdown-option.selected:hover {
    background: var(--color-primary-dark);
}

/* Theme selector dropdown (smaller) */
.theme-selector .custom-dropdown {
    width: auto;
    min-width: 7rem;
}

.theme-selector .custom-dropdown-trigger {
    padding: 0.35rem 0.75rem;
    font-size: 0.875rem;
}

.theme-selector .custom-dropdown-menu {
    min-width: 100%;
}

.app-subtitle {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.app-disclaimer {
    margin: 1.5rem 0 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    line-height: 1.4;
}

/* Legal section (Privacy Policy, Terms of Service) */
.legal-section {
    margin-top: 2rem;
    width: 100%;
    max-width: 600px;
    padding: 0 1rem;
}

.legal-dropdown {
    margin-bottom: 0.5rem;
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-md);
    background: var(--bg-secondary);
    overflow: hidden;
}

.legal-dropdown:last-child {
    margin-bottom: 0;
}

.legal-dropdown-trigger {
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background 0.2s ease;
}

.legal-dropdown-trigger::-webkit-details-marker {
    display: none;
}

.legal-dropdown-trigger::after {
    content: "▼";
    font-size: 0.65em;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.legal-dropdown[open] .legal-dropdown-trigger::after {
    transform: rotate(180deg);
}

.legal-dropdown-trigger:hover {
    background: var(--bg-tertiary);
}

.legal-dropdown-content {
    padding: 0 1rem 1rem;
    border-top: 1px solid var(--border-primary);
}

.legal-dropdown-content p {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
    text-align: left;
}

.legal-dropdown-content p:first-child {
    margin-top: 1rem;
}

.legal-dropdown-content a {
    color: var(--color-primary);
    text-decoration: none;
}

.legal-dropdown-content a:hover {
    text-decoration: underline;
}

.app-credits {
    margin: 0.75rem 0 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    opacity: 0.9;
}

.app-credits a {
    color: var(--color-primary);
    text-decoration: none;
}

.app-credits a:hover {
    text-decoration: underline;
}

.app-email {
    margin: 0.75rem 0 0;
    padding: 0 1rem;
    font-size: 1rem;
    color: var(--text-secondary);
    text-align: center;
    max-width: 600px;
    line-height: 1.5;
    opacity: 0.9;
}

.app-email a {
    color: var(--color-primary);
    text-decoration: none;
}

.app-email a:hover {
    text-decoration: underline;
}

.app-kofi {
    margin: 1.5rem 0 1.5rem;
    padding: 0 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.kofi-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: #72a4f2;
    color: #fff;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--border-radius-md);
    transition: opacity 0.2s, transform 0.2s;
}

.kofi-button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.kofi-button-icon {
    height: 20px;
    width: auto;
}

/* Dice Tray Panel */
.dice-tray-panel {
    width: 100%;
    max-width: 600px;
}

.floating-panel-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 24px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    overflow: hidden;
}

.dice-tray-panel-content {
    width: 100%;
}

.dice-tray-dashboard {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.dice-tray-left {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    width: 100%;
}

.dice-tray-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    max-width: 100%;
    align-items: center;
}

.control-group label {
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--text-primary);
    text-align: center;
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group select {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    margin: 0;
    width: 100%;
    max-width: 100%;
}

.control-group select {
    text-align: left;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 1rem;
    width: 100%;
}

.control-row-formula-difficulty {
    flex-wrap: wrap;
}

.control-row-formula-difficulty .control-group-flex:first-child {
    flex: 2;
    min-width: 140px;
}

.control-row-formula-difficulty .control-group-flex:not(:first-child) {
    flex: 1;
    min-width: 80px;
}

.control-row-formula-difficulty .control-group-flex-2 {
    flex: 2;
    min-width: 140px;
}

input[type="text"],
input[type="number"],
select {
    font-family: inherit;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-md);
    color: var(--text-primary);
    text-align: center;
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Checkbox grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    width: 100%;
}

.checkbox-grid-item-full {
    grid-column: 1 / -1;
}

/* Checkbox */
.checkbox-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.checkbox-option:hover {
    border-color: var(--color-primary);
    background: var(--bg-secondary);
}

.checkbox-option input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.checkbox-label {
    font-size: 0.875rem;
    color: var(--text-primary);
}

.control-group-flex .checkbox-option.checkbox-option-full-width {
    width: 100%;
    margin: 0;
}

/* Roll Button */
.control-group-roll .roll-btn {
    width: 100%;
}

.roll-btn {
    font-family: inherit;
    background: var(--color-accent);
    color: var(--color-white);
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    max-width: 100%;
}

.roll-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: var(--color-primary-dark);
}

.roll-btn .button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Long-press intensity */
.roll-trigger--intense {
    animation: roll-trigger-shake 0.12s ease-in-out infinite;
}

@keyframes roll-trigger-shake {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(-2px) translateY(-1px); }
    50% { transform: translateX(2px) translateY(1px); }
    75% { transform: translateX(-1px) translateY(2px); }
}

/* Full-screen 3D Dice Overlay */
.dice-3d-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.dice-3d-overlay.dice-3d-overlay--hidden {
    display: none !important;
    pointer-events: none !important;
}

.dice-3d-overlay .dice-3d-container {
    flex: 1;
    width: 100%;
    min-height: 0;
    position: relative;
}

.dice-3d-overlay .dice-2d-container {
    flex: 1;
    width: 100%;
    min-height: 0;
    display: none;
    flex-wrap: wrap;
    align-items: center;
    align-content: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem;
    position: relative;
    pointer-events: none;
}

.dice-3d-overlay .dice-2d-container .dice-result {
    pointer-events: none;
    margin: 0;
}

.dice-3d-overlay .dice-3d-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.dice-3d-overlay.dice-3d-overlay--2d .dice-2d-container {
    display: flex;
}

.dice-3d-overlay.dice-3d-overlay--2d .dice-3d-container {
    display: none;
}

.dice-results-popup {
    display: none;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    min-width: 12rem;
    max-width: 90vw;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    z-index: 2;
    text-align: center;
}

.dice-3d-overlay.dice-3d-overlay--results-above .dice-results-popup {
    top: 32%;
    transform: translate(-50%, -50%);
}

.dice-results-popup-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.dice-results-popup-values {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.dice-results-popup-values .dice-result-success {
    color: var(--color-success);
}

.dice-results-popup-values .dice-result-failure {
    color: var(--text-secondary);
}

.dice-results-popup-values .dice-result-botch {
    color: var(--color-danger);
    font-weight: 700;
}

.dice-results-popup-successes {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-success);
}

.dice-results-popup-successes.zero {
    color: var(--color-danger);
}

.dice-results-popup-successes.dice-results-popup-successes--botch {
    color: var(--color-danger);
    font-weight: 700;
}

.dice-difficulty-warning {
    font-size: 0.75rem;
    color: var(--color-danger);
    margin: 0.25rem 0 0;
    font-weight: 500;
}

.dice-results-popup-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.9;
}

.dice-results-popup-timestamp {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    opacity: 0.9;
}

.dice-3d-overlay .dice-3d-dismiss-hint {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.6);
    color: var(--text-primary);
    font-size: 0.875rem;
    border-radius: 4px;
    pointer-events: none;
}

/* Dice result chips */
.dice-result {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 0.875rem;
    margin: 0.25rem;
    border-radius: var(--border-radius-lg);
    font-weight: 700;
    font-size: 1.125rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    text-align: center;
    transition: all 0.3s ease;
    animation: rollIn 0.5s ease;
}

.dice-result.d6,
.dice-result.d10 {
    border-radius: 0.25rem;
    width: 3rem;
    height: 3rem;
    min-width: 3rem;
    min-height: 3rem;
    padding: 0;
}

.success {
    background: var(--color-success);
    color: var(--color-white);
    box-shadow: var(--shadow-md);
}

.failure {
    background: var(--color-gray-400);
    color: var(--color-white);
    box-shadow: var(--shadow-sm);
}

.botch {
    background: var(--color-danger);
    color: var(--color-white);
    box-shadow: var(--shadow-md);
}

/* Toast notifications */
.vtm-notification {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 10001;
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius-md);
    font-weight: 500;
    color: var(--color-white);
    box-shadow: var(--shadow-lg);
    animation: vtmSlideIn 0.3s ease;
}

.vtm-notification-error {
    background: var(--color-danger);
}

.vtm-notification-warning {
    background: var(--color-warning);
}

.vtm-notification-success {
    background: var(--color-success);
}

.vtm-notification-info {
    background: var(--color-info);
}

@keyframes vtmSlideIn {
    from { opacity: 0; transform: translateX(1rem); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes rollIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-container {
        padding: 1rem 0.75rem;
    }

    .dice-tray-panel {
        max-width: 100%;
    }

    .control-row-formula-difficulty .control-group-flex:first-child {
        flex: 1;
        min-width: 100px;
    }

    .control-row-formula-difficulty .control-group-flex:not(:first-child) {
        min-width: 70px;
    }

    .dice-3d-overlay.dice-3d-overlay--results-above .dice-results-popup {
        top: 18%;
    }

    .dice-3d-overlay.dice-3d-overlay--2d .dice-2d-container {
        margin-top: 0;
        padding-top: 3.5rem;
        overflow-y: auto;
        max-height: 50vh;
    }

    .dice-3d-overlay .dice-2d-container {
        padding: 1rem 1.5rem;
        gap: 0.5rem;
        max-width: min(24rem, 100%);
    }

    .dice-3d-overlay .dice-2d-container .dice-result.d6,
    .dice-3d-overlay .dice-2d-container .dice-result.d10 {
        width: 2.75rem;
        height: 2.75rem;
        min-width: 2.75rem;
        min-height: 2.75rem;
        font-size: 1rem;
    }
}
