.public-dice-tray {
    --tray-ink: #182749;
    --tray-blue: #294fcf;
    --tray-border: #bcc9e7;
    --tray-muted: #475778;
    --tray-line: #dce5f6;
    background: radial-gradient(ellipse at 82% 12%, #e2eaff 0%, transparent 37rem),
        linear-gradient(#f4f7ff, #fff 41rem);
    color: var(--tray-ink);
    padding-block: clamp(1.35rem, 4vw, 3rem) 2.5rem;
}

.tray-shell { max-width: 70rem; }
.tray-intro { margin-block-end: clamp(1rem, 2.6vw, 1.6rem); }
.tray-intro h1 { margin: 0 0 .25rem; font-size: clamp(2.2rem, 5vw, 3.35rem); line-height: 1.1; }
.tray-intro p { margin: 0; color: var(--tray-muted); font-size: 1.08rem; }
.tray-card {
    display: grid;
    grid-template-columns: minmax(0, 1.24fr) minmax(0, .76fr);
    border: 1px solid var(--tray-line);
    border-radius: 1.15rem;
    background: #fff;
    box-shadow: 0 .85rem 2.8rem #263f7910;
    overflow: hidden;
}
.tray-controls, .tray-result { min-width: 0; padding: clamp(1rem, 3vw, 1.75rem); }
.tray-controls { display: flex; flex-direction: column; gap: .8rem; }
.tray-controls fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.tray-controls legend, .tray-fields label { display: block; color: var(--tray-ink); font-weight: 650; font-size: .9rem; margin-bottom: .35rem; }
.tray-palette { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.tray-palette button, .tray-presets button {
    color: var(--tray-blue);
    background: #f6f8ff;
    border: 1px solid var(--tray-border);
    border-radius: .6rem;
    line-height: 1.2;
    font: inherit;
    font-weight: 650;
}
.tray-palette button { min-height: 58px; display: grid; place-content: center; justify-items: center; gap: .16rem; padding: .27rem .1rem; font-size: .8rem; }
.tray-palette button:hover:not(:disabled), .tray-presets button:hover { background: #e9efff; border-color: #6c83c6; }
.tray-die-icon { display: block; width: 1.35rem; height: 1.35rem; color: var(--tray-blue); background: currentColor; }
.tray-die-icon[data-faces="4"] { clip-path: polygon(50% 2%, 98% 93%, 2% 93%); }
.tray-die-icon[data-faces="6"] { clip-path: polygon(50% 2%, 93% 26%, 93% 75%, 50% 98%, 7% 75%, 7% 26%); }
.tray-die-icon[data-faces="8"] { clip-path: polygon(50% 2%, 91% 50%, 50% 98%, 9% 50%); }
.tray-die-icon[data-faces="10"], .tray-die-icon[data-faces="100"] { clip-path: polygon(50% 1%, 97% 48%, 76% 77%, 50% 98%, 24% 77%, 3% 48%); }
.tray-die-icon[data-faces="12"] { clip-path: polygon(50% 1%, 95% 34%, 78% 91%, 22% 91%, 5% 34%); }
.tray-die-icon[data-faces="20"] { clip-path: polygon(50% 0, 94% 23%, 97% 71%, 50% 100%, 3% 71%, 6% 23%); }
.tray-die-icon[data-faces="100"] { color: #5146ab; }
.tray-groups, .tray-breakdown { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: .32rem; }
.tray-groups button {
    min-height: 44px;
    padding: .2rem .75rem;
    border: 1px solid #ccd8f4;
    border-radius: 1.4rem;
    color: var(--tray-ink);
    background: #edf2ff;
    font: inherit;
    font-size: .83rem;
    font-weight: 650;
}
.tray-groups button:hover { background: #dce6ff; }
.tray-groups span { margin-inline-start: .28rem; color: var(--tray-muted); }
.tray-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(5.6rem, .37fr); gap: .6rem; }
.tray-fields input {
    color: var(--tray-ink);
    background: #fff;
    border: 1px solid #8798bb;
    border-radius: .55rem;
    min-height: 44px;
    width: 100%;
    padding: .35rem .65rem;
    font: inherit;
    font-variant-numeric: tabular-nums;
}
.tray-fields input[aria-invalid="true"] { border-color: #a42635; }
.tray-note, .tray-empty { color: var(--tray-muted); font-size: .875rem; margin: 0; }
.tray-error { color: #a42635; }
.tray-actions, .tray-presets, .tray-examples { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .7rem; }
.tray-actions .marketing-button { min-height: 44px; }
.tray-presets button { padding: .24rem .65rem; min-height: 44px; font-size: .83rem; text-align: left; }
.tray-presets small { display: block; margin-top: .1rem; color: var(--tray-muted); font-weight: 400; }
.public-dice-tray button:disabled, .public-dice-tray input:disabled { opacity: .55; cursor: default; }
.public-dice-tray :is(a,button,input,summary):focus-visible { outline: 2px solid #234bc4; outline-offset: 3px; }
.public-dice-tray .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.tray-result {
    background: radial-gradient(ellipse at 46% 26%, #e7eeff, transparent 72%), #f5f8ff;
    border-inline-start: 1px solid var(--tray-line);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: .4rem;
}
.tray-result-summary { position: relative; width: 100%; min-width: 0; padding-inline: 44px; }
.tray-result-summary h2 { margin: 0; color: var(--tray-muted); font-size: .92rem; font-weight: 650; }
.tray-copy-latest { position: absolute; inset-block-start: -.15rem; inset-inline-end: 0; }
.tray-empty { margin-top: .35rem; }
.tray-stage { position: relative; isolation: isolate; display: grid; place-items: center; width: 100%; min-height: 12.25rem; }
.tray-art { position: relative; display: grid; place-items: center; width: min(100%, 12.25rem); aspect-ratio: 1; color: var(--tray-blue); }
.tray-orbit { position: absolute; inset: 10%; border: 1px solid #aabbe9; border-radius: 50%; background: radial-gradient(circle at 38% 25%, #fbfcff, #dce6ff 73%); }
.tray-orbit::before, .tray-orbit::after { position: absolute; border-radius: inherit; content: ''; }
.tray-orbit::before { inset: 10%; border: 1px solid #bcccf1; }
.tray-orbit::after { inset: -10%; border: 1px dashed #9daee07d; }
.tray-illustration { width: 69%; position: relative; display: block; }
.tray-spark { position: absolute; width: 9%; aspect-ratio: 1; clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%); }
.tray-spark-mint { right: 12%; top: 12%; background: #22886c; }
.tray-spark-gold { left: 13%; top: 27%; width: 7%; background: #b67419; }
.tray-spark-lilac { right: 15%; bottom: 16%; width: 6%; background: #7360bf; }
.tray-natural .tray-spark-mint { background: #a96715; scale: 1.35; }
.tray-total { margin: 0; font-size: clamp(2.35rem, 5.9vw, 3.7rem); line-height: 1.05; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.045em; }
.tray-result-expression { margin: .14rem 0 .15rem; overflow-wrap: anywhere; color: var(--tray-blue); font-weight: 650; }
.tray-breakdown { justify-content: center; }
.tray-breakdown li { display: flex; align-items: baseline; gap: .23rem; color: var(--tray-ink); background: #fff; border: 1px solid var(--tray-line); border-radius: .4rem; padding: .19rem .38rem; }
.tray-breakdown small { color: var(--tray-muted); font-size: .74rem; }
.tray-breakdown .tray-dropped strong { text-decoration: line-through; }

.tray-history, .tray-help { background: #fff; border: 1px solid var(--tray-line); border-radius: .85rem; margin-top: 1rem; padding: .75rem clamp(.8rem, 2vw, 1.25rem); }
.tray-history-heading { display: flex; gap: .45rem; justify-content: space-between; align-items: center; }
.tray-history h2 { font-size: 1.1rem; margin: 0; }
.tray-history-heading + .tray-note { margin-top: .3rem; }
.tray-history ol { list-style: none; padding: 0; margin: .25rem 0 0; }
.tray-history li { display: grid; grid-template-columns: minmax(1.9rem, max-content) minmax(0, 1fr) auto; gap: 0 .45rem; align-items: center; border-top: 1px solid var(--tray-line); }
.tray-history li span { overflow-wrap: anywhere; color: var(--tray-muted); }
.tray-history li strong { color: var(--tray-ink); font-variant-numeric: tabular-nums; }
.tray-history-actions { display: flex; gap: .15rem; }
.tray-history-error { grid-column: 1 / -1; padding-block-end: .5rem; }
.tray-icon-button {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--tray-blue);
    background: transparent;
    border: 0;
    border-radius: .55rem;
    cursor: pointer;
}
.tray-icon-button svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tray-icon-button:hover { background: #e9efff; }
.tray-clear-history:hover { color: #a42635; background: #fff1f2; }
.tray-text-button { min-height: 44px; color: var(--tray-blue); background: none; border: 0; padding: .15rem .4rem; font: inherit; font-size: .85rem; font-weight: 650; }
.tray-text-button:hover:not(:disabled) { text-decoration: underline; text-underline-offset: .14em; }
.tray-help summary { cursor: pointer; font-weight: 650; min-height: 44px; align-content: center; }
.tray-help p { margin: .3rem 0 0; color: var(--tray-muted); }
.tray-help code { color: var(--tray-ink); }
.tray-gameboard { margin: 1.15rem 0 0; }

@media (max-width: 700px) {
    .tray-card { grid-template-columns: minmax(0, 1fr); }
    .tray-controls { gap: .65rem; }
    .tray-result { display: grid; grid-template-columns: minmax(0, 1fr); gap: .25rem; text-align: left; border-inline-start: 0; border-top: 1px solid var(--tray-line); padding-block: .62rem; }
    .tray-result-summary { grid-row: 1; padding-inline-start: 0; }
    .tray-stage { min-height: clamp(10rem, 44vw, 12.25rem); }
    .tray-art { width: clamp(8.4rem, 37vw, 10.5rem); }
    .tray-breakdown { justify-content: start; }
}
@media (max-width: 430px) {
    .tray-palette { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .tray-palette button { min-height: 44px; display: flex; align-items: center; justify-content: center; gap: .22rem; }
    .tray-die-icon { width: .85rem; height: .85rem; }
}
