/* ============================================================================
   DICE BOX - MAIN STYLESHEET
   Modern, responsive design for Dice Box strategic dice game
   ============================================================================ */

/* Game Menu Customization */
:root {
    --game-primary: #8B5CF6;
    --game-primary-dark: #6D28D9;
    --game-secondary: #F59E0B;
}

/* Menu styles are handled by shared game-menu.css */
.dicebox-menu .game-menu-stats .stat-card {
    background: rgba(15, 23, 42, 0.78);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    box-shadow: 0 20px 48px rgba(15, 23, 42, 0.5);
}

.dicebox-menu .game-menu-stats .stat-value {
    color: var(--game-secondary);
}

.dicebox-menu .game-menu-preview {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(245, 158, 11, 0.16) 100%);
    border: 1px solid rgba(139, 92, 246, 0.4);
    box-shadow: 0 24px 52px rgba(15, 23, 42, 0.55);
}

.dicebox-menu .game-menu-preview__badge {
    background: rgba(139, 92, 246, 0.8);
    color: #fff;
    box-shadow: 0 14px 30px rgba(139, 92, 246, 0.35);
}

/* Game-specific variables */
:root {
    --primary-color: #8B5CF6;
    --primary-hover: #6D28D9;
    --success-color: #28a745;
    --success-hover: #218838;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --gold-color: #F59E0B;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Rockwell', 'Rockwell Nova', 'Roboto Slab', serif;
    color: var(--text-dark);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Allow scrolling on menu screen */
body.game-menu-active {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Prevent scrolling when game is active */
body:not(.game-menu-active) .game-container {
    overflow: hidden;
}

html {
    height: 100%;
}

/* Game Container - No Scroll Layout */
.game-container {
    display: none;
    height: 100vh;
    overflow: hidden;
    padding: 0;
    margin: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--bg-light);
}

.game-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    gap: clamp(0.5rem, 1.5vh, 1rem);
    padding: clamp(0.5rem, 1vh, 1rem);
}

/* Goal Section */
.goal-section {
    text-align: center;
    padding: clamp(0.5rem, 1vh, 1rem);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.25) 0%, rgba(245, 158, 11, 0.25) 100%);
    border-radius: clamp(0.5rem, 1vw, 1rem);
    border: 2px solid rgba(139, 92, 246, 0.4);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.goal-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.25rem, 0.5vh, 0.5rem);
}

.goal-label {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    color: var(--text-light);
    margin: 0;
    font-weight: 600;
}

.goal-value {
    font-size: clamp(1.5rem, 4vw, 3rem);
    font-weight: 700;
    color: #ffffff;
    text-shadow: 
        2px 2px 4px rgba(0, 0, 0, 0.5),
        0 0 10px rgba(139, 92, 246, 0.8);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9) 0%, rgba(109, 40, 217, 0.9) 100%);
    padding: clamp(0.25rem, 0.5vh, 0.5rem) clamp(0.75rem, 1.5vw, 1.5rem);
    border-radius: clamp(0.375rem, 0.75vw, 0.75rem);
    display: inline-block;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.difficulty-badge {
    display: inline-block;
    margin-left: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.difficulty-badge.difficulty-easy {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9) 0%, rgba(22, 163, 74, 0.9) 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.4);
}

.difficulty-badge.difficulty-hard {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9) 0%, rgba(220, 38, 38, 0.9) 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
}

/* Dice Section */
.dice-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.5rem, 1vh, 1rem);
    padding: clamp(0.5rem, 1vh, 1rem);
    background: var(--bg-white);
    border-radius: clamp(0.5rem, 1vw, 1rem);
    box-shadow: var(--shadow);
    flex-shrink: 0;
    min-height: 0;
}

.current-dice-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.25rem, 0.5vh, 0.5rem);
}

.current-dice-area h3 {
    margin: 0;
    font-size: clamp(0.9rem, 2vw, 1.5rem);
    color: var(--text-dark);
}

.dice-container-game {
    width: clamp(80px, 12vw, 120px);
    height: clamp(80px, 12vw, 120px);
    perspective: 1000px;
    margin: 0 auto;
    transition: opacity 0.2s ease, transform 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.dice-container-game:active {
    cursor: grabbing;
}

.dice-container-game .dice {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.dice-container-game .dice .face {
    width: 100% !important;
    height: 100% !important;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    position: absolute !important;
    overflow: hidden !important; /* Prevent dots from appearing outside face */
    box-sizing: border-box;
    display: block !important; /* Override flex/grid from shared CSS */
    justify-content: unset !important;
    align-items: unset !important;
    flex-wrap: unset !important;
    grid-template-columns: none !important;
    grid-template-rows: none !important;
    gap: 0 !important;
    padding: 0 !important;
}

.dice-container-game .dice .dot {
    width: clamp(12px, 1.5vw, 18px) !important;
    height: clamp(12px, 1.5vw, 18px) !important;
    position: absolute !important;
    margin: 0 !important;
    flex: none !important;
    /* Override all shared CSS positioning rules */
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
}

/* Override specific face dot positioning from shared CSS */
.dice-container-game .dice .face.front .dot,
.dice-container-game .dice .face.right .dot,
.dice-container-game .dice .face.top .dot,
.dice-container-game .dice .face.bottom .dot,
.dice-container-game .dice .face.left .dot,
.dice-container-game .dice .face.back .dot {
    position: absolute !important;
    margin: 0 !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
}

/* Override translateZ for responsive dice (scale dynamically) */
.dice-container-game .dice .face.front {
    transform: translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-container-game .dice .face.right {
    transform: rotateY(90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-container-game .dice .face.top {
    transform: rotateX(90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-container-game .dice .face.bottom {
    transform: rotateX(-90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-container-game .dice .face.left {
    transform: rotateY(-90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-container-game .dice .face.back {
    transform: translateZ(calc(clamp(80px, 12vw, 120px) / -2)) rotateY(180deg) !important;
}

.dice-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(0.25rem, 0.5vh, 0.5rem);
}

.roll-counter {
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    color: var(--text-light);
    font-weight: 600;
}

.game-message {
    font-size: clamp(0.9rem, 1.8vw, 1.2rem);
    color: var(--text-dark);
    text-align: center;
    padding: clamp(0.5rem, 1vh, 1rem);
    background: rgba(139, 92, 246, 0.1);
    border-radius: clamp(0.25rem, 0.5vw, 0.5rem);
    min-height: clamp(40px, 6vh, 60px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Buttons */
.btn {
    padding: clamp(0.5rem, 1vh, 0.75rem) clamp(0.75rem, 1.5vw, 1.5rem);
    border: none;
    border-radius: clamp(0.25rem, 0.5vw, 0.5rem);
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: clamp(0.25rem, 0.5vw, 0.5rem);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--text-light);
    color: white;
}

.btn-secondary:hover {
    background: var(--text-dark);
}

.btn-large {
    padding: clamp(0.75rem, 1.5vh, 1rem) clamp(1.5rem, 3vw, 2rem);
    font-size: clamp(1rem, 2vw, 1.2rem);
}

/* Boxes Section */
.boxes-section {
    padding: clamp(0.5rem, 1vh, 1rem);
    background: var(--bg-white);
    border-radius: clamp(0.5rem, 1vw, 1rem);
    box-shadow: var(--shadow);
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.boxes-title {
    text-align: center;
    font-size: clamp(1rem, 2.5vw, 2rem);
    margin-bottom: clamp(0.5rem, 1vh, 1rem);
    color: var(--text-dark);
    flex-shrink: 0;
}

.boxes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(120px, 15vw, 200px), 1fr));
    gap: clamp(0.5rem, 1vw, 1rem);
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    padding: clamp(0.25rem, 0.5vh, 0.5rem);
}

.box {
    background: var(--bg-white);
    border: 3px solid var(--border-color);
    border-radius: clamp(0.5rem, 1vw, 1rem);
    padding: clamp(0.5rem, 1vh, 1rem);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: clamp(0.25rem, 0.5vh, 0.5rem);
    min-height: clamp(180px, 22vh, 250px);
}

.box.available {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.05) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.box.available:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-hover);
}

.box.available.highlight {
    animation: pulse 1s infinite;
    border-color: var(--gold-color);
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.box.drag-over {
    border-color: var(--gold-color) !important;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.2) 0%, rgba(245, 158, 11, 0.15) 100%) !important;
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.6) !important;
    transform: scale(1.05);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.box.used {
    border-color: var(--text-light);
    background: var(--bg-light);
    cursor: default;
    opacity: 0.7;
}

.box-header {
    text-align: center;
}

.box-name {
    font-size: clamp(0.9rem, 2vw, 1.5rem);
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
}

.box.used .box-name {
    color: var(--text-light);
}

.box-rule {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: var(--text-light);
    font-style: italic;
}

.box-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(120px, 15vh, 150px);
    padding: clamp(0.5rem, 1vh, 1rem);
}

.box-empty {
    color: var(--text-light);
    font-style: italic;
}

.dice-in-box {
    width: clamp(80px, 12vw, 120px);
    height: clamp(80px, 12vw, 120px);
    margin: 0 auto;
    perspective: 1000px;
}

.dice-in-box .dice {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
}

.dice-in-box .dice .face {
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    padding: clamp(3px, 0.5vw, 6px);
    box-sizing: border-box;
}

.dice-in-box .dice .dot {
    width: clamp(12px, 1.5vw, 18px);
    height: clamp(12px, 1.5vw, 18px);
    position: absolute;
    margin: 0;
    flex-shrink: 0;
}

/* Override translateZ for responsive dice in boxes - same size as main dice */
.dice-in-box .dice .face.front {
    transform: translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-in-box .dice .face.right {
    transform: rotateY(90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-in-box .dice .face.top {
    transform: rotateX(90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-in-box .dice .face.bottom {
    transform: rotateX(-90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-in-box .dice .face.left {
    transform: rotateY(-90deg) translateZ(calc(clamp(80px, 12vw, 120px) / 2)) !important;
}

.dice-in-box .dice .face.back {
    transform: translateZ(calc(clamp(80px, 12vw, 120px) / -2)) rotateY(180deg) !important;
}

.box-result {
    text-align: center;
    font-weight: 600;
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    padding-top: clamp(0.25rem, 0.5vh, 0.5rem);
    border-top: 1px solid var(--border-color);
}

.box-result.positive {
    color: var(--success-color);
}

.box-result.negative {
    color: var(--danger-color);
}

.box-result.zero {
    color: var(--text-light);
}

/* Score Section */
.score-section {
    padding: clamp(0.5rem, 1vh, 1rem);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%);
    border-radius: clamp(0.5rem, 1vw, 1rem);
    border: 2px solid rgba(139, 92, 246, 0.3);
    flex-shrink: 0;
}

.score-display {
    text-align: center;
    margin-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
}

.score-label {
    font-size: clamp(0.8rem, 1.5vw, 1.2rem);
    color: var(--text-light);
    margin-bottom: clamp(0.25rem, 0.5vh, 0.5rem);
    font-weight: 600;
}

.score-value {
    font-size: clamp(2rem, 4.5vw, 3.5rem);
    font-weight: 700;
    color: var(--primary-color);
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.score-breakdown {
    display: flex;
    flex-direction: column;
    gap: clamp(0.25rem, 0.5vh, 0.5rem);
    margin-top: clamp(0.25rem, 0.5vh, 0.5rem);
    padding-top: clamp(0.25rem, 0.5vh, 0.5rem);
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    max-height: clamp(100px, 15vh, 150px);
    overflow-y: auto;
}

.breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: clamp(0.25rem, 0.5vh, 0.5rem);
    background: rgba(255, 255, 255, 0.5);
    border-radius: clamp(0.125rem, 0.25vw, 0.25rem);
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
}

.breakdown-item.positive {
    color: var(--success-color);
}

.breakdown-item.negative {
    color: var(--danger-color);
}

.breakdown-item.zero {
    color: var(--text-light);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    overflow: auto;
}

.modal-content {
    background-color: var(--bg-white);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 1rem;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    margin-top: 1rem;
}

.modal-body h3 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-body ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.modal-body li {
    margin-bottom: 0.5rem;
}

.modal-body .success {
    color: var(--success-color);
    font-weight: 600;
}

.modal-body .error {
    color: var(--danger-color);
    font-weight: 600;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-light);
    padding: 1.5rem;
    border-radius: 0.5rem;
    text-align: center;
    border: 2px solid var(--border-color);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

/* Game Over Modal */
.game-over-score {
    text-align: center;
    margin-bottom: 2rem;
}

.final-score-label {
    font-size: 1.2rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.final-score-value {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.target-score-label {
    font-size: 1rem;
    color: var(--text-light);
    margin-top: 1rem;
}

.target-score-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text-dark);
}

.game-over-details {
    margin-bottom: 2rem;
    text-align: center;
}

.game-over-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Settings */
.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.setting-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.setting-toggle input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Responsive Design - Additional adjustments for very small screens */
@media (max-height: 600px) {
    .game-main {
        gap: clamp(0.25rem, 0.5vh, 0.5rem);
        padding: clamp(0.25rem, 0.5vh, 0.5rem);
    }
    
    .boxes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .boxes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin: 10% auto;
    }
    
    .game-over-buttons {
        flex-direction: column;
    }
    
    .game-over-buttons .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .boxes-grid {
        grid-template-columns: 1fr;
    }
}

/* Hide game header on mobile when game is active */
@media (max-width: 768px), (max-height: 667px) {
    body:not(.game-menu-active) #game-header {
        display: none !important;
    }
    
    body:not(.game-menu-active).with-game-header {
        padding-top: 0 !important;
    }
}
