/* D&D Physics Dice Roller - Main Styles */

body {
    font-family: 'Inter', sans-serif;
    overscroll-behavior: none;
}

.font-medieval {
    font-family: 'MedievalSharp', cursive;
}

#dice-box {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
}

#settings-popup {
    display: none;
    z-index: 50;
}

#saved-roll-dialog {
    z-index: 60;
    display: none;
}

#result-display {
    z-index: 10;
}

#saved-roll-dialog.show {
    display: flex !important;
}

#controls {
    flex-shrink: 0;
}

/* Default (Desktop) styles */
#mobile-ui, #mobile-buttons {
    display: none;
}

/* Mobile specific styles */
@media (max-width: 767px) {
    #app {
        flex-direction: column;
    }
    #scene-container {
        height: 55vh;
        flex-grow: 0;
    }
    #dice-display-container {
        flex-grow: 0.70;
    }
    #controls {
        display: none;
    }
    #settings-btn {
        display: none;
    }
    #mobile-ui, #mobile-buttons {
        display: block;
    }
}

.dice-selector-bar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: min(0.8vw, 0.2rem);
    padding: min(1.5vw, 0.375rem);
    background-color: #1a202c;
    overflow-x: hidden;
}

.die-button {
    background-color: #4a5568;
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: min(1.2vw, 0.3rem);
    font-size: min(2.8vw, 0.7rem);
    font-family: 'MedievalSharp', cursive;
    cursor: pointer;
    min-width: min(7vw, 1.75rem);
    flex: 1 1 auto;
    text-align: center;
    white-space: nowrap;
    position: relative;
}

.die-button.active {
    background-color: #f59e0b;
}

.die-button.has-quantity::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    border: 1px solid #1a202c;
    z-index: 1;
}

.mobile-controls {
    padding: min(4vw, 1rem);
    background-color: #1a202c;
}

.mobile-config {
    display: none;
    padding: min(1.5vw, 0.375rem) min(2vw, 0.5rem);
    background-color: #2d3748;
    border-radius: 0.375rem;
    margin-bottom: min(1vw, 0.25rem);
}

.mobile-config.active {
    display: block;
}

.mobile-modifier-btn, .mobile-quantity-btn {
    background: #374151 !important;
    color: white !important;
    border: none !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.mobile-modifier-btn:hover, .mobile-quantity-btn:hover {
    background: #4b5563 !important;
}

.mobile-modifier-btn:active, .mobile-quantity-btn:active {
    background: #6b7280 !important;
}

.mobile-quantity-btn.disabled {
    background: #1f2937 !important;
    color: #6b7280 !important;
    cursor: not-allowed !important;
}

.mobile-quantity-btn.disabled:hover {
    background: #1f2937 !important;
}

/* Enhanced Mobile Responsive Styles */
@media (max-width: 767px) {
    /* Mobile UI header responsive */
    #mobile-ui .flex {
        padding: min(1vw, 0.25rem) min(2vw, 0.5rem);
    }
    
    /* Mobile UI title responsive */
    #mobile-ui h1 {
        font-size: min(6vw, 1.5rem) !important;
    }
    
    /* Mobile buttons responsive */
    #mobile-ui button {
        font-size: min(4vw, 1rem) !important;
        padding: min(2vw, 0.5rem) min(3vw, 0.75rem) !important;
    }
    
    /* Mobile config inputs responsive */
    .mobile-config input[type="number"] {
        width: min(12vw, 3rem);
        padding: min(1vw, 0.25rem);
        font-size: min(4vw, 0.875rem);
    }
    
    /* Mobile config labels responsive */
    .mobile-config label {
        font-size: min(4vw, 0.875rem);
        margin-bottom: 0;
        display: inline;
    }
    
    /* Mobile roll buttons responsive */
    #roll-btn-mobile, #clear-btn-mobile {
        font-size: min(5vw, 1.125rem) !important;
        padding: min(3vw, 0.75rem) min(6vw, 1.5rem) !important;
        border-radius: min(2vw, 0.5rem) !important;
    }
    
    /* Mobile header buttons responsive */
    #mobile-ui .flex button {
        font-size: min(3vw, 0.75rem) !important;
        /* padding: min(1vw, 0.25rem) !important; */
        white-space: nowrap;
    }
    
    /* Force dice selector to stay on one line on mobile */
    .dice-selector-bar {
        flex-wrap: nowrap !important;
        gap: min(0.5vw, 0.15rem) !important;
        padding: min(1vw, 0.25rem) !important;
    }
    
    .die-button {
        padding: min(1vw, 0.25rem) !important;
        font-size: min(2.5vw, 0.65rem) !important;
        min-width: min(6vw, 1.5rem) !important;
        flex: 1 1 0 !important;
    }
    
    /* Mobile total result display - much smaller */
    #result-display {
        padding: min(2vw, 0.5rem) !important;
        bottom: min(2vw, 0.5rem) !important;
        left: min(2vw, 0.5rem) !important;
        right: min(2vw, 0.5rem) !important;
        z-index: 10;
    }
    
    #total-result {
        font-size: min(8vw, 2rem) !important;
        line-height: 1 !important;
    }
    
    #total-breakdown {
        font-size: min(3vw, 0.75rem) !important;
        margin-top: min(1vw, 0.25rem) !important;
    }
    
    #result-display .text-gray-300 {
        font-size: min(3vw, 0.75rem) !important;
        margin-bottom: min(1vw, 0.25rem) !important;
    }
    
    /* Saved rolls mobile panel responsive */
    #saved-rolls-mobile-panel .bg-gray-800 {
        margin: min(4vw, 1rem);
        border-radius: min(2vw, 0.5rem);
    }
    
    #saved-rolls-mobile-panel h2 {
        font-size: min(6vw, 1.5rem) !important;
        margin-bottom: min(4vw, 1rem) !important;
    }
    
    #saved-rolls-mobile-panel button {
        font-size: min(4vw, 1rem) !important;
        padding: min(2vw, 0.5rem) min(4vw, 1rem) !important;
    }
    
    /* Mobile config container responsive */
    #mobile-config-container {
        padding: 0;
        margin: min(1vw, 0.25rem) min(2vw, 0.5rem);
    }
    
    /* Ensure dice buttons don't get too small */
    .die-button {
        min-height: min(10vw, 2.5rem);
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Quantity indicator for small mobile screens */
    .die-button.has-quantity::after {
        width: min(3vw, 10px);
        height: min(3vw, 10px);
        top: min(0.8vw, 3px);
        right: min(0.8vw, 3px);
        border-width: 1px;
    }
    
    /* Mobile modifier and quantity buttons on small screens */
    .mobile-modifier-btn, .mobile-quantity-btn {
        width: min(5vw, 20px) !important;
        height: min(6vw, 24px) !important;
        font-size: min(3vw, 12px) !important;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .dice-selector-bar {
        gap: min(1.5vw, 0.25rem);
        padding: min(3vw, 0.75rem);
    }
    
    .die-button {
        font-size: min(4vw, 1rem);
        padding: min(2vw, 0.5rem);
        min-width: min(10vw, 2.5rem);
    }
    
    /* Ensure quantity indicator is visible on very small screens */
    .die-button.has-quantity::after {
        width: min(2.5vw, 8px);
        height: min(2.5vw, 8px);
        top: min(0.5vw, 2px);
        right: min(0.5vw, 2px);
    }
}

/* Dice Box Size Slider Styles */
.slider {
    -webkit-appearance: none;
    appearance: none;
    background: #4a5568;
    outline: none;
    border-radius: 4px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    border: 2px solid #1a202c;
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #f59e0b;
    cursor: pointer;
    border: 2px solid #1a202c;
}

.slider:hover::-webkit-slider-thumb {
    background: #d97706;
}

.slider:hover::-moz-range-thumb {
    background: #d97706;
}

/* Mobile Dialog and Popup Responsive Styles */
@media (max-width: 767px) {
    /* Settings popup responsive */
    #settings-popup .bg-gray-800 {
        margin: min(2vw, 0.5rem);
        padding: min(4vw, 1rem) !important;
        border-radius: min(2vw, 0.5rem);
        max-height: 90vh;
        overflow-y: auto;
    }
    
    #settings-popup h2 {
        font-size: min(6vw, 1.5rem) !important;
        margin-bottom: min(4vw, 1rem) !important;
    }
    
    #settings-popup label {
        font-size: min(4vw, 0.875rem) !important;
    }
    
    #settings-popup input, #settings-popup select {
        font-size: min(4vw, 0.875rem) !important;
        padding: min(2vw, 0.5rem) !important;
    }
    
    #settings-popup button {
        font-size: min(4vw, 1rem) !important;
        padding: min(2vw, 0.5rem) min(4vw, 1rem) !important;
    }
    
    /* Saved roll dialog responsive */
    #saved-roll-dialog .bg-gray-800 {
        margin: min(2vw, 0.5rem);
        padding: min(3vw, 0.75rem) !important;
        border-radius: min(2vw, 0.5rem);
        max-height: 95vh;
        overflow-y: auto;
        max-width: 95vw;
    }
    
    /* Saved roll dialog dice grid mobile optimization */
    #saved-roll-dialog #saved-roll-dice {
        gap: min(2vw, 0.5rem) !important;
    }
    
    #saved-roll-dialog #saved-roll-dice .bg-gray-700 {
        padding: min(2vw, 0.5rem) !important;
        border-radius: min(1vw, 0.25rem);
    }
    
    #saved-roll-dialog h3 {
        font-size: min(6vw, 1.5rem) !important;
        margin-bottom: min(4vw, 1rem) !important;
    }
    
    #saved-roll-dialog label {
        font-size: min(4vw, 0.875rem) !important;
    }
    
    #saved-roll-dialog input[type="text"], 
    #saved-roll-dialog textarea,
    #saved-roll-dialog input[type="number"] {
        font-size: min(4vw, 0.875rem) !important;
        padding: min(2vw, 0.5rem) !important;
    }
    
    #saved-roll-dialog button {
        font-size: min(4vw, 1rem) !important;
        padding: min(2vw, 0.5rem) min(4vw, 1rem) !important;
    }
    
    /* Result display responsive */
    #result-display {
        bottom: min(2vw, 0.5rem) !important;
        left: min(2vw, 0.5rem) !important;
        right: min(2vw, 0.5rem) !important;
        padding: min(3vw, 0.75rem) !important;
        border-radius: min(2vw, 0.5rem) !important;
        z-index: 10;
    }
    
    #result-display h3 {
        font-size: min(5vw, 1.25rem) !important;
    }
    
    #total-result {
        font-size: min(8vw, 2rem) !important;
    }
}

/* === DICE MODE STYLES === */

/* Mode selector buttons */
.mode-btn, .mode-btn-mobile {
    transition: all 0.2s ease;
    cursor: pointer;
    user-select: none;
}

.mode-btn:hover, .mode-btn-mobile:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.mode-btn.active, .mode-btn-mobile.active {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* Dice display containers */
#dice-display-container {
    position: relative;
    overflow: hidden;
}

#image-container, #text-container {
    background: linear-gradient(135deg, #1f2937 0%, #374151 100%);
    overflow-y: auto;
}

/* Image mode styles */
#dice-images {
    animation: fadeIn 0.5s ease-in-out;
}

#dice-images > div {
    min-width: 100px;
    animation: slideIn 0.3s ease-out;
    background: linear-gradient(145deg, #374151, #4b5563);
    border: 2px solid #6b7280;
    transition: all 0.2s ease;
}

#dice-images > div:hover {
    transform: scale(1.05);
    border-color: #f59e0b;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.2);
}

/* Text mode styles */
#text-container {
    animation: fadeIn 0.5s ease-in-out;
    padding: 1rem;
}

/* Default desktop text sizing for text breakdown */
@media (min-width: 768px) {
    #text-dice-breakdown > div {
        font-size: 1.75rem;
        padding: 0.625rem;
        margin: 0.5rem 0;
        line-height: 1.4;
    }
}

#text-dice-breakdown > div {
    animation: slideInUp 0.3s ease-out;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: rgba(55, 65, 81, 0.3);
    border-radius: 0.5rem;
    border: 1px solid rgba(245, 158, 11, 0.2);
    text-align: left;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideIn {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.9);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes slideInUp {
    from { 
        opacity: 0;
        transform: translateY(10px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* SVG dice styling */
#dice-images svg {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: filter 0.2s ease;
}

#dice-images div:hover svg {
    filter: drop-shadow(0 4px 8px rgba(245, 158, 11, 0.3));
}

/* D20 Advantage/Disadvantage styling */
.advantage-selected {
    background: linear-gradient(145deg, #065f46, #10b981) !important;
    border-color: #10b981 !important;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.disadvantage-selected {
    background: linear-gradient(145deg, #7f1d1d, #ef4444) !important;
    border-color: #ef4444 !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
}

.dice-discarded {
    opacity: 0.4 !important;
    filter: grayscale(50%);
}

/* Pulse animation for selected dice */
@keyframes selectedPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.advantage-selected, .disadvantage-selected {
    animation: selectedPulse 2s ease-in-out;
}

/* === CRITICAL HIT & FAIL EFFECTS === */

/* Critical Hit (20) Effects */
@keyframes criticalHitGlow {
    0% { 
        box-shadow: 0 0 5px #10b981, 0 0 10px #10b981, 0 0 15px #10b981;
        transform: scale(1);
    }
    25% { 
        box-shadow: 0 0 10px #34d399, 0 0 20px #34d399, 0 0 30px #34d399;
        transform: scale(1.1);
    }
    50% { 
        box-shadow: 0 0 20px #6ee7b7, 0 0 40px #6ee7b7, 0 0 60px #6ee7b7;
        transform: scale(1.15);
    }
    75% { 
        box-shadow: 0 0 15px #34d399, 0 0 30px #34d399, 0 0 45px #34d399;
        transform: scale(1.1);
    }
    100% { 
        box-shadow: 0 0 5px #10b981, 0 0 10px #10b981, 0 0 15px #10b981;
        transform: scale(1);
    }
}

@keyframes criticalHitPulse {
    0% { background-color: #065f46; }
    50% { background-color: #059669; }
    100% { background-color: #065f46; }
}

@keyframes criticalHitSparkle {
    0% { opacity: 0; transform: rotate(0deg) scale(0); }
    50% { opacity: 1; transform: rotate(180deg) scale(1.2); }
    100% { opacity: 0; transform: rotate(360deg) scale(0); }
}

@keyframes criticalHitTextGlow {
    0% { 
        text-shadow: 0 0 5px #10b981, 0 0 10px #10b981;
        transform: scale(1);
    }
    50% { 
        text-shadow: 0 0 10px #34d399, 0 0 20px #34d399, 0 0 30px #6ee7b7;
        transform: scale(1.05);
    }
    100% { 
        text-shadow: 0 0 5px #10b981, 0 0 10px #10b981;
        transform: scale(1);
    }
}

/* Critical Fail (1) Effects */
@keyframes criticalFailShake {
    0% { transform: translateX(0); }
    10% { transform: translateX(-5px) rotate(-1deg); }
    20% { transform: translateX(5px) rotate(1deg); }
    30% { transform: translateX(-5px) rotate(-1deg); }
    40% { transform: translateX(5px) rotate(1deg); }
    50% { transform: translateX(-3px) rotate(-0.5deg); }
    60% { transform: translateX(3px) rotate(0.5deg); }
    70% { transform: translateX(-2px) rotate(-0.3deg); }
    80% { transform: translateX(2px) rotate(0.3deg); }
    90% { transform: translateX(-1px); }
    100% { transform: translateX(0); }
}

@keyframes criticalFailGlow {
    0% { 
        box-shadow: 0 0 5px #dc2626, 0 0 10px #dc2626, 0 0 15px #dc2626;
        background-color: #7f1d1d;
    }
    25% { 
        box-shadow: 0 0 10px #ef4444, 0 0 20px #ef4444, 0 0 30px #ef4444;
        background-color: #991b1b;
    }
    50% { 
        box-shadow: 0 0 20px #f87171, 0 0 40px #f87171, 0 0 60px #f87171;
        background-color: #b91c1c;
    }
    75% { 
        box-shadow: 0 0 15px #ef4444, 0 0 30px #ef4444, 0 0 45px #ef4444;
        background-color: #991b1b;
    }
    100% { 
        box-shadow: 0 0 5px #dc2626, 0 0 10px #dc2626, 0 0 15px #dc2626;
        background-color: #7f1d1d;
    }
}

@keyframes criticalFailTextShake {
    0% { transform: translateX(0); text-shadow: 0 0 5px #dc2626; }
    25% { transform: translateX(-3px); text-shadow: 0 0 10px #ef4444; }
    50% { transform: translateX(3px); text-shadow: 0 0 15px #f87171; }
    75% { transform: translateX(-2px); text-shadow: 0 0 10px #ef4444; }
    100% { transform: translateX(0); text-shadow: 0 0 5px #dc2626; }
}

@keyframes criticalFailFlash {
    0% { background-color: rgba(220, 38, 38, 0.1); }
    50% { background-color: rgba(220, 38, 38, 0.3); }
    100% { background-color: rgba(220, 38, 38, 0.1); }
}

/* Critical Effect Classes */
.critical-hit-dice {
    animation: criticalHitGlow 2s ease-in-out, criticalHitPulse 2s ease-in-out;
    position: relative;
    overflow: visible;
}

.critical-fail-dice {
    animation: criticalFailShake 1s ease-in-out, criticalFailGlow 2s ease-in-out;
}

.critical-hit-text {
    animation: criticalHitTextGlow 2s ease-in-out infinite;
    color: #10b981 !important;
    font-weight: bold;
}

.critical-fail-text {
    animation: criticalFailTextShake 1s ease-in-out, criticalFailFlash 2s ease-in-out;
    color: #dc2626 !important;
    font-weight: bold;
}

/* Sparkle effect for critical hits */
.critical-hit-dice::before,
.critical-hit-dice::after {
    content: '✨';
    position: absolute;
    font-size: 1.5rem;
    pointer-events: none;
    animation: criticalHitSparkle 2s ease-in-out infinite;
}

.critical-hit-dice::before {
    top: -10px;
    left: -10px;
    animation-delay: 0.3s;
}

.critical-hit-dice::after {
    bottom: -10px;
    right: -10px;
    animation-delay: 0.8s;
}

/* Screen flash effects for text mode */
@keyframes screenFlashGreen {
    0% { background-color: rgba(16, 185, 129, 0); }
    10% { background-color: rgba(16, 185, 129, 0.1); }
    20% { background-color: rgba(16, 185, 129, 0.05); }
    100% { background-color: rgba(16, 185, 129, 0); }
}

@keyframes screenFlashRed {
    0% { background-color: rgba(220, 38, 38, 0); }
    10% { background-color: rgba(220, 38, 38, 0.1); }
    20% { background-color: rgba(220, 38, 38, 0.05); }
    100% { background-color: rgba(220, 38, 38, 0); }
}

/* Apply screen flash to text container for critical results */
.critical-hit-screen {
    animation: screenFlashGreen 2s ease-out;
}

.critical-fail-screen {
    animation: screenFlashRed 2s ease-out;
}

/* Enhanced text effects */
.critical-hit-celebration {
    background: linear-gradient(45deg, #10b981, #34d399, #6ee7b7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: criticalHitTextGlow 2s ease-in-out infinite;
}

.critical-fail-warning {
    background: linear-gradient(45deg, #dc2626, #ef4444, #f87171);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: criticalFailTextShake 1s ease-in-out infinite;
}

/* === DICE SHAPE STYLES === */

.dice-shape {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px;
    min-width: 100px;
    /* Keep consistent square container for all dice types */
    border-radius: 8px;
    background: linear-gradient(135deg, #374151, #4b5563);
    border: 2px solid #6b7280;
}

/* All dice containers now use uniform square styling defined in .dice-shape */

/* Enhanced shadows and effects for dice shapes */
.dice-shape {
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.3),
        0 2px 4px -1px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: visible;
}

.dice-shape:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 
        0 8px 12px -2px rgba(0, 0, 0, 0.4),
        0 4px 8px -2px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    filter: brightness(1.1);
}

/* Adjust SVG positioning within shaped dice */
.dice-shape svg {
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.4));
}

/* Adjust label positioning for shaped dice */
.dice-shape .text-center {
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

/* Critical effects work with dice shapes */
.dice-shape.critical-hit-dice {
    animation: criticalHitGlow 2s ease-in-out, criticalHitPulse 2s ease-in-out;
    border-color: #10b981 !important;
}

.dice-shape.critical-fail-dice {
    animation: criticalFailShake 1s ease-in-out, criticalFailGlow 2s ease-in-out;
    border-color: #dc2626 !important;
}

/* Dynamic dice sizing based on number of dice */
.dice-size-small .dice-shape {
    min-width: 45px;
    min-height: 45px;
    padding: 0.25rem;
    margin: 0.125rem;
}

.dice-size-small svg {
    width: 28px;
    height: 28px;
}

.dice-size-medium .dice-shape {
    min-width: 60px;
    min-height: 60px;
    padding: 0.5rem;
    margin: 0.25rem;
}

.dice-size-medium svg {
    width: 35px;
    height: 35px;
}

.dice-size-large .dice-shape {
    min-width: 80px;
    min-height: 80px;
    padding: 0.75rem;
    margin: 0.5rem;
}

.dice-size-large svg {
    width: 50px;
    height: 50px;
}

.dice-size-xlarge .dice-shape {
    min-width: 100px;
    min-height: 100px;
    padding: 1rem;
    margin: 0.5rem;
}

.dice-size-xlarge svg {
    width: 65px;
    height: 65px;
}

/* Responsive adjustments for modes */
@media (max-width: 767px) {
    #dice-images {
        padding: 0.5rem;
        gap: 0.25rem;
        align-content: center;
    }
    
    /* Scale down all sizes for mobile */
    .dice-size-small .dice-shape { min-width: 35px; min-height: 35px; padding: 0.2rem; margin: 0.1rem; }
    .dice-size-small svg { width: 22px; height: 22px; }
    
    .dice-size-medium .dice-shape { min-width: 45px; min-height: 45px; padding: 0.3rem; margin: 0.15rem; }
    .dice-size-medium svg { width: 28px; height: 28px; }
    
    .dice-size-large .dice-shape { min-width: 55px; min-height: 55px; padding: 0.4rem; margin: 0.2rem; }
    .dice-size-large svg { width: 35px; height: 35px; }
    
    .dice-size-xlarge .dice-shape { min-width: 70px; min-height: 70px; padding: 0.5rem; margin: 0.25rem; }
    .dice-size-xlarge svg { width: 45px; height: 45px; }
}

/* Dynamic text sizing based on number of result lines */
.text-size-small {
    font-size: min(3vw, 0.75rem) !important;
    padding: min(1vw, 0.25rem) !important;
    margin: min(0.5vw, 0.125rem) 0 !important;
    line-height: 1.2 !important;
}

.text-size-medium {
    font-size: min(4vw, 1rem) !important;
    padding: min(1.5vw, 0.375rem) !important;
    margin: min(1vw, 0.25rem) 0 !important;
    line-height: 1.3 !important;
}

.text-size-large {
    font-size: min(5vw, 1.25rem) !important;
    padding: min(2vw, 0.5rem) !important;
    margin: min(1.5vw, 0.375rem) 0 !important;
    line-height: 1.4 !important;
}

.text-size-xlarge {
    font-size: min(6vw, 1.5rem) !important;
    padding: min(2.5vw, 0.625rem) !important;
    margin: min(2vw, 0.5rem) 0 !important;
    line-height: 1.5 !important;
}

/* Desktop text sizing overrides - larger and more readable for desktop */
@media (min-width: 768px) {
    .text-size-small { font-size: 1.125rem !important; padding: 0.375rem !important; margin: 0.25rem 0 !important; }
    .text-size-medium { font-size: 1.375rem !important; padding: 0.5rem !important; margin: 0.375rem 0 !important; }
    .text-size-large { font-size: 1.75rem !important; padding: 0.625rem !important; margin: 0.5rem 0 !important; }
    .text-size-xlarge { font-size: 2.25rem !important; padding: 0.875rem !important; margin: 0.625rem 0 !important; }
}

@media (max-width: 767px) {
    #text-container {
        padding: 0.5rem;
        max-height: 50vh;
        overflow-y: auto;
    }
    
    #text-dice-breakdown > div {
        font-size: min(4vw, 1rem);
        padding: min(2vw, 0.5rem);
        margin: min(1vw, 0.25rem) 0;
    }
    
    /* Ensure text results fit in viewport */
    #dice-text-results {
        max-width: 90vw;
    }
    
    /* Mobile advantage/disadvantage adjustments */
    .advantage-selected, .disadvantage-selected {
        animation-duration: 1.5s;
    }
    
    /* Mobile dice shapes */
    .dice-shape:hover {
        transform: translateY(-1px) scale(1.01);
    }
}