.yz-shell {
    display: block;
}

.yz-shell *,
.yz-shell *::before,
.yz-shell *::after {
    box-sizing: border-box;
}

.yz-wrap {
    --yz-felt-1: #1a6f52;
    --yz-felt-2: #0a3527;
    --yz-gold: #e3b23c;
    --yz-cream: #fffdf4;
    --yz-pip: #171f23;
    max-width: min(92vw, 720px);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: Inter, Arial, sans-serif;
    color: var(--cg-ink);
}

.yz-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.yz-modes,
.yz-actions {
    display: flex;
    gap: 6px;
}

.yz-btn {
    appearance: none;
    min-height: 44px;
    border: 1px solid var(--cg-line);
    background: var(--cg-panel);
    color: var(--cg-ink);
    border-radius: 10px;
    padding: 9px 14px;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.yz-btn:hover {
    border-color: var(--cg-green);
    transform: translateY(-1px);
}

.yz-btn.yz-on {
    background: var(--cg-green);
    border-color: var(--cg-green);
    color: #fff;
}

.yz-primary {
    background: var(--cg-ink);
    border-color: var(--cg-ink);
    color: #fff;
}

.yz-icon {
    width: 44px;
    padding: 9px 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.yz-icon svg {
    width: 20px;
    height: 20px;
}

.yz-stage {
    min-height: 296px;
    padding: 14px clamp(10px, 2.4vw, 20px) 12px;
    border: 2px solid #072318;
    border-radius: 18px;
    background:
        radial-gradient(120% 110% at 50% -10%, var(--yz-felt-1), var(--yz-felt-2) 78%);
    box-shadow: inset 0 0 0 4px rgba(227, 178, 60, 0.24), inset 0 -24px 44px rgba(0, 0, 0, 0.35), var(--cg-shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.yz-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: #b7d8c9;
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.yz-hud-item {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
}

.yz-hud strong {
    color: #fff;
    font-size: 1.02rem;
    letter-spacing: 0;
}

.yz-dice {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    justify-items: center;
    align-items: start;
    gap: clamp(7px, 1.8vw, 14px);
    min-height: 108px;
}

.yz-die {
    position: relative;
    width: 100%;
    max-width: 124px;
    aspect-ratio: 1;
    padding: 13%;
    border: none;
    border-radius: 16px;
    background: linear-gradient(158deg, var(--yz-cream), #e6e0cd);
    box-shadow: 0 5px 0 #a49d88, 0 10px 16px rgba(0, 0, 0, 0.4);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 7%;
    cursor: pointer;
    transition: transform 0.14s ease, box-shadow 0.14s ease, opacity 0.14s ease;
}

.yz-die:disabled {
    cursor: default;
}

.yz-die .yz-pip {
    border-radius: 50%;
}

.yz-die .yz-on {
    background: radial-gradient(circle at 34% 28%, #545f66, var(--yz-pip));
    box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.25);
}

.yz-die.yz-dim {
    opacity: 0.86;
    filter: saturate(0.8);
    box-shadow: 0 4px 0 #a49d88, 0 7px 12px rgba(0, 0, 0, 0.32);
}

.yz-die.yz-dim .yz-on {
    opacity: 0.72;
}

.yz-die.yz-held {
    transform: translateY(7px);
    box-shadow: 0 0 0 3px var(--yz-gold), 0 3px 0 #a49d88, 0 6px 12px rgba(0, 0, 0, 0.4);
}

.yz-die.yz-held::after {
    content: 'HELD';
    position: absolute;
    left: 50%;
    bottom: -3px;
    transform: translateX(-50%);
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--yz-gold);
    color: #2a1e04;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.08em;
}

.yz-wrap[data-actor="cpu"] .yz-die {
    background: linear-gradient(158deg, #eef4ff, #ccd8ea);
}

.yz-die.yz-tumble {
    animation: yz-tumble 0.42s ease-in-out;
}

@keyframes yz-tumble {
    0% { transform: translateY(0) rotate(0deg); }
    22% { transform: translateY(-16px) rotate(-15deg); }
    48% { transform: translateY(0) rotate(11deg); }
    72% { transform: translateY(-8px) rotate(-6deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

.yz-rollbar {
    display: flex;
    justify-content: center;
}

.yz-roll {
    width: 100%;
    max-width: 320px;
    min-height: 52px;
    border: 1px solid #a5761a;
    border-radius: 12px;
    background: linear-gradient(180deg, #f3c85f, #d29a1c);
    color: #241a05;
    font: inherit;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    cursor: pointer;
    box-shadow: 0 4px 0 #9a6f16, 0 8px 16px rgba(0, 0, 0, 0.3);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.yz-roll:hover:not(:disabled) {
    transform: translateY(-1px);
}

.yz-roll:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #9a6f16;
}

.yz-roll:disabled {
    background: #205244;
    border-color: #0d3529;
    color: #9dc2b3;
    box-shadow: none;
    cursor: default;
}

.yz-status {
    margin: 0;
    text-align: center;
    color: #fff;
    font-size: 0.94rem;
    font-weight: 800;
}

.yz-note {
    margin: -6px 0 0;
    min-height: 1.15em;
    text-align: center;
    color: #a9cbbc;
    font-size: 0.8rem;
    font-weight: 600;
}

.yz-sheet {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    padding: 8px;
    border: 1px solid var(--cg-line);
    border-radius: 12px;
    background: var(--cg-panel);
    box-shadow: 0 6px 16px rgba(33, 43, 40, 0.08);
}

.yz-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.yz-head,
.yz-foot,
.yz-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px 40px;
    align-items: center;
    gap: 4px;
    text-align: left;
}

.yz-wrap[data-mode="solo"] .yz-head,
.yz-wrap[data-mode="solo"] .yz-foot,
.yz-wrap[data-mode="solo"] .yz-row {
    grid-template-columns: minmax(0, 1fr) 40px;
}

.yz-wrap[data-mode="solo"] .yz-cpu {
    display: none;
}

.yz-head {
    padding: 2px 8px 4px;
    color: var(--cg-teal);
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.yz-head em,
.yz-foot .yz-cpu,
.yz-row .yz-cpu {
    text-align: right;
    font-style: normal;
}

.yz-row {
    flex: 1 1 auto;
    min-height: 44px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: #f2f5f1;
    color: var(--cg-ink);
    font: inherit;
    cursor: pointer;
    transition: background 0.1s ease, border-color 0.1s ease, transform 0.1s ease;
}

.yz-lab {
    overflow: hidden;
    font-size: 0.8rem;
    font-weight: 700;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.yz-row .yz-val,
.yz-foot .yz-val {
    text-align: right;
    font-size: 0.95rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.yz-row .yz-val {
    color: #9aa5a0;
}

.yz-row .yz-cpu,
.yz-foot .yz-cpu {
    color: var(--cg-blue);
    font-size: 0.78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.yz-row.yz-pot {
    border-color: #a8cfbf;
    background: #e7f5ee;
    cursor: pointer;
}

.yz-row.yz-pot .yz-val {
    color: var(--cg-green);
}

.yz-row.yz-pot:hover {
    border-color: var(--cg-green);
    background: #d6efe3;
    transform: translateY(-1px);
}

.yz-row.yz-pot.yz-zero .yz-val {
    color: #b07a76;
}

.yz-row.yz-pot.yz-zero {
    border-color: var(--cg-line);
    background: #f4f5f3;
}

.yz-row.yz-pot.yz-zero:hover {
    border-color: var(--cg-red);
    background: #f7ecea;
    transform: translateY(-1px);
}

.yz-row.yz-filled {
    background: var(--cg-ink);
    border-color: var(--cg-ink);
    color: #fff;
    cursor: default;
}

.yz-row.yz-filled .yz-val {
    color: var(--yz-gold);
}

.yz-row.yz-filled .yz-cpu {
    color: #9dbbe8;
}

.yz-row.yz-locked {
    opacity: 0.55;
    cursor: default;
}

.yz-row:disabled {
    transform: none;
}

.yz-foot {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 4px 8px;
    border-radius: 9px;
    background: #eef2ee;
    color: var(--cg-muted);
}

.yz-foot .yz-lab {
    color: var(--cg-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: normal;
}

.yz-bar {
    display: block;
    height: 5px;
    margin-top: 4px;
    border-radius: 99px;
    background: #d5dfd9;
    overflow: hidden;
}

.yz-bar b {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--cg-green), var(--cg-amber));
    transition: width 0.3s ease;
}

.yz-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    border: 1px solid #0f4433;
    border-radius: 12px;
    background: linear-gradient(120deg, #12503c, #0b3527);
    color: #d8ece3;
    box-shadow: var(--cg-shadow);
}

.yz-total span {
    display: block;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #8fbdab;
}

.yz-total strong {
    display: block;
    font-size: 1.7rem;
    line-height: 1.1;
    color: var(--yz-gold);
    font-variant-numeric: tabular-nums;
}

.yz-total-cpu {
    text-align: right;
}

.yz-total-cpu strong {
    color: #b7cef0;
    font-size: 1.35rem;
}

.yz-stats {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.yz-stat {
    flex: 1 1 0;
    min-width: 74px;
    padding: 8px 10px;
    border: 1px solid var(--cg-line);
    border-radius: 10px;
    background: var(--cg-panel);
    text-align: center;
}

.yz-stat span {
    display: block;
    color: var(--cg-muted);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.yz-stat strong {
    display: block;
    font-size: 1.1rem;
    font-variant-numeric: tabular-nums;
}

.yz-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(9, 30, 22, 0.62);
    z-index: 200;
}

.yz-overlay[hidden] {
    display: none;
}

.yz-dialog {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 86vh;
    overflow-y: auto;
    padding: 22px 24px;
    border-radius: 14px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    box-shadow: var(--cg-shadow);
}

.yz-dialog h2 {
    margin: 0 0 10px;
    padding-right: 44px;
    font-size: 1.2rem;
}

.yz-dialog ul {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.92rem;
    line-height: 1.45;
}

.yz-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    border: 1px solid var(--cg-line);
    border-radius: 9px;
    background: var(--cg-panel);
    color: var(--cg-ink);
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
}

.yz-close:hover {
    border-color: var(--cg-red);
    color: var(--cg-red);
}

.yz-final {
    margin: 6px 0 12px;
    text-align: center;
    color: var(--cg-green);
    font-size: 3rem;
    font-weight: 900;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.yz-lines {
    padding: 0;
    list-style: none;
    gap: 6px !important;
}

.yz-lines li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 7px 12px;
    border-radius: 8px;
    background: #f2f5f1;
    font-size: 0.86rem;
}

.yz-lines span {
    color: var(--cg-muted);
    font-weight: 700;
}

.yz-result-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
}

.yz-result-actions .yz-btn {
    flex: 1 1 0;
}

@media (max-width: 640px) {
    .yz-wrap {
        max-width: 100%;
        gap: 9px;
    }

    .yz-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .yz-stage {
        min-height: 236px;
        padding: 11px 10px 10px;
        gap: 10px;
    }

    .yz-hud {
        font-size: 0.66rem;
    }

    .yz-hud strong {
        font-size: 0.92rem;
    }

    .yz-dice {
        min-height: 62px;
    }

    .yz-die {
        border-radius: 13px;
    }

    .yz-roll {
        min-height: 48px;
        font-size: 0.94rem;
    }

    .yz-status {
        font-size: 0.88rem;
    }

    .yz-note {
        font-size: 0.74rem;
    }

    .yz-grid {
        gap: 6px;
    }

    .yz-sheet {
        padding: 6px;
    }

    .yz-head,
    .yz-foot,
    .yz-row {
        grid-template-columns: minmax(0, 1fr) 26px 34px;
    }

    .yz-wrap[data-mode="solo"] .yz-head,
    .yz-wrap[data-mode="solo"] .yz-foot,
    .yz-wrap[data-mode="solo"] .yz-row {
        grid-template-columns: minmax(0, 1fr) 34px;
    }

    .yz-row {
        min-height: 42px;
        padding: 4px 6px;
        border-radius: 8px;
    }

    .yz-lab {
        font-size: 0.72rem;
    }

    .yz-row .yz-val,
    .yz-foot .yz-val {
        font-size: 0.85rem;
    }

    .yz-row .yz-cpu,
    .yz-foot .yz-cpu {
        font-size: 0.7rem;
    }

    .yz-foot .yz-lab {
        font-size: 0.62rem;
    }

    .yz-total {
        padding: 8px 12px;
    }

    .yz-total strong {
        font-size: 1.45rem;
    }

    .yz-total-cpu strong {
        font-size: 1.15rem;
    }

    .yz-stat {
        min-width: 62px;
        padding: 6px 6px;
    }

    .yz-stat strong {
        font-size: 1rem;
    }

    .yz-dialog {
        padding: 18px 16px;
    }

    .yz-final {
        font-size: 2.4rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .yz-die.yz-tumble {
        animation: none;
    }
}
