/* ======================
   ADVANCED DICE ROLLER STYLES
   ====================== */

:root {
    --primary-color: #8b5cf6;
    --primary-dark: #7c3aed;
    --primary-light: #a78bfa;
    --secondary-color: #06b6d4;
    --accent-color: #f59e0b;
    --danger-color: #ef4444;
    --warning-color: #f97316;
    --success-color: #22c55e;
    --info-color: #3b82f6;
    
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-dark: #0f172a;
    
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.tool-page {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 2rem;
    align-items: start;
}

/* ======================
   PROFESSIONAL HEADER
   ====================== */
.tool-header {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, rgba(255,255,255,0.95) 0%, rgba(255,255,255,0.9) 100%);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255,255,255,0.2);
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-text h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.header-text h1 i {
    margin-right: 1rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tool-description {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 600px;
}

.header-stats {
    display: flex;
    gap: 2rem;
}

.stat-item {
    text-align: center;
    padding: 1rem;
    background: rgba(255,255,255,0.7);
    border-radius: var(--radius-lg);
    min-width: 100px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* ======================
   TEMPLATE SECTION
   ====================== */
.template-section {
    grid-column: 1 / -1;
    margin-bottom: 2rem;
}

.template-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-section h2 i {
    color: var(--accent-color);
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.template-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: var(--shadow-md);
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-xl);
    background: rgba(255,255,255,1);
}

.template-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.template-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.template-card p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ======================
   MAIN DICE CONTAINER
   ====================== */
.dice-container {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid rgba(255,255,255,0.2);
    overflow: hidden;
}

/* ======================
   TAB NAVIGATION
   ====================== */
.tab-navigation {
    display: flex;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(255,255,255,0.5);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-primary);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-btn i {
    font-size: 1.1rem;
}

/* ======================
   TAB CONTENT
   ====================== */
.tab-content {
    display: none;
    padding: 2rem;
}

.tab-content.active {
    display: block;
}

/* ======================
   DICE ROLLER MAIN
   ====================== */
.roller-main {
    display: grid;
    gap: 2rem;
}

.dice-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-with-buttons {
    display: flex;
    align-items: center;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    overflow: hidden;
}

.count-btn {
    padding: 0.75rem;
    border: none;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    width: 40px;
}

.count-btn:hover {
    background: var(--primary-dark);
}

#dice-count {
    flex: 1;
    padding: 0.75rem;
    border: none;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

#dice-count:focus {
    outline: none;
}

.control-group select,
.control-group input[type="number"]:not(#dice-count) {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.modifier-input {
    display: flex;
    gap: 0.5rem;
}

.modifier-input select {
    flex: 1;
}

.modifier-input input {
    width: 80px;
}

/* Roll Actions */
.roll-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.primary-btn {
    padding: 1rem 2rem;
    border: none;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--primary-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.secondary-btn:hover {
    background: var(--primary-color);
    color: white;
}

.danger-btn {
    padding: 0.75rem 1.5rem;
    border: 2px solid var(--danger-color);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--danger-color);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.danger-btn:hover {
    background: var(--danger-color);
    color: white;
}

/* ======================
   DICE DISPLAY AREA
   ====================== */
.dice-display-area {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.dice-display {
    min-height: 150px;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
}

.no-dice {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.no-dice i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Dice Styles */
.die {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.die:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

/* Dice Themes */
.die.classic {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.die.neon {
    background: linear-gradient(135deg, #ff006e, #8338ec);
    box-shadow: 0 0 20px rgba(255, 0, 110, 0.5);
}

.die.wood {
    background: linear-gradient(135deg, #8b4513, #a0522d);
    color: #f4e4bc;
}

.die.metal {
    background: linear-gradient(135deg, #4a5568, #2d3748);
    color: #e2e8f0;
    box-shadow: inset 0 2px 4px rgba(255,255,255,0.1);
}

/* Dice Animation */
@keyframes rollDice {
    0% { 
        transform: rotate(0deg) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 0.7;
    }
    100% { 
        transform: rotate(360deg) scale(1);
        opacity: 1;
    }
}

.die.rolling {
    animation: rollDice 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Roll Result */
.roll-result {
    text-align: center;
}

.result-main {
    margin-bottom: 1.5rem;
}

.result-label {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.result-value {
    font-size: 4rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.result-breakdown {
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.result-details {
    display: grid;
    gap: 0.75rem;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: var(--radius-md);
}

.detail-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* ======================
   QUICK ROLLS
   ====================== */
.quick-rolls {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
}

.quick-rolls h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.quick-rolls h3 i {
    color: var(--accent-color);
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 0.75rem;
}

.preset-btn {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.preset-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

/* ======================
   ROLL BUILDER
   ====================== */
.builder-panel {
    display: grid;
    gap: 2rem;
}

.builder-header {
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.builder-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.builder-form {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
}

.dice-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.dice-group {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

.group-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.group-controls input,
.group-controls select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.group-count,
.group-sides {
    width: 80px;
    text-align: center;
    font-weight: 600;
}

.group-operator {
    width: 60px;
    text-align: center;
}

.remove-group {
    padding: 0.5rem;
    border: 1px solid var(--danger-color);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--danger-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

.remove-group:hover {
    background: var(--danger-color);
    color: white;
}

.builder-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.formula-display {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.formula-display label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.formula-text {
    font-family: 'Courier New', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}

.builder-roll-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.saved-formulas {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
}

.saved-formulas h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.formulas-list {
    min-height: 100px;
}

.no-formulas {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.no-formulas i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* ======================
   STATISTICS PANEL
   ====================== */
.stats-panel {
    display: grid;
    gap: 2rem;
}

.stats-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
}

.stat-info {
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.chart-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.chart-container h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    text-align: center;
}

.chart-container canvas {
    max-height: 300px;
}

.dice-analysis {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.dice-analysis h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.analysis-grid {
    display: grid;
    gap: 1rem;
}

.analysis-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.analysis-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.analysis-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* ======================
   HISTORY PANEL
   ====================== */
.history-panel {
    display: grid;
    gap: 1.5rem;
}

.history-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-controls h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-actions {
    display: flex;
    gap: 1rem;
}

.history-filters {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.history-filters select,
.history-filters input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.history-list {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
}

.no-history {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
}

.no-history i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ======================
   GAME TOOLS
   ====================== */
.games-panel {
    display: grid;
    gap: 2rem;
}

.game-tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.game-tool {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-light);
}

.tool-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.tool-header h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.tool-header p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Initiative Tracker */
.add-character {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.add-character input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.initiative-list,
.health-list {
    min-height: 150px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.no-characters,
.no-health-characters {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.no-characters i,
.no-health-characters i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Health Tracker */
.add-health-character {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.add-health-character input {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
}

.add-health-character input[type="text"] {
    flex: 2;
}

.add-health-character input[type="number"] {
    flex: 1;
}

/* Random Generators */
.random-generators {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.generator-btn {
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
}

.generator-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
}

.generator-result {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* Coin Flipper */
.coin-flipper {
    text-align: center;
}

.coin-display {
    margin: 1rem 0;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.coin {
    width: 80px;
    height: 80px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 1s;
}

.coin.flipping {
    animation: flipCoin 1s ease-in-out;
}

@keyframes flipCoin {
    0% { transform: rotateY(0deg); }
    50% { transform: rotateY(900deg); }
    100% { transform: rotateY(1800deg); }
}

.coin-side {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
    color: white;
    backface-visibility: hidden;
}

.coin-side.heads {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #8b4513;
}

.coin-side.tails {
    background: linear-gradient(135deg, #c0c0c0, #e5e5e5);
    color: #4a5568;
    transform: rotateY(180deg);
}

.coin-result {
    margin-top: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ======================
   SIDEBAR
   ====================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255,255,255,0.2);
}

.sidebar-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.recent-rolls,
.saved-rolls {
    max-height: 200px;
    overflow-y: auto;
}

.no-recent,
.no-saved {
    text-align: center;
    color: var(--text-secondary);
    padding: 1rem;
}

.no-recent i,
.no-saved i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.roll-item {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.3s ease;
}

.roll-item:hover {
    background: var(--bg-secondary);
}

.roll-item:last-child {
    border-bottom: none;
}

.roll-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.roll-formula {
    font-weight: 600;
    color: var(--text-primary);
}

.roll-total {
    font-weight: 700;
    color: var(--primary-color);
}

.roll-time {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.settings-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.setting-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.setting-label input[type="checkbox"] {
    margin: 0;
}

.setting-label select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    font-size: 0.8rem;
}

.dice-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.info-label {
    color: var(--text-secondary);
}

.info-value {
    font-weight: 500;
    color: var(--text-primary);
}

/* ======================
   SUCCESS MESSAGE
   ====================== */
.success-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl);
    text-align: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    max-width: 400px;
}

.success-message.show {
    opacity: 1;
    visibility: visible;
}

.success-icon {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.success-message h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.success-message p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.success-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.success-btn {
    padding: 0.75rem 1.5rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--radius-md);
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.success-btn.secondary {
    background: transparent;
    color: var(--primary-color);
}

.success-btn:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.success-btn.secondary:hover {
    background: var(--primary-color);
    color: white;
}

/* ======================
   NOTIFICATION SYSTEM
   ====================== */
.notification-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.notification {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--info-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    border-left-color: var(--success-color);
}

.notification.error {
    border-left-color: var(--danger-color);
}

.notification.warning {
    border-left-color: var(--warning-color);
}

.notification-icon {
    font-size: 1.25rem;
}

.notification.success .notification-icon {
    color: var(--success-color);
}

.notification.error .notification-icon {
    color: var(--danger-color);
}

.notification.warning .notification-icon {
    color: var(--warning-color);
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 500;
    color: var(--text-primary);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

.notification-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ======================
   RESPONSIVE DESIGN
   ====================== */
@media (max-width: 1200px) {
    .tool-page {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    .sidebar {
        grid-row: 1;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    .tool-page {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 1.5rem;
    }
    
    .header-stats {
        justify-content: center;
    }
    
    .template-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .tab-navigation {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        flex: 1;
        min-width: 120px;
    }
    
    .tab-btn span {
        display: none;
    }
    
    .dice-controls {
        grid-template-columns: 1fr;
    }
    
    .roll-actions {
        flex-direction: column;
    }
    
    .dice-display {
        min-height: 120px;
    }
    
    .die {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }
    
    .result-value {
        font-size: 3rem;
    }
    
    .preset-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .stats-overview {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-charts {
        grid-template-columns: 1fr;
    }
    
    .game-tools-grid {
        grid-template-columns: 1fr;
    }
    
    .random-generators {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }
    
    .notification-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    .notification {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .tool-header {
        padding: 1.5rem;
    }
    
    .header-text h1 {
        font-size: 2rem;
    }
    
    .header-stats {
        flex-direction: column;
        gap: 1rem;
    }
    
    .template-grid {
        grid-template-columns: 1fr;
    }
    
    .tab-content {
        padding: 1rem;
    }
    
    .dice-controls {
        padding: 1rem;
    }
    
    .dice-display {
        min-height: 100px;
        padding: 0.5rem;
    }
    
    .die {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .result-value {
        font-size: 2.5rem;
    }
    
    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-overview {
        grid-template-columns: 1fr;
    }
    
    .sidebar-section {
        padding: 1rem;
    }
}

/* ======================
   DARK MODE SUPPORT
   ====================== */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #64748b;
        
        --bg-primary: #1e293b;
        --bg-secondary: #334155;
        --bg-tertiary: #475569;
        --bg-dark: #0f172a;
        
        --border-color: #475569;
        --border-light: #334155;
    }
    
    body {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    }
    
    .tool-header,
    .template-card,
    .dice-container,
    .sidebar-section {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(71, 85, 105, 0.3);
    }
    
    .template-card:hover {
        background: rgba(51, 65, 85, 0.95);
    }
    
    .tab-btn.active {
        background: var(--bg-primary);
    }
}

/* ======================
   PRINT STYLES
   ====================== */
@media print {
    .tool-page {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .sidebar,
    .tab-navigation,
    .template-section,
    .notification-container,
    .success-message {
        display: none;
    }
    
    .tab-content {
        display: block !important;
    }
    
    .dice-container {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
    
    .dice-display-area {
        break-inside: avoid;
    }
}

/* ======================
   ACCESSIBILITY
   ====================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus styles for better accessibility */
button:focus,
input:focus,
select:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --secondary-color: #008000;
        --danger-color: #ff0000;
        --warning-color: #ff8c00;
        --success-color: #008000;
        
        --border-color: #000000;
        --text-primary: #000000;
        --text-secondary: #333333;
    }
    
    .template-card,
    .dice-container,
    .sidebar-section {
        border: 2px solid var(--border-color);
    }
}

/* ======================
   SPECIAL EFFECTS
   ====================== */
.critical-hit {
    animation: criticalPulse 1s ease-in-out;
}

@keyframes criticalPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 20px rgba(34, 197, 94, 0);
    }
}

.critical-fail {
    animation: criticalShake 0.5s ease-in-out;
}

@keyframes criticalShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.lucky-streak {
    position: relative;
    overflow: hidden;
}

.lucky-streak::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.4), transparent);
    animation: shimmer 1.5s ease-in-out;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}