  * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            -webkit-tap-highlight-color: transparent;
            -webkit-user-select: none;
            user-select: none;
        }

        html,
        body {
            width: 100%;
            min-height: 100vh;
            min-height: 100dvh;
            overflow-x: hidden;
            touch-action: manipulation;
            overscroll-behavior: none;
            font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
            background: linear-gradient(135deg, #0f0c29, #1a1a2e, #16213e);
            background-attachment: fixed;
        }

        body {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
            padding: max(16px, 3vw);
            position: relative;
        }

        /* Animated background particles */
        .bg-particles {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 0;
            overflow: hidden;
        }

        .bg-particle {
            position: absolute;
            border-radius: 50%;
            background: rgba(255, 255, 255, 0.03);
            animation: floatUp linear infinite;
        }

        @keyframes floatUp {
            0% {
                transform: translateY(105vh) scale(0);
                opacity: 0;
            }
            10% {
                opacity: 1;
            }
            80% {
                opacity: 1;
            }
            100% {
                transform: translateY(-10vh) scale(1.5);
                opacity: 0;
            }
        }

        /* Main container */
        .container {
            position: relative;
            z-index: 1;
            width: 100%;
            max-width: 520px;
            background: rgba(255, 255, 255, 0.04);
            backdrop-filter: blur(20px);
            -webkit-backdrop-filter: blur(20px);
            border-radius: clamp(20px, 4vw, 32px);
            border: 1px solid rgba(255, 255, 255, 0.12);
            padding: clamp(20px, 4vw, 36px) clamp(16px, 3vw, 28px);
            box-shadow:
                0 30px 60px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(255, 255, 255, 0.05) inset,
                0 1px 0 rgba(255, 255, 255, 0.08) inset;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: clamp(16px, 3vw, 24px);
            transition: all 0.3s ease;
        }

        /* Title */
        h1 {
            font-size: clamp(1.6rem, 4.5vw, 2.4rem);
            font-weight: 900;
            letter-spacing: -0.02em;
            background: linear-gradient(135deg, #ffffff 0%, #c0caf5 40%, #7aa2f7 70%, #bb9af7 100%);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            text-align: center;
            line-height: 1.2;
            filter: drop-shadow(0 2px 8px rgba(122, 162, 247, 0.3));
        }

        /* === DICE CUBE === */
        .dice-wrapper {
            perspective: 800px;
            width: clamp(100px, 25vw, 150px);
            height: clamp(100px, 25vw, 150px);
            cursor: pointer;
            -webkit-tap-highlight-color: transparent;
            transition: transform 0.15s ease;
        }

        .dice-wrapper:active {
            transform: scale(0.94);
        }

        .dice-cube {
            width: 100%;
            height: 100%;
            position: relative;
            transform-style: preserve-3d;
            transition: transform 0.1s ease;
        }

        .dice-cube.rolling {
            animation: diceRoll3D 0.8s cubic-bezier(0.22, 0.61, 0.36, 1);
        }

        @keyframes diceRoll3D {
            0% {
                transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg);
            }
            25% {
                transform: rotateX(200deg) rotateY(130deg) rotateZ(40deg);
            }
            50% {
                transform: rotateX(380deg) rotateY(300deg) rotateZ(120deg);
            }
            75% {
                transform: rotateX(560deg) rotateY(470deg) rotateZ(200deg);
            }
            100% {
                transform: rotateX(720deg) rotateY(600deg) rotateZ(360deg);
            }
        }

        /* Dice face */
        .dice-face {
            position: absolute;
            width: 100%;
            height: 100%;
            border-radius: clamp(12px, 3vw, 18px);
            background: linear-gradient(145deg, #fafafa, #e8e8e8);
            box-shadow:
                inset 0 -4px 8px rgba(0, 0, 0, 0.1),
                inset 0 4px 8px rgba(255, 255, 255, 0.9),
                0 8px 24px rgba(0, 0, 0, 0.3);
            display: grid;
            grid-template: repeat(3, 1fr) / repeat(3, 1fr);
            padding: clamp(10%, 12%, 16%);
            gap: 2px;
            backface-visibility: hidden;
            border: 2px solid rgba(0, 0, 0, 0.06);
            transition: all 0.3s ease;
        }

        .dice-dot {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: radial-gradient(circle at 35% 35%, #3a3a3a, #1a1a1a);
            box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.4), inset 0 2px 3px rgba(255, 255, 255, 0.3);
            transition: all 0.2s ease;
        }

        .dot-empty {
            background: transparent;
            box-shadow: none;
        }

        /* Dice face positions */
        .face-front {
            transform: translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }
        .face-back {
            transform: rotateY(180deg) translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }
        .face-right {
            transform: rotateY(90deg) translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }
        .face-left {
            transform: rotateY(-90deg) translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }
        .face-top {
            transform: rotateX(90deg) translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }
        .face-bottom {
            transform: rotateX(-90deg) translateZ(calc(clamp(50px, 12.5vw, 75px)));
        }

        /* Final face rotations for each result */
        .dice-cube.show-1 {
            transform: rotateX(0deg) rotateY(0deg);
        }
        .dice-cube.show-2 {
            transform: rotateX(0deg) rotateY(-90deg);
        }
        .dice-cube.show-3 {
            transform: rotateX(-90deg) rotateY(0deg);
        }
        .dice-cube.show-4 {
            transform: rotateX(90deg) rotateY(0deg);
        }
        .dice-cube.show-5 {
            transform: rotateX(0deg) rotateY(90deg);
        }
        .dice-cube.show-6 {
            transform: rotateX(0deg) rotateY(180deg);
        }

        /* Result number display */
        .result-number {
            font-size: clamp(2.5rem, 7vw, 4rem);
            font-weight: 900;
            letter-spacing: -0.03em;
            background: linear-gradient(135deg, #7aa2f7, #bb9af7);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            opacity: 0;
            transform: translateY(8px);
            transition: all 0.4s cubic-bezier(0.22, 0.61, 0.36, 1);
            text-align: center;
            min-height: clamp(40px, 8vw, 60px);
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .result-number.show {
            opacity: 1;
            transform: translateY(0);
        }

        /* Roll button */
        .roll-btn {
            background: linear-gradient(135deg, #7aa2f7, #5d8af0);
            color: #fff;
            font-size: clamp(1.1rem, 2.8vw, 1.35rem);
            font-weight: 700;
            letter-spacing: 0.02em;
            padding: clamp(12px, 2.5vw, 18px) clamp(28px, 6vw, 44px);
            border: none;
            border-radius: 50px;
            cursor: pointer;
            transition: all 0.25s ease;
            box-shadow:
                0 8px 30px rgba(93, 138, 240, 0.4),
                0 2px 0 rgba(255, 255, 255, 0.2) inset;
            position: relative;
            overflow: hidden;
            touch-action: manipulation;
            -webkit-tap-highlight-color: transparent;
            width: 100%;
            max-width: 300px;
            text-align: center;
            letter-spacing: 0.04em;
        }

        .roll-btn:hover {
            background: linear-gradient(135deg, #8db4f8, #6e9af5);
            box-shadow:
                0 12px 40px rgba(93, 138, 240, 0.55),
                0 2px 0 rgba(255, 255, 255, 0.2) inset;
            transform: translateY(-2px);
        }

        .roll-btn:active {
            transform: scale(0.95);
            box-shadow:
                0 4px 16px rgba(93, 138, 240, 0.5),
                0 1px 0 rgba(255, 255, 255, 0.15) inset;
            transition: all 0.08s ease;
        }

        .roll-btn:disabled {
            opacity: 0.55;
            cursor: not-allowed;
            pointer-events: none;
            filter: grayscale(20%);
        }

        .roll-btn .btn-shine {
            position: absolute;
            top: 0;
            left: -100%;
            width: 60%;
            height: 100%;
            background: linear-gradient(90deg,
                    transparent,
                    rgba(255, 255, 255, 0.2),
                    transparent);
            transform: skewX(-20deg);
            animation: btnShine 3s ease-in-out infinite;
        }

        @keyframes btnShine {
            0%,
            100% {
                left: -100%;
            }
            50% {
                left: 140%;
            }
        }

        /* Roll history */
        .history-section {
            width: 100%;
            max-width: 400px;
        }

        .history-title {
            font-size: clamp(0.85rem, 2vw, 1rem);
            font-weight: 600;
            color: rgba(255, 255, 255, 0.5);
            text-transform: uppercase;
            letter-spacing: 0.08em;
            margin-bottom: clamp(8px, 1.5vw, 12px);
            text-align: center;
        }

        .history-list {
            list-style: none;
            padding: 0;
            max-height: clamp(180px, 35vh, 300px);
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: clamp(6px, 1.2vw, 10px);
            scroll-behavior: smooth;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
            scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
            padding-right: 4px;
        }

        .history-list::-webkit-scrollbar {
            width: 4px;
        }
        .history-list::-webkit-scrollbar-track {
            background: transparent;
            border-radius: 10px;
        }
        .history-list::-webkit-scrollbar-thumb {
            background: rgba(255, 255, 255, 0.2);
            border-radius: 10px;
        }

        .history-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: clamp(10px, 2vw, 14px) clamp(14px, 3vw, 18px);
            background: rgba(255, 255, 255, 0.05);
            border-radius: clamp(10px, 2vw, 14px);
            border: 1px solid rgba(255, 255, 255, 0.08);
            animation: slideIn 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
            transition: all 0.2s ease;
            backdrop-filter: blur(8px);
            -webkit-backdrop-filter: blur(8px);
        }

        .history-item:hover {
            background: rgba(255, 255, 255, 0.09);
            border-color: rgba(255, 255, 255, 0.18);
            transform: translateX(3px);
        }

        @keyframes slideIn {
            0% {
                opacity: 0;
                transform: translateX(-20px) scale(0.95);
            }
            100% {
                opacity: 1;
                transform: translateX(0) scale(1);
            }
        }

        .history-roll-label {
            font-size: clamp(0.8rem, 1.8vw, 0.95rem);
            color: rgba(255, 255, 255, 0.7);
            font-weight: 500;
        }

        .history-dice-mini {
            display: grid;
            grid-template: repeat(3, 1fr) / repeat(3, 1fr);
            width: clamp(28px, 6vw, 36px);
            height: clamp(28px, 6vw, 36px);
            background: linear-gradient(145deg, #f5f5f5, #e0e0e0);
            border-radius: clamp(5px, 1vw, 7px);
            padding: clamp(3px, 0.8vw, 5px);
            gap: 1px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
            flex-shrink: 0;
        }

        .history-mini-dot {
            width: 100%;
            height: 100%;
            border-radius: 50%;
            background: radial-gradient(circle at 35% 35%, #3a3a3a, #1a1a1a);
            box-shadow: inset 0 -1px 2px rgba(0, 0, 0, 0.4);
        }
        .history-mini-empty {
            background: transparent;
            box-shadow: none;
        }

        .history-result-badge {
            font-size: clamp(1rem, 2.5vw, 1.4rem);
            font-weight: 800;
            color: #7aa2f7;
            min-width: 24px;
            text-align: center;
        }

        .history-left {
            display: flex;
            align-items: center;
            gap: clamp(8px, 2vw, 14px);
        }

        /* Clear history button */
        .clear-btn {
            background: transparent;
            color: rgba(255, 255, 255, 0.4);
            font-size: clamp(0.7rem, 1.5vw, 0.8rem);
            font-weight: 500;
            border: 1px solid rgba(255, 255, 255, 0.15);
            padding: clamp(6px, 1.2vw, 8px) clamp(14px, 3vw, 20px);
            border-radius: 30px;
            cursor: pointer;
            transition: all 0.2s ease;
            touch-action: manipulation;
            letter-spacing: 0.03em;
        }

        .clear-btn:hover {
            color: rgba(255, 255, 255, 0.8);
            border-color: rgba(255, 255, 255, 0.4);
            background: rgba(255, 255, 255, 0.04);
        }
        .clear-btn:active {
            transform: scale(0.94);
            background: rgba(255, 100, 100, 0.1);
            border-color: rgba(255, 100, 100, 0.4);
            color: #ff6b6b;
        }

        .history-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: clamp(8px, 1.5vw, 12px);
        }

        /* Total stats */
        .stats-row {
            display: flex;
            gap: clamp(6px, 1.5vw, 10px);
            flex-wrap: wrap;
            justify-content: center;
            width: 100%;
            max-width: 400px;
        }

        .stat-chip {
            background: rgba(255, 255, 255, 0.05);
            border: 1px solid rgba(255, 255, 255, 0.1);
            border-radius: 30px;
            padding: clamp(6px, 1.2vw, 8px) clamp(12px, 2.5vw, 16px);
            font-size: clamp(0.7rem, 1.5vw, 0.8rem);
            color: rgba(255, 255, 255, 0.6);
            font-weight: 500;
            letter-spacing: 0.02em;
            backdrop-filter: blur(6px);
            -webkit-backdrop-filter: blur(6px);
        }

        .stat-chip strong {
            color: #7aa2f7;
            font-weight: 700;
        }

        /* Confetti burst */
        .confetti-container {
            position: fixed;
            inset: 0;
            pointer-events: none;
            z-index: 100;
        }

        .confetti-piece {
            position: absolute;
            width: 10px;
            height: 10px;
            border-radius: 3px;
            animation: confettiFall 0.9s ease-out forwards;
        }

        @keyframes confettiFall {
            0% {
                transform: translateY(0) rotate(0deg) scale(1);
                opacity: 1;
            }
            100% {
                transform: translateY(400px) rotate(720deg) scale(0);
                opacity: 0;
            }
        }

        /* Landscape adjustments */
        @media (max-width: 750px) and (orientation: landscape) {
            .container {
                flex-direction: row;
                flex-wrap: wrap;
                justify-content: center;
                gap: 12px;
                padding: 16px;
                max-width: 95vw;
            }
            h1 {
                font-size: 1.3rem;
                width: 100%;
            }
            .dice-wrapper {
                width: 80px;
                height: 80px;
            }
            .dice-face {
                border-radius: 10px;
            }
            .face-front {
                transform: translateZ(40px);
            }
            .face-back {
                transform: rotateY(180deg) translateZ(40px);
            }
            .face-right {
                transform: rotateY(90deg) translateZ(40px);
            }
            .face-left {
                transform: rotateY(-90deg) translateZ(40px);
            }
            .face-top {
                transform: rotateX(90deg) translateZ(40px);
            }
            .face-bottom {
                transform: rotateX(-90deg) translateZ(40px);
            }
            .dice-cube.show-1 {
                transform: rotateX(0deg) rotateY(0deg);
            }
            .dice-cube.show-2 {
                transform: rotateX(0deg) rotateY(-90deg);
            }
            .dice-cube.show-3 {
                transform: rotateX(-90deg) rotateY(0deg);
            }
            .dice-cube.show-4 {
                transform: rotateX(90deg) rotateY(0deg);
            }
            .dice-cube.show-5 {
                transform: rotateX(0deg) rotateY(90deg);
            }
            .dice-cube.show-6 {
                transform: rotateX(0deg) rotateY(180deg);
            }
            .roll-btn {
                max-width: 200px;
                padding: 10px 20px;
                font-size: 0.9rem;
            }
            .history-list {
                max-height: 120px;
            }
            .result-number {
                font-size: 1.8rem;
                min-height: 30px;
            }
        }

        /* Small phones */
        @media (max-width: 360px) {
            .container {
                padding: 14px 10px;
                gap: 12px;
                border-radius: 16px;
            }
            h1 {
                font-size: 1.3rem;
            }
            .dice-wrapper {
                width: 85px;
                height: 85px;
            }
            .dice-face {
                border-radius: 10px;
            }
            .face-front {
                transform: translateZ(42px);
            }
            .face-back {
                transform: rotateY(180deg) translateZ(42px);
            }
            .face-right {
                transform: rotateY(90deg) translateZ(42px);
            }
            .face-left {
                transform: rotateY(-90deg) translateZ(42px);
            }
            .face-top {
                transform: rotateX(90deg) translateZ(42px);
            }
            .face-bottom {
                transform: rotateX(-90deg) translateZ(42px);
            }
            .dice-cube.show-1 {
                transform: rotateX(0deg) rotateY(0deg);
            }
            .dice-cube.show-2 {
                transform: rotateX(0deg) rotateY(-90deg);
            }
            .dice-cube.show-3 {
                transform: rotateX(-90deg) rotateY(0deg);
            }
            .dice-cube.show-4 {
                transform: rotateX(90deg) rotateY(0deg);
            }
            .dice-cube.show-5 {
                transform: rotateX(0deg) rotateY(90deg);
            }
            .dice-cube.show-6 {
                transform: rotateX(0deg) rotateY(180deg);
            }
            .history-dice-mini {
                width: 24px;
                height: 24px;
                padding: 2px;
                border-radius: 4px;
            }
        }