* {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Arial, sans-serif;
        }
        
        body {
            display: flex;
            flex-direction: column;
            min-height: 100vh;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            color: #333;
            padding: 15px;
            overflow-x: hidden;
        }
        
        .header {
            text-align: center;
            margin-bottom: 20px;
            padding: 0 10px;
        }
        
        h1 {
            margin-bottom: 8px;
            font-weight: 300;
            color: #2c3e50;
            font-size: 1.8rem;
        }
        h2 {
            margin-bottom: 8px;
            font-weight: 200;
            color: #2c3e50;
            font-size: 0.9rem;
        }
        
        .main-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            gap: 30px;
            margin-bottom: 20px;
            flex-grow: 1;
            max-height: calc(100vh - 180px);
        }
        
        .grid-section {
            flex: 1;
            min-width: 300px;
            max-width: 400px;
        }
        
        .dice-section {
            flex: 1;
            min-width: 300px;
            max-width: 400px;
        }
        
        .grid-container {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-bottom: 25px;
        }
        
        .grid-row {
            display: flex;
            justify-content: space-between;
            align-items: center;
            //gap: 15px;
        }
        
        .square-group {
            display: flex;
            align-items: center;
            gap: 0px;
            flex: 1;
        }
        
        .square-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 90px;
        }
        
        .square-label {
            font-size: 0.75rem;
            color: #7f8c8d;
            margin-bottom: 6px;
            height: 16px;
            text-align: center;
            font-weight: 500;
            white-space: nowrap;
        }
        
        .square {
            width: 80px;
            padding:8px;
            height: 80px;
            background-color: white;
            border: 2px solid #3498db;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 6vw;
            font-weight: 700;
            color: #2c3e50;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
            transition: all 0.3s;
            cursor: pointer;
        }
        
        .square:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(0,0,0,0.15);
        }
        
        .row-label {
            font-size: 0.8rem;
            color: #7f8c8d;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            font-weight: 500;
        }
        
        .square-caption {
            text-align: center;
            font-size: 2rem;
            color: #7f8c8d;
            width:100%;
            min-width: 60px;
            padding-left: 2px;
            border-left: 1px solid #ddd;
            line-height: 1.3;
        }
        
        .result-container, .dice-container {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 20px;
        }

        .result-container {
            margin-left:100px;
        }

        .dice-result-row {
          padding-top: 50px;
          display: flex;
          justify-content: center;
          align-items: center;
          gap: 80px;
          margin: 20px 0;
          flex-wrap: wrap; /* Allow wrapping on small screens */
        }

        textarea {
            width: 100%;
        }
        
        .result-label {
            font-size: 0.9rem;
            color: #2c3e50;
            margin-bottom: 8px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }
        
        .result-square {
            width: 80px;
            height: 80px;
            background: linear-gradient(145deg, #ffffff, #f0f0f0);
            border: 3px solid #2c3e50;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 2rem;
            font-weight: 700;
            color: #2c3e50;
            box-shadow: 0 6px 12px rgba(0,0,0,0.15);
        }
        
        .dice-container {
            position: relative;
            //margin: 0 auto 25px;
            perspective: 800px;
        }
        
        #dice {
            width: 80px;
            height: 80px;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.2s ease-out;
            transform-origin: center;
        }
        
        .dice-face {
            position: absolute;
            width: 80px;
            height: 80px;
            background-color: #fefefe;
            border: 2px solid #2c3e50;
            border-radius: 10px;
            display: flex;
            justify-content: center;
            align-items: center;
            box-shadow: 
                inset 0 0 10px rgba(0,0,0,0.05),
                0 2px 4px rgba(0,0,0,0.1);
        }
        
        /* Enhanced dice faces with subtle gradient */
        .dice-face::before {
            content: '';
            position: absolute;
            top: 4px;
            left: 4px;
            right: 4px;
            bottom: 4px;
            border-radius: 6px;
            background: linear-gradient(145deg, #ffffff, #f0f0f0);
            z-index: 0;
        }
        
        /* Position each face in 3D space */
        .front { transform: translateZ(40px); }
        .back { transform: rotateY(180deg) translateZ(40px); }
        .top { transform: rotateX(90deg) translateZ(40px); }
        .bottom { transform: rotateX(-90deg) translateZ(40px); }
        .right { transform: rotateY(90deg) translateZ(40px); }
        .left { transform: rotateY(-90deg) translateZ(40px); }
        
        .dot-container {
            position: relative;
            width: 60px;
            height: 60px;
            z-index: 1;
        }
        
        .dot {
            width: 12px;
            height: 12px;
            background: radial-gradient(circle at 30% 30%, #2c3e50, #1a1a2e);
            border-radius: 50%;
            position: absolute;
            box-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        
        /* Dot glow effect */
        .dot::after {
            content: '';
            position: absolute;
            width: 4px;
            height: 4px;
            background: rgba(255,255,255,0.7);
            border-radius: 50%;
            top: 3px;
            left: 3px;
        }
        
        .controls {
            margin-bottom: 20px;
            text-align: center;
        }
        
        #roll-btn {
            //background: linear-gradient(to bottom, #3498db, #2980b9);
            //border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: all 0.3s;
            background-color: white;

            font-size: 0.7rem;
            color: #7f8c8d;
            margin-bottom: 6px;
            height: 16px;
            text-align: center;
            font-weight: 500;
            white-space: nowrap;            
        }


        
        button:hover {
            background: linear-gradient(to bottom, #3cb0fd, #3498db);
            transform: translateY(-2px);
            box-shadow: 0 6px 8px rgba(52, 152, 219, 0.4);
        }
        
        button:active {
            transform: translateY(1px);
            box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
        }
        
        button:disabled {
            background: linear-gradient(to bottom, #bdc3c7, #95a5a6);
            cursor: not-allowed;
            transform: none;
            box-shadow: none;
        }
        
        .result-display, textarea {
            //background-color: white;
            //border-radius: 10px;
            //padding: 20px;
            box-shadow: 0 8px 20px rgba(0,0,0,0.08);
            //margin-top: 15px;
            //border: 1px solid #eaeaea;
            text-align: center;
        }
        
        
        #result {
            font-size: 1.0rem;
            font-weight: 300;
            color: #2c3e50;
            margin-bottom: 12px;
            min-height: 150px;
            height: auto;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        
        .footer {
            margin-top: auto;
            padding: 15px 10px 10px;
            display: flex;
            justify-content: space-between;
            align-items: flex-end;
            width: 100%;
            border-top: 1px solid rgba(0,0,0,0.05);
        }
        
        .footer-text {
            color: #95a5a6;
            font-size: 0.75rem;
            text-align: center;
            line-height: 1.4;
            flex: 1;
        }
        
        .bottom-right-text {
            color: #7f8c8d;
            font-size: 0.7rem;
            //text-align: right;
            padding: 5px 8px;
            background: rgba(255, 255, 255, 0.7);
            border-radius: 4px;
            max-width: 180px;
        }
        
        /* Realistic rolling animation with bounce effect */
        @keyframes roll {
            0% { 
                transform: rotateX(0) rotateY(0) rotateZ(0); 
            }
            20% { 
                transform: rotateX(90deg) rotateY(180deg) rotateZ(45deg); 
            }
            40% { 
                transform: rotateX(270deg) rotateY(360deg) rotateZ(90deg); 
            }
            60% { 
                transform: rotateX(450deg) rotateY(540deg) rotateZ(135deg); 
            }
            80% { 
                transform: rotateX(630deg) rotateY(720deg) rotateZ(180deg);
                animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1);
            }
            90% {
                transform: rotateX(720deg) rotateY(810deg) rotateZ(200deg);
                animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
            }
            100% { 
                transform: rotateX(720deg) rotateY(900deg) rotateZ(180deg); 
            }
        }
        
        /* Subtle bounce effect after rolling */
        @keyframes bounce {
            0%, 20%, 50%, 80%, 100% {transform: translateY(0);}
            40% {transform: translateY(-8px);}
            60% {transform: translateY(-4px);}
        }
        
        .rolling {
            animation: roll 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }
        
        .bounce {
            animation: bounce 0.6s ease;
        }
        
        
        /* Responsive layout adjustments */
        @media (max-width: 900px) {
            .main-container {
                flex-direction: column;
                align-items: center;
                max-height: none;
            }
            
            .grid-section, .dice-section {
                max-width: 100%;
                width: 100%;
            }
            
            .grid-container {
                max-width: 500px;
                margin: 0 auto 25px;
            }
        }
        
        @media (max-width: 500px) {
            .grid-row {
                //gap: 10px;
            }
            
            .square-group {
                gap: 0px;
            }
            
            .square-container {
                width: 75px;
            }
            
            .square {
                width: 70px;
                height: 70px;
                font-size: 6vw;
                padding:8px;
            }
            
            .square-caption {
                text-align: center;
                min-width: 60px;
                width:100%;
                font-size: 2rem;
            }
            
            .row-label {
                width: 30px;
                font-size: 0.75rem;
            }
            
            .dice-container {
                width: 70px;
                height: 100px;
                }

            #dice {
                width: 70px;
                height: 70px;
                }

            .result-square {
                width: 70px;
                height: 70px;
            }
            
            .front { transform: translateZ(35px); }
            .back { transform: rotateY(180deg) translateZ(35px); }
            .top { transform: rotateX(90deg) translateZ(35px); }
            .bottom { transform: rotateX(-90deg) translateZ(35px); }
            .right { transform: rotateY(90deg) translateZ(35px); }
            .left { transform: rotateY(-90deg) translateZ(35px); }
            
            .dot-container {
                width: 50px;
                height: 50px;
            }
            
            .dot {
                width: 10px;
                height: 10px;
            }
            
            h1 {
                font-size: 1.5rem;
            }

            h2 {
                font-size: 0.75rem;
            }
            
            .subtitle {
                font-size: 0.8rem;
            }
            
            .result-display {
                //padding: 15px;
            }
            
            #result {
                font-size: 1.8rem;
            }
        }
        
        @media (max-width: 380px) {
            .square {
                width: 60px;
                height: 60px;
                font-size: 6vw;
                padding:8px;
            }
            
            .square-container {
                width: 65px;
            }
            
            .square-caption {
                text-align: center;
                width:100%;
                min-width: 60px;
                font-size: 1.3rem;
            }
            
            .dice-container {
                width: 70px;
                height: 100px;
            }
            .result-square {
                width: 60px;
                height: 60px;
            }
            
            .front { transform: translateZ(30px); }
            .back { transform: rotateY(180deg) translateZ(30px); }
            .top { transform: rotateX(90deg) translateZ(30px); }
            .bottom { transform: rotateX(-90deg) translateZ(30px); }
            .right { transform: rotateY(90deg) translateZ(30px); }
            .left { transform: rotateY(-90deg) translateZ(30px); }
            
            .dot-container {
                width: 40px;
                height: 40px;
            }
            
            .dot {
                width: 8px;
                height: 8px;
            }
        }
        
        /* Ensure everything fits in viewport */
        @media (max-height: 700px) {
            .header {
                margin-bottom: 15px;
            }
            
            .main-container {
                margin-bottom: 15px;
            }
            
            .grid-container {
                margin-bottom: 15px;
            }
            
            .footer {
                padding: 10px 10px 5px;
            }
            
            h1 {
                font-size: 1.5rem;
                margin-bottom: 5px;
            }

            h2 {
                font-size: 0.75rem;
                margin-bottom: 5px;
            }
            
            .subtitle {
                font-size: 0.8rem;
            }
        }