/* =========================================================
   DICE ROLLER
   ========================================================= */


/* ---------------------------------------------------------
   Page
   --------------------------------------------------------- */

.dice-page {
    width: 100%;
    min-height: calc(100vh - 120px);
    padding-bottom: 40px;
}


/* ---------------------------------------------------------
   Header
   --------------------------------------------------------- */

.dice-header {
    margin-bottom: 28px;
}

.dice-icon {
    font-size: 52px;
    line-height: 1;
    margin-bottom: 14px;
}

.dice-header h1 {
    margin: 0;
    font-size: 2.4rem;
    font-weight: 700;
}

.dice-header p {
    margin: 10px 0 0;
    font-size: 1rem;
    opacity: 0.7;
}


/* ---------------------------------------------------------
   Game Card
   --------------------------------------------------------- */

.dice-game-card {
    width: 100%;
    max-width: 600px;

    margin: 0 auto;

    padding: 30px;

    border-radius: 24px;

    background: #ffffff;

    box-shadow:
        0 15px 40px rgba(0, 0, 0, 0.10);

    text-align: center;
}


/* ---------------------------------------------------------
   Shared Control Label
   --------------------------------------------------------- */

.dice-control-label {
    display: block;

    margin-bottom: 9px;

    font-size: 0.72rem;
    font-weight: 700;

    letter-spacing: 1.5px;

    color: #777777;
}


/* ---------------------------------------------------------
   Dice Type
   --------------------------------------------------------- */

.dice-type-control {
    margin-bottom: 22px;
}

.dice-type-buttons {
    display: flex;

    justify-content: center;
    align-items: center;

    flex-wrap: wrap;

    gap: 8px;
}

.dice-type-button {
    min-width: 50px;
    height: 38px;

    padding: 0 12px;

    border: 1px solid #d5d5d5;
    border-radius: 9px;

    background: #f7f7f7;
    color: #333333;

    font-size: 0.82rem;
    font-weight: 700;

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease,
        transform 0.15s ease;
}

.dice-type-button:hover {
    background: #eeeeee;

    transform: translateY(-1px);
}

.dice-type-button.active {
    background: #222222;
    color: #ffffff;

    border-color: #222222;
}

.dice-type-button:disabled {
    opacity: 0.45;

    cursor: not-allowed;

    transform: none;
}


/* ---------------------------------------------------------
   Number of Dice
   --------------------------------------------------------- */

.dice-count-control {
    display: flex;

    flex-direction: column;

    align-items: center;

    margin-bottom: 18px;
}

.dice-count-buttons {
    display: flex;

    align-items: center;
    justify-content: center;

    gap: 14px;
}

.dice-count-buttons strong {
    min-width: 30px;

    font-size: 1.25rem;
    font-weight: 700;

    color: #222222;
}

.dice-count-button {
    width: 34px;
    height: 34px;

    display: flex;

    align-items: center;
    justify-content: center;

    padding: 0;

    border: 1px solid #d5d5d5;
    border-radius: 9px;

    background: #f7f7f7;
    color: #222222;

    font-size: 1.35rem;
    line-height: 1;

    cursor: pointer;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.dice-count-button:hover {
    background: #eeeeee;

    transform: translateY(-1px);
}

.dice-count-button:active {
    transform: translateY(0);
}

.dice-count-button:disabled {
    opacity: 0.35;

    cursor: not-allowed;

    transform: none;
}


/* ---------------------------------------------------------
   Dice Stage
   --------------------------------------------------------- */

.dice-stage {
    width: 100%;
    min-height: 220px;

    display: flex;

    align-items: center;
    justify-content: center;

    gap: 20px;

    position: relative;

    margin-bottom: 8px;

    overflow: visible;

    perspective: 700px;
}


/* ---------------------------------------------------------
   Dice
   --------------------------------------------------------- */

.dice-page .dice {
    position: relative;

    top: auto;
    right: auto;
    bottom: auto;
    left: auto;

    flex: 0 0 auto;

    width: 130px;
    height: 130px;

    margin: 0;

    border-radius: 22px;

    background: #ffffff;

    border: 3px solid #222222;

    box-shadow:
        0 12px 25px rgba(0, 0, 0, 0.18);

    display: flex;

    align-items: center;
    justify-content: center;

    box-sizing: border-box;

    overflow: hidden;

    transform-origin: center center;

    transform-style: preserve-3d;

    animation-delay: 0s;
}


/* ---------------------------------------------------------
   Number on Dice
   --------------------------------------------------------- */

.dice-page .dice-number {
    position: relative;

    z-index: 2;

    font-size: 3.2rem;
    line-height: 1;

    font-weight: 800;

    color: #222222;

    user-select: none;
}


/* ---------------------------------------------------------
   Dice Type Label
   --------------------------------------------------------- */

.dice-page .dice-type-small {
    position: absolute;

    right: 9px;
    bottom: 7px;

    z-index: 3;

    font-size: 0.65rem;

    font-weight: 700;

    letter-spacing: 0.5px;

    opacity: 0.35;

    user-select: none;
}


/* ---------------------------------------------------------
   Rolling Animation
   --------------------------------------------------------- */

.dice-page .dice.rolling {
    animation:
        dice-roll-3d
        0.7s
        cubic-bezier(0.25, 0.8, 0.25, 1);
}


@keyframes dice-roll-3d {

    0% {
        transform:
            translateY(0)
            rotateX(0deg)
            rotateY(0deg)
            rotateZ(0deg)
            scale(1);
    }

    15% {
        transform:
            translateY(-18px)
            rotateX(80deg)
            rotateY(45deg)
            rotateZ(20deg)
            scale(1.05);
    }

    30% {
        transform:
            translateY(-8px)
            rotateX(180deg)
            rotateY(100deg)
            rotateZ(45deg)
            scale(0.96);
    }

    45% {
        transform:
            translateY(5px)
            rotateX(270deg)
            rotateY(180deg)
            rotateZ(70deg)
            scale(1.04);
    }

    60% {
        transform:
            translateY(-6px)
            rotateX(360deg)
            rotateY(260deg)
            rotateZ(100deg)
            scale(0.98);
    }

    75% {
        transform:
            translateY(2px)
            rotateX(440deg)
            rotateY(330deg)
            rotateZ(125deg)
            scale(1.02);
    }

    90% {
        transform:
            translateY(-2px)
            rotateX(520deg)
            rotateY(390deg)
            rotateZ(145deg)
            scale(1);
    }

    100% {
        transform:
            translateY(0)
            rotateX(720deg)
            rotateY(450deg)
            rotateZ(180deg)
            scale(1);
    }
}


/* ---------------------------------------------------------
   Result
   --------------------------------------------------------- */

.dice-page .dice-result {
    position: relative;

    width: 100%;

    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    margin: 5px 0 25px;

    text-align: center;
}

.dice-page .result-label {
    display: block;

    margin-bottom: 4px;

    font-size: 0.75rem;
    font-weight: 700;

    letter-spacing: 2px;

    opacity: 0.55;
}

.dice-page .dice-result strong {
    display: block;

    font-size: 2.4rem;
    line-height: 1;

    font-weight: 700;
}


/* ---------------------------------------------------------
   Roll Button
   --------------------------------------------------------- */

.dice-page .roll-button {
    width: 100%;
    max-width: 300px;

    min-height: 56px;

    display: inline-flex;

    align-items: center;
    justify-content: center;

    gap: 10px;

    padding: 14px 24px;

    border: none;
    border-radius: 14px;

    background: #222222;
    color: #ffffff;

    font-size: 1rem;
    font-weight: 700;

    letter-spacing: 0.5px;

    cursor: pointer;

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        opacity 0.15s ease;
}

.dice-page .roll-button:hover {
    transform: translateY(-2px);

    box-shadow:
        0 8px 18px rgba(0, 0, 0, 0.18);
}

.dice-page .roll-button:active {
    transform: translateY(0);

    box-shadow: none;
}

.dice-page .roll-button:disabled {
    cursor: not-allowed;

    opacity: 0.6;

    transform: none;

    box-shadow: none;
}

.dice-page .roll-icon {
    font-size: 1.2rem;

    line-height: 1;
}


/* ---------------------------------------------------------
   Keyboard Hint
   --------------------------------------------------------- */

.dice-page .keyboard-hint {
    margin: 18px 0 0;

    font-size: 0.85rem;

    opacity: 0.6;
}

.dice-page .keyboard-hint kbd {
    display: inline-block;

    margin: 0 3px;

    padding: 4px 8px;

    border: 1px solid #d0d0d0;

    border-radius: 5px;

    background: #f5f5f5;

    color: #333333 !important;

    font-family: inherit;

    font-size: 0.75rem;
    font-weight: 600;

    line-height: 1.2;

    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.10);

    text-shadow: none;
}


/* =========================================================
   ROLL HISTORY
   ========================================================= */

.dice-history-card {
    width: 100%;
    max-width: 600px;

    margin: 25px auto 0;

    padding: 25px 30px;

    border-radius: 20px;

    background: #ffffff;

    box-shadow:
        0 12px 35px rgba(0, 0, 0, 0.08);
}


/* ---------------------------------------------------------
   History Header
   --------------------------------------------------------- */

.history-header {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-bottom: 18px;
}

.history-header h2 {
    margin: 0;

    font-size: 1.2rem;
    font-weight: 700;
}

.history-header p {
    margin: 4px 0 0;

    font-size: 0.8rem;

    opacity: 0.55;
}


/* ---------------------------------------------------------
   Clear History
   --------------------------------------------------------- */

.clear-history-button {
    flex: 0 0 auto;

    padding: 8px 13px;

    border: 1px solid #d5d5d5;

    border-radius: 8px;

    background: #ffffff;

    color: #555555;

    font-size: 0.75rem;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.15s ease,
        color 0.15s ease,
        border-color 0.15s ease;
}

.clear-history-button:hover {
    background: #f5f5f5;

    border-color: #bbbbbb;

    color: #222222;
}


/* ---------------------------------------------------------
   History List
   --------------------------------------------------------- */

.history-list {
    display: flex;

    flex-direction: column;

    gap: 8px;
}


/* ---------------------------------------------------------
   History Item
   --------------------------------------------------------- */

.history-item {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;

    padding: 13px 14px;

    border: 1px solid #eeeeee;

    border-radius: 11px;

    background: #fafafa;
}


.history-main {
    min-width: 0;

    text-align: left;
}


.history-title {
    margin: 0 0 4px;

    font-size: 0.85rem;

    font-weight: 700;

    color: #222222;
}


.history-values {
    margin: 0;

    font-size: 0.8rem;

    color: #555555;

    word-break: break-word;
}


.history-time {
    flex: 0 0 auto;

    font-size: 0.72rem;

    color: #888888;

    white-space: nowrap;
}


.history-total {
    margin-left: 5px;

    font-weight: 700;

    color: #222222;
}


/* ---------------------------------------------------------
   Empty History
   --------------------------------------------------------- */

.empty-history {
    padding: 20px 10px;

    text-align: center;

    font-size: 0.85rem;

    opacity: 0.5;
}


/* ---------------------------------------------------------
   Multiple Dice
   --------------------------------------------------------- */

.dice-page .dice-stage.has-multiple-dice {
    gap: 16px;
}


/* =========================================================
   RESPONSIVE
   ========================================================= */


/* ---------------------------------------------------------
   Tablet
   --------------------------------------------------------- */

@media (max-width: 768px) {

    .dice-header {
        margin-bottom: 24px;
    }

    .dice-header h1 {
        font-size: 2rem;
    }

    .dice-icon {
        font-size: 46px;
    }

    .dice-game-card {
        max-width: 520px;

        padding: 28px 24px;

        border-radius: 20px;
    }

    .dice-stage {
        min-height: 200px;
    }

    .dice-page .dice {
        width: 115px;
        height: 115px;
    }

    .dice-page .dice-number {
        font-size: 2.8rem;
    }

    .dice-history-card {
        max-width: 520px;
    }
}


/* ---------------------------------------------------------
   Mobile
   --------------------------------------------------------- */

@media (max-width: 560px) {

    .dice-game-card {
        padding: 26px 18px 24px;
    }

    .dice-type-buttons {
        gap: 6px;
    }

    .dice-type-button {
        min-width: 45px;

        height: 36px;

        padding: 0 9px;

        font-size: 0.78rem;
    }

    .dice-stage {
        min-height: 175px;

        gap: 12px;
    }

    .dice-page .dice {
        width: 95px;
        height: 95px;

        border-radius: 17px;

        border-width: 2px;
    }

    .dice-page .dice-number {
        font-size: 2.35rem;
    }

    .dice-page .dice-type-small {
        right: 6px;
        bottom: 5px;

        font-size: 0.55rem;
    }

    .dice-history-card {
        padding: 22px 18px;
    }

    .history-item {
        align-items: flex-start;
    }

    .history-time {
        font-size: 0.68rem;
    }
}


/* ---------------------------------------------------------
   Very Small Screens
   --------------------------------------------------------- */

@media (max-width: 380px) {

    .dice-game-card {
        padding-left: 14px;
        padding-right: 14px;
    }

    .dice-type-buttons {
        gap: 5px;
    }

    .dice-type-button {
        min-width: 42px;

        padding: 0 7px;

        font-size: 0.72rem;
    }

    .dice-stage {
        min-height: 155px;

        gap: 5px;
    }

    .dice-page .dice {
        width: 82px;
        height: 82px;

        border-radius: 14px;
    }

    .dice-page .dice-number {
        font-size: 2rem;
    }

    .history-header {
        align-items: flex-start;

        flex-direction: column;
    }

    .clear-history-button {
        width: 100%;
    }

    .history-item {
        flex-direction: column;

        gap: 5px;
    }

    .history-time {
        align-self: flex-start;
    }
}