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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    min-height: 100vh;
    padding-bottom: 80px;
    position: relative;
}

/* Paper Texture Background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(255,255,255,.15) 1px, transparent 0);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    text-align: center;
    padding: 1rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* Main Content */
.app-main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Page Sections */
.page-section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.page-section.active {
    display: block;
}

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

/* Game Area */
.game-area {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.game-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 10px,
            rgba(0,0,0,.02) 10px,
            rgba(0,0,0,.02) 20px
        );
    pointer-events: none;
}

/* Canvas */
#gameCanvas {
    width: 100%;
    height: 300px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    background: linear-gradient(45deg, #f8f9fa, #e9ecef);
    display: block;
    margin: 0 auto 1rem auto;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.05);
}

/* Game Controls */
.game-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.dice-controls, .card-controls {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.dice-controls h3, .card-controls h3 {
    color: #2196F3;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

/* Dice Types */
.dice-types {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dice-btn {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: perspective(1000px) rotateX(0deg);
}

.dice-btn:hover {
    transform: perspective(1000px) rotateX(-5deg) scale(1.05);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.4);
}

.dice-btn:active {
    transform: perspective(1000px) rotateX(5deg) scale(0.95);
}

.dice-btn.selected {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
}

/* Dice Quantity */
.dice-quantity {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dice-quantity label {
    font-weight: 500;
    color: #555;
}

.dice-quantity input {
    width: 60px;
    padding: 0.5rem;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    text-align: center;
    font-weight: 600;
}

/* Action Buttons */
.action-btn {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-bottom: 0.5rem;
    position: relative;
    overflow: hidden;
}

.action-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.action-btn:active::before {
    width: 300px;
    height: 300px;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

/* Card Actions */
.card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.deck-info {
    text-align: center;
    font-weight: 500;
    color: #666;
    padding: 0.5rem;
    background: white;
    border-radius: 5px;
    border: 1px solid #e0e0e0;
}

/* Results Area */
.results-area {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.dice-results, .card-results {
    background: #f8f9fa;
    padding: 1.5rem;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
    min-height: 120px;
}

.dice-results h4, .card-results h4 {
    color: #2196F3;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

#diceResultsContainer {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.dice-result {
    background: linear-gradient(135deg, #FFC107, #F57F17);
    color: #333;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 700;
    font-size: 1.5rem;
    min-width: 50px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(255, 193, 7, 0.3);
    transform: perspective(1000px) rotateX(0deg);
    animation: rollIn 0.6s ease-out;
}

@keyframes rollIn {
    0% {
        transform: perspective(1000px) rotateX(90deg) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: perspective(1000px) rotateX(-10deg) scale(1.1);
    }
    100% {
        transform: perspective(1000px) rotateX(0deg) scale(1);
        opacity: 1;
    }
}

.card-result {
    background: white;
    border: 2px solid #333;
    border-radius: 10px;
    padding: 2rem 1rem;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 600;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    animation: cardFlip 0.8s ease-in-out;
}

@keyframes cardFlip {
    0% {
        transform: perspective(1000px) rotateY(90deg);
        opacity: 0;
    }
    50% {
        transform: perspective(1000px) rotateY(0deg) scale(1.05);
    }
    100% {
        transform: perspective(1000px) rotateY(0deg) scale(1);
        opacity: 1;
    }
}

.red-suit {
    color: #F44336;
}

.black-suit {
    color: #333;
}

/* History Section */
.history-container {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

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

.history-header h2 {
    color: #2196F3;
    font-size: 1.8rem;
}

.clear-btn {
    background: linear-gradient(135deg, #F44336, #D32F2F);
    color: white;
    border: none;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.4);
}

.history-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 10px;
    text-align: center;
    border: 1px solid #e0e0e0;
}

.stat-label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #2196F3;
}

.history-list {
    max-height: 400px;
    overflow-y: auto;
}

.history-item {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    border-left: 4px solid #2196F3;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-item:nth-child(odd) {
    background: #e3f2fd;
}

.history-time {
    color: #666;
    font-size: 0.85rem;
}

/* Customization Section */
.custom-container {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.custom-container h2 {
    color: #2196F3;
    font-size: 1.8rem;
    margin-bottom: 2rem;
    text-align: center;
}

.custom-tabs {
    display: flex;
    margin-bottom: 2rem;
    background: #f8f9fa;
    border-radius: 10px;
    padding: 0.5rem;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.tab-btn.active {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    box-shadow: 0 2px 10px rgba(33, 150, 243, 0.3);
}

.custom-tab {
    display: none;
}

.custom-tab.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.custom-tab h3 {
    color: #4CAF50;
    margin-bottom: 1.5rem;
    font-size: 1.3rem;
}

.custom-form {
    display: grid;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 600;
    color: #555;
}

.form-group input[type="color"] {
    width: 100px;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.form-group input[type="range"] {
    width: 100%;
}

.form-group select {
    padding: 0.8rem;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    font-size: 1rem;
}

.save-btn {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.save-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.reset-btn {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(255, 152, 0, 0.4);
}

/* FAQ Section */
.faq-container {
    background: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.faq-container h2 {
    color: #2196F3;
    font-size: 1.8rem;
    margin-bottom: 2rem;
    text-align: center;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.faq-item {
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.faq-item:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.faq-question {
    width: 100%;
    background: #f8f9fa;
    border: none;
    padding: 1.5rem;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: #e3f2fd;
    color: #2196F3;
}

.faq-question[aria-expanded="true"] {
    background: #2196F3;
    color: white;
}

.faq-icon {
    font-size: 1.2rem;
    font-weight: 700;
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    background: white;
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
    animation: slideDown 0.3s ease-out;
}

.faq-answer[hidden] {
    display: none;
}

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

.faq-answer p {
    color: #555;
    line-height: 1.6;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.8rem 0.5rem;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-item.active::before {
    width: 100%;
}

.nav-item.active {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.05);
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.nav-item:hover {
    color: #2196F3;
    background: rgba(33, 150, 243, 0.05);
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: #666;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.8);
    margin-top: 2rem;
    border-top: 1px solid #e0e0e0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        padding: 0.5rem;
    }
    
    .game-controls {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .results-area {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .dice-types {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .history-stats {
        grid-template-columns: 1fr;
    }
    
    .custom-tabs {
        flex-direction: column;
    }
    
    #gameCanvas {
        height: 200px;
    }
    
    .app-header h1 {
        font-size: 1.2rem;
    }
    
    .faq-question {
        padding: 1rem;
        font-size: 0.9rem;
    }
    
    .faq-answer {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .dice-types {
        grid-template-columns: 1fr;
    }
    
    .nav-item {
        padding: 0.6rem 0.3rem;
    }
    
    .nav-item i {
        font-size: 1rem;
    }
    
    .nav-item span {
        font-size: 0.7rem;
    }
    
    #gameCanvas {
        height: 150px;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 3D Transform Effects */
.transform-3d {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.rotate-x {
    transform: rotateX(15deg);
}

.rotate-y {
    transform: rotateY(15deg);
}

/* Hover Effects */
.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .dice-btn, .action-btn, .save-btn, .reset-btn {
        border: 2px solid currentColor;
    }
    
    .faq-question {
        border: 1px solid currentColor;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
        color: #e0e0e0;
    }
    
    .game-area, .history-container, .custom-container, .faq-container {
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .dice-controls, .card-controls, .dice-results, .card-results {
        background: #3d3d3d;
        border-color: #555;
    }
    
    #gameCanvas {
        background: linear-gradient(45deg, #2d2d2d, #3d3d3d);
        border-color: #555;
    }
    
    .bottom-nav {
        background: #2d2d2d;
        border-color: #555;
    }
    
    .nav-item {
        color: #ccc;
    }
    
    .nav-item.active {
        color: #64B5F6;
    }
}
