/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(to bottom, #0f172a, #1e293b);
    color: white;
    min-height: 100vh;
    padding: 12px;
}

/* Container */
.container {
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.app {
    max-width: 384px;
    width: 100%;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 16px;
}

.header h1 {
    font-size: 24px;
    font-weight: bold;
    color: #fbbf24;
}

/* Token Counters */
.counters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.counter {
    border-radius: 8px;
    padding: 12px;
    border: 1px solid;
}

.hope-counter {
    background: rgba(234, 179, 8, 0.1);
    border-color: rgba(234, 179, 8, 0.3);
}

.fear-counter {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.counter-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.hope-counter .counter-label {
    color: #fcd34d;
}

.fear-counter .counter-label {
    color: #fca5a5;
}

.counter-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.counter-btn {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: none;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hope-counter .counter-btn {
    background: rgba(234, 179, 8, 0.2);
    color: #fcd34d;
}

.hope-counter .counter-btn:hover {
    background: rgba(234, 179, 8, 0.3);
}

.fear-counter .counter-btn {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.fear-counter .counter-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.counter-value {
    font-size: 20px;
    font-weight: bold;
}

.hope-counter .counter-value {
    color: #fcd34d;
}

.fear-counter .counter-value {
    color: #fca5a5;
}

/* Main Dice Area */
.dice-area {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.5);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
}

/* Dice Container */
.dice-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.die-section {
    text-align: center;
}

.die-label {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.hope-die + .die-label,
.die-section:first-child .die-label {
    color: #fcd34d;
}

.fear-die + .die-label,
.die-section:last-child .die-label {
    color: #fca5a5;
}

.die {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 30px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease;
}

.hope-die {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: black;
}

.fear-die {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

/* Rolling Animation */
.die.rolling {
    animation: bounce 0.6s ease-in-out infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

/* DC Input */
.dc-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.dc-input label {
    color: #d1d5db;
    font-size: 14px;
    font-weight: 500;
}

.dc-input input {
    width: 64px;
    padding: 4px 8px;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 4px;
    color: white;
    text-align: center;
    font-size: 14px;
}

.dc-input input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.5);
}

/* Roll Button */
.roll-button {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 18px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    background: linear-gradient(to right, #7c3aed, #4f46e5);
    color: white;
}

.roll-button:hover:not(:disabled) {
    background: linear-gradient(to right, #6d28d9, #4338ca);
}

.roll-button:active:not(:disabled) {
    transform: scale(0.95);
}

.roll-button:disabled {
    background: #4b5563;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Outcome Display */
.outcome {
    border-radius: 12px;
    padding: 16px;
    border: 1px solid;
    transition: all 0.3s ease;
    text-align: center;
    margin-bottom: 16px;
}

.outcome.critical {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.2);
    border-color: rgba(251, 191, 36, 0.5);
}

.outcome.hope {
    color: #34d399;
    background: rgba(52, 211, 153, 0.2);
    border-color: rgba(52, 211, 153, 0.5);
}

.outcome.fear {
    color: #f87171;
    background: rgba(248, 113, 113, 0.2);
    border-color: rgba(248, 113, 113, 0.5);
}

.outcome-title {
    font-weight: bold;
    font-size: 18px;
    margin-bottom: 4px;
}

.outcome-details {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.outcome-token {
    font-size: 12px;
    font-weight: 500;
}

/* History Section */
.history-section {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.history-title {
    font-size: 16px;
    font-weight: 600;
    color: #d1d5db;
}

.clear-history-btn {
    padding: 6px 12px;
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 6px;
    color: #fca5a5;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-history-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.clear-history-btn:disabled {
    background: rgba(75, 85, 99, 0.2);
    border-color: rgba(75, 85, 99, 0.3);
    color: #6b7280;
    cursor: not-allowed;
}

#history {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(156, 163, 175, 0.3) transparent;
}

#history::-webkit-scrollbar {
    width: 6px;
}

#history::-webkit-scrollbar-track {
    background: transparent;
}

#history::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.3);
    border-radius: 3px;
}

#history::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.5);
}

.history-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(75, 85, 99, 0.2);
    border: 1px solid rgba(75, 85, 99, 0.3);
    border-radius: 6px;
    font-size: 13px;
    animation: slideIn 0.3s ease-out;
}

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

.history-dice {
    display: flex;
    gap: 8px;
    align-items: center;
}

.history-die {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 11px;
}

.history-die.hope {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: black;
}

.history-die.fear {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
}

.history-total {
    font-weight: 600;
    color: #e5e7eb;
}

.history-dc {
    font-size: 11px;
    color: #9ca3af;
}

.history-empty {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 20px;
}

/* Instructions */
.instructions {
    text-align: center;
    color: #6b7280;
    font-size: 12px;
    margin-top: 16px;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    body {
        padding: 8px;
    }
    
    .die {
        width: 70px;
        height: 70px;
        font-size: 24px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .dice-area {
        padding: 12px;
    }
    
    .history-section {
        padding: 12px;
    }
    
    .history-entry {
        padding: 6px 8px;
    }
}

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible {
    outline: 2px solid #8b5cf6;
    outline-offset: 2px;
}
