* {
    box-sizing: border-box;
}

.dice-container {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    padding: 24px;
    border-radius: 20px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
    border: 1px solid rgba(255,255,255,0.07);
}

.dice-button-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 24px 12px 18px;
}

.reset-dice,
.roll-button {
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.roll-button {
    min-width: 180px;
    height: 54px;
    padding: 0 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
    color: #111827;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow: 0 10px 26px rgba(245, 158, 11, 0.24);
}

.roll-button::after {
    content: "Roll Dice";
}

.roll-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(245, 158, 11, 0.32);
}

.roll-button:active {
    transform: translateY(0);
}

.reset-dice {
    width: 54px;
    height: 54px;
    background: rgba(255,255,255,0.08);
    color: #cbd5e1;
    border: 1px solid rgba(255,255,255,0.10);
    font-size: 1rem;
}

.reset-dice:hover {
    background: rgba(255,255,255,0.12);
    color: white;
    transform: translateY(-2px);
}

#rollCount {
    min-width: 95px;
    margin: 0 0 0 6px;
    color: #cbd5e1;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.first-face {
    display: flex;
    align-items: center;
    justify-content: center;
}

.second-face {
    display: flex;
    justify-content: space-between;
}

.second-face .dot:nth-of-type(2) {
    align-self: flex-end;
}

.third-face {
    display: flex;
    justify-content: space-between;
}

.third-face .dot:nth-of-type(1) {
    align-self: flex-end;
}

.third-face .dot:nth-of-type(2) {
    align-self: center;
}

.fourth-face,
.fifth-face,
.sixth-face {
    display: flex;
    justify-content: space-between;
}

.fourth-face .column,
.fifth-face .column,
.sixth-face .column {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.fifth-face .column:nth-of-type(2) {
    justify-content: center;
}

.dice {
    position: relative;
    width: 86px;
    height: 86px;
    margin: 0;
    padding: 13px;
    border-radius: 18px;
    background: linear-gradient(145deg, #ffffff, #e8edf3);
    border: 2px solid rgba(15, 23, 42, 0.08);
    box-shadow:
        0 13px 20px rgba(0,0,0,0.24),
        inset 0 2px 2px rgba(255,255,255,0.9),
        inset 0 -3px 6px rgba(15,23,42,0.10);
    cursor: pointer;
    user-select: none;
    transform: translateY(0) rotate(0deg);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border 0.18s ease;
    animation: diceRoll 0.65s ease-in-out 1;
    animation-play-state: paused;
}

.dice:hover:not(.selected) {
    transform: translateY(-5px);
    box-shadow:
        0 18px 28px rgba(0,0,0,0.28),
        inset 0 2px 2px rgba(255,255,255,0.9),
        inset 0 -3px 6px rgba(15,23,42,0.10);
}

.dice.selected {
    transform: translateY(-10px);
    border: 3px solid #f59e0b;
    background: linear-gradient(145deg, #fffdf5, #fff2c7);
    box-shadow:
        0 0 0 4px rgba(245, 158, 11, 0.14),
        0 20px 28px rgba(0,0,0,0.28);
}

.dice.selected::after {
    content: "HOLD";
    position: absolute;
    left: 50%;
    bottom: -27px;
    transform: translateX(-50%);
    padding: 3px 8px;
    border-radius: 999px;
    background: #f59e0b;
    color: #111827;
    font-size: 0.63rem;
    font-weight: 900;
    letter-spacing: 0.09em;
}

.dot {
    display: block;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #111827;
    box-shadow: inset 0 2px 3px rgba(0,0,0,0.28);
}

@keyframes diceRoll {
    0%   { transform: translateY(0) rotate(0deg) scale(1); }
    35%  { transform: translateY(-14px) rotate(145deg) scale(1.04); }
    70%  { transform: translateY(3px) rotate(290deg) scale(0.98); }
    100% { transform: translateY(0) rotate(360deg) scale(1); }
}

.play {
    animation-play-state: running;
}

.stop {
    animation-play-state: paused;
}

@media (max-width: 700px) {
    .dice-container {
        gap: 12px;
        padding: 22px 12px 34px;
    }

    .dice {
        width: 68px;
        height: 68px;
        padding: 10px;
        border-radius: 15px;
    }

    .dot {
        width: 12px;
        height: 12px;
    }

    .roll-button {
        min-width: 150px;
    }
}

/* --------------------------------------------------
   Gameplay polish: rolling, held dice, and turn flow
   -------------------------------------------------- */

.dice-container {
    position: relative;
    transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.dice {
    outline: none;
}

.dice:focus-visible {
    box-shadow:
        0 0 0 4px rgba(96, 165, 250, 0.32),
        0 18px 28px rgba(0,0,0,0.28),
        inset 0 2px 2px rgba(255,255,255,0.9),
        inset 0 -3px 6px rgba(15,23,42,0.10);
}

.dice.selected {
    transform: translateY(-12px) scale(1.035);
    border-color: #fbbf24;
    box-shadow:
        0 0 0 5px rgba(245, 158, 11, 0.13),
        0 22px 34px rgba(0,0,0,0.34);
}

.dice.selected::before {
    content: "✓";
    position: absolute;
    top: -10px;
    right: -10px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #f59e0b;
    color: #111827;
    font-size: 0.78rem;
    font-weight: 1000;
    box-shadow: 0 6px 14px rgba(0,0,0,0.28);
}

.dice.selected::after {
    content: "HELD";
    bottom: -30px;
    padding: 4px 9px;
    box-shadow: 0 5px 12px rgba(0,0,0,0.22);
}

.roll-button.roll-again::after {
    content: "Roll Again";
}

.roll-button.rolling::after {
    content: "Rolling...";
}

.roll-button.choose-score::after {
    content: "Choose a Score";
}

.roll-button:disabled {
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.roll-button.choose-score:disabled {
    opacity: 1;
    background: linear-gradient(180deg, #334155, #263244);
    color: #f8fafc;
    border: 1px solid rgba(251, 191, 36, 0.30);
}

.roll-button.choose-score:disabled i {
    color: #fbbf24;
}

.roll-button.rolling:disabled {
    opacity: 0.82;
}

.roll-button.rolling i {
    animation: buttonDiceSpin 0.55s linear infinite;
}

.reset-dice:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

#rollCount {
    min-width: 126px;
}

.turn-message {
    margin: -4px auto 22px;
    min-height: 22px;
    padding: 0 16px;
    color: #94a3b8;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 650;
    transition: color 0.2s ease, transform 0.2s ease;
}

.turn-message.active-turn-message {
    color: #cbd5e1;
}

.turn-message.choose-score-message {
    color: #fde68a;
    font-weight: 800;
    animation: messagePulse 1.5s ease-in-out infinite;
}

.turn-message.score-saved-message {
    color: #86efac;
    font-weight: 800;
    animation: scoreMessageIn 0.35s ease-out;
}

@keyframes diceRoll {
    0%   { transform: translateY(0) rotate(0deg) scale(1); }
    22%  { transform: translateY(-20px) rotate(115deg) scale(1.07); }
    48%  { transform: translateY(5px) rotate(240deg) scale(0.96); }
    70%  { transform: translateY(-8px) rotate(325deg) scale(1.025); }
    88%  { transform: translateY(2px) rotate(350deg) scale(0.995); }
    100% { transform: translateY(0) rotate(360deg) scale(1); }
}

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

@keyframes messagePulse {
    0%, 100% { opacity: 0.72; }
    50% { opacity: 1; }
}

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

@media (prefers-reduced-motion: reduce) {
    .dice,
    .roll-button,
    .turn-message {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* =====================================================
   COMPACT GAME LAYOUT
   ===================================================== */

.dice-container {
    min-height: 116px;
    gap: 14px;
    padding: 14px 18px 18px;
}

.dice-button-container {
    gap: 10px;
    padding: 10px 10px 6px;
}

.roll-button {
    min-width: 170px;
    height: 48px;
}

#rollCount {
    min-width: 118px;
    margin-left: 4px;
    font-size: 0.88rem;
}

.turn-message {
    margin: 0 auto 10px;
    min-height: 18px;
    font-size: 0.78rem;
}

@media (max-width: 700px) {
    .dice-container {
        gap: 10px;
        padding: 16px 10px 26px;
    }

    .dice-button-container {
        padding-top: 8px;
    }
}

/* =====================================================
   PHONE FIT: keep all five dice on one row
   ===================================================== */
@media (max-width: 620px) {
    .dice-container {
        display: flex;
        flex-wrap: nowrap;
        justify-content: center !important;
        align-items: center;
        gap: 13px;
        padding: 16px 14px 24px;
    }

    .dice {
        width: 50px;
        height: 50px;
        padding: 7px;
        border-radius: 12px;
        flex: 0 0 50px;
    }

    .dot {
        width: 8px;
        height: 8px;
    }

    .dice.selected::before {
        top: -7px;
        right: -7px;
        width: 20px;
        height: 20px;
        font-size: 0.64rem;
    }

    .dice.selected::after {
        bottom: -24px;
        padding: 3px 6px;
        font-size: 0.55rem;
    }

}
