:root {
    --dice-bg: #f6f1e8;
    --dice-paper: #fffdf9;
    --dice-ink: #243534;
    --dice-muted: #526966;
    --dice-teal: #087d73;
    --dice-teal-dark: #075f59;
    --dice-teal-soft: #e5f5f2;
    --dice-gold: #96620f;
    --dice-gold-soft: #fff3d7;
    --dice-rose: #bd3c73;
    --dice-line: #dfd5c5;
    --dice-shadow: 0 22px 58px rgba(34, 65, 61, .11);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    color: var(--dice-ink);
    font-family: "Sarabun", Tahoma, sans-serif;
    font-size: 18px;
    line-height: 1.7;
    background:
        radial-gradient(circle at 8% 3%, rgba(8, 125, 115, .12), transparent 27rem),
        radial-gradient(circle at 92% 18%, rgba(213, 154, 43, .12), transparent 25rem),
        var(--dice-bg);
}

button, select, input { font: inherit; }

.dice-page {
    width: min(100% - 32px, 1160px);
    margin: 0 auto;
    padding: 22px 0 46px;
}

.dice-site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.dice-logo img {
    display: block;
    width: min(330px, 60vw);
    height: auto;
}

.dice-home-link {
    display: inline-flex;
    align-items: center;
    min-height: 46px;
    padding: 8px 17px;
    border: 1px solid rgba(8, 125, 115, .25);
    border-radius: 999px;
    color: var(--dice-teal-dark);
    background: rgba(255, 255, 255, .72);
    font-weight: 700;
    text-decoration: none;
}

.dice-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(250px, .75fr);
    gap: 34px;
    align-items: center;
    padding: clamp(30px, 5vw, 62px);
    border: 1px solid rgba(8, 125, 115, .15);
    border-radius: 32px;
    background: linear-gradient(135deg, #fffdf9 5%, #e8f6f3 100%);
    box-shadow: var(--dice-shadow);
}

.dice-hero::after {
    content: "";
    position: absolute;
    right: -105px;
    bottom: -130px;
    width: 340px;
    height: 340px;
    border: 52px solid rgba(8, 125, 115, .07);
    border-radius: 50%;
}

.dice-kicker {
    margin: 0 0 clamp(22px, 2.2vw, 28px);
    color: var(--dice-rose);
    font-weight: 800;
    letter-spacing: .02em;
}

.dice-hero h1 {
    margin: 0;
    color: #123f3c;
    font-size: clamp(2.45rem, 6vw, 4.9rem);
    line-height: 1.08;
    letter-spacing: -.045em;
}

.dice-lead {
    max-width: 760px;
    margin: 22px 0 0;
    color: #50615f;
    font-size: clamp(1.05rem, 1.9vw, 1.35rem);
}

.dice-hero-art {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    min-height: 235px;
    isolation: isolate;
}

.dice-hero-art::before {
    content: "";
    position: absolute;
    z-index: -1;
    width: 92%;
    aspect-ratio: 1;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, .82) 0, rgba(229, 245, 242, .42) 47%, transparent 72%);
    filter: blur(8px);
}

.dice-hero-image {
    display: block;
    width: min(100%, 420px);
    height: auto;
    aspect-ratio: 1;
    object-fit: cover;
    object-position: center;
    border-radius: 34px;
    opacity: .95;
    filter: saturate(.84) contrast(.97);
    transform: rotate(-2deg);
    box-shadow: 0 24px 50px rgba(5, 95, 88, .2);
    -webkit-mask-image: radial-gradient(ellipse 74% 74% at center, #000 48%, rgba(0, 0, 0, .96) 66%, transparent 100%);
    mask-image: radial-gradient(ellipse 74% 74% at center, #000 48%, rgba(0, 0, 0, .96) 66%, transparent 100%);
}

.dice-intro,
.dice-daily-rules,
.dice-workspace,
.dice-result,
.dice-note {
    margin-top: 26px;
    border: 1px solid var(--dice-line);
    border-radius: 26px;
    background: rgba(255, 253, 249, .96);
    box-shadow: 0 12px 34px rgba(55, 50, 40, .07);
}

.dice-intro { padding: clamp(26px, 4vw, 46px); }

.dice-daily-rules {
    padding: clamp(24px, 4vw, 42px);
    border-top: 6px solid var(--dice-teal);
    background: linear-gradient(145deg, rgba(255, 253, 249, .98), rgba(229, 245, 242, .82));
}

.dice-rules-heading {
    max-width: 900px;
}

.dice-rules-heading h2 {
    margin: 0 0 12px;
    color: #123f3c;
    font-size: clamp(1.6rem, 3vw, 2.3rem);
    line-height: 1.28;
}

.dice-rules-heading > p:last-child {
    margin: 0;
    color: var(--dice-muted);
}

.dice-rules-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 24px;
}

.dice-rules-grid article {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 13px;
    align-items: start;
    min-width: 0;
    padding: 17px;
    border: 1px solid rgba(8, 125, 115, .18);
    border-radius: 17px;
    background: rgba(255, 255, 255, .82);
}

.dice-rules-grid article > span {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    color: #fff;
    background: var(--dice-teal);
    font-size: .86rem;
    font-weight: 800;
}

.dice-rules-grid strong {
    display: block;
    color: #174c48;
    line-height: 1.45;
}

.dice-rules-grid p {
    margin: 5px 0 0;
    color: var(--dice-muted);
    font-size: .92rem;
    line-height: 1.58;
}

.dice-rules-profile-note {
    margin: 16px 0 0;
    padding: 14px 17px;
    border-left: 5px solid var(--dice-gold);
    border-radius: 12px;
    color: #4f5f5c;
    background: rgba(255, 243, 215, .8);
    font-size: .94rem;
}

.dice-rules-profile-note strong { color: #714d0f; }

.dice-intro-grid {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: clamp(26px, 5vw, 60px);
}

.dice-section-label {
    margin: 0 0 8px;
    color: var(--dice-gold);
    font-weight: 800;
}

.dice-intro h2,
.dice-workspace h2,
.dice-result h2 {
    margin: 0 0 16px;
    color: #153f3c;
    font-size: clamp(1.75rem, 3.2vw, 2.55rem);
    line-height: 1.25;
}

.dice-intro p { margin: 0 0 13px; }

.dice-steps {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.dice-steps li {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 14px;
    align-items: center;
    padding: 14px;
    border-radius: 17px;
    background: var(--dice-teal-soft);
}

.dice-step-number {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 15px;
    color: white;
    background: var(--dice-teal);
    font-weight: 800;
}

.dice-workspace {
    display: grid;
    grid-template-columns: minmax(0, .95fr) minmax(300px, 1.05fr);
    gap: clamp(26px, 4vw, 52px);
    align-items: center;
    padding: clamp(24px, 4vw, 48px);
    border-top: 6px solid var(--dice-gold);
}

.dice-workspace-copy { min-width: 0; }

.dice-profile-card {
    margin: 0 0 22px;
    padding: 18px;
    border: 1px solid rgba(8, 125, 115, .18);
    border-radius: 18px;
    background: linear-gradient(145deg, rgba(229, 245, 242, .82), rgba(255, 253, 249, .94));
}

.dice-profile-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.dice-profile-current[hidden],
.dice-profile-editor[hidden],
.dice-daily-status[hidden],
.dice-today-history[hidden] { display: none; }

.dice-profile-current > div {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.dice-profile-current strong {
    color: #123f3c;
    font-size: 1.17rem;
    overflow-wrap: anywhere;
}

.dice-profile-eyebrow {
    color: var(--dice-muted);
    font-size: .86rem;
    font-weight: 700;
}

.dice-profile-change,
.dice-profile-input-row button,
.dice-history-list button {
    border: 1px solid rgba(8, 125, 115, .3);
    color: var(--dice-teal-dark);
    background: #fff;
    cursor: pointer;
    font-weight: 800;
    transition: border-color .18s ease, background .18s ease, color .18s ease, transform .18s ease;
}

.dice-profile-change {
    flex: 0 0 auto;
    min-height: 42px;
    padding: 7px 13px;
    border-radius: 12px;
    font-size: .9rem;
}

.dice-profile-editor > label {
    display: block;
    margin-bottom: 8px;
    color: #174c48;
    font-weight: 800;
}

.dice-profile-input-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.dice-profile-input-row input {
    min-width: 0;
    min-height: 50px;
    padding: 9px 14px;
    border: 2px solid #6f8f8a;
    border-radius: 13px;
    color: var(--dice-ink);
    background: #fff;
}

.dice-profile-input-row button {
    min-height: 50px;
    padding: 9px 17px;
    border: 0;
    border-radius: 13px;
    color: #fff;
    background: var(--dice-teal);
}

.dice-profile-editor > p {
    margin: 9px 0 0;
    color: var(--dice-muted);
    font-size: .88rem;
    line-height: 1.55;
}

.dice-daily-status {
    display: grid;
    gap: 2px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: 13px;
    color: #365653;
    background: rgba(255, 243, 215, .76);
}

.dice-daily-status strong { color: #795514; }
.dice-daily-status span { font-size: .85rem; line-height: 1.5; }

.dice-profile-message {
    margin: 12px 0 0;
    padding: 10px 12px;
    border-radius: 11px;
    color: #8e2450;
    background: #fff0f5;
    font-size: .9rem;
    font-weight: 700;
}

.dice-profile-message:empty { display: none; }

.dice-today-history {
    margin-top: 18px;
    padding: 15px;
    border: 1px solid rgba(213, 154, 43, .28);
    border-radius: 16px;
    background: rgba(255, 250, 240, .82);
}

.dice-history-heading {
    display: grid;
    gap: 1px;
    margin-bottom: 10px;
}

.dice-history-heading strong { color: #6f4e10; }
.dice-history-heading span { color: var(--dice-muted); font-size: .84rem; }

.dice-history-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.dice-history-list button {
    max-width: 100%;
    min-height: 40px;
    padding: 7px 12px;
    border-radius: 999px;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.dice-profile-change:hover,
.dice-history-list button:hover {
    border-color: var(--dice-teal);
    background: var(--dice-teal-soft);
    transform: translateY(-1px);
}

.dice-profile-input-row button:hover { background: var(--dice-teal-dark); transform: translateY(-1px); }

.dice-profile-input-row input:focus,
.dice-profile-change:focus-visible,
.dice-profile-input-row button:focus-visible,
.dice-history-list button:focus-visible {
    outline: 3px solid #087d73;
    outline-offset: 3px;
}

.dice-field label {
    display: block;
    margin-bottom: 10px;
    color: #174c48;
    font-size: 1.15rem;
    font-weight: 800;
}

.dice-select {
    width: 100%;
    min-height: 58px;
    padding: 10px 46px 10px 16px;
    border: 2px solid #6f8f8a;
    border-radius: 14px;
    color: var(--dice-ink);
    background: #fff;
}

.dice-select:focus,
.dice-button:focus-visible,
.dice-secondary:focus-visible {
    outline: 3px solid #087d73;
    outline-offset: 3px;
}

.dice-bridge {
    margin: 20px 0 16px;
    color: var(--dice-muted);
}

.dice-roll-reminder {
    margin: 18px 0 0;
    padding: 12px 14px;
    border-left: 5px solid var(--dice-rose);
    border-radius: 11px;
    color: #5f5056;
    background: #fff0f5;
    font-size: .92rem;
    line-height: 1.55;
}

.dice-roll-reminder strong { color: #8e2450; }

.dice-button,
.dice-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 800;
    transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.dice-button {
    width: 100%;
    padding: 12px 24px;
    border: 0;
    color: white;
    background: linear-gradient(135deg, #0a8e82, #05655f);
    box-shadow: 0 14px 26px rgba(5, 101, 95, .2);
    font-size: 1.22rem;
}

.dice-button:hover:not(:disabled),
.dice-secondary:hover { transform: translateY(-2px); }

.dice-button:disabled { cursor: not-allowed; opacity: .55; }

.dice-validation {
    min-height: 30px;
    margin: 10px 0 0;
    color: #a12b5c;
    font-weight: 700;
}

.dice-stage {
    position: relative;
    display: grid;
    place-items: center;
    width: min(100%, 440px);
    aspect-ratio: 1;
    margin: 0 auto;
    overflow: hidden;
    border-radius: 28px;
    background: #1d5451;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 18px 36px rgba(28, 74, 70, .18);
}

.dice-stage video,
.dice-stage img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity .22s ease;
}

.dice-stage video,
.dice-stage img[hidden] { opacity: 0; pointer-events: none; }
.dice-stage.is-rolling video { opacity: 1; }
.dice-stage.is-result img { opacity: 1; }

.dice-idle-mark {
    display: grid;
    place-items: center;
    width: 128px;
    height: 128px;
    border: 1px solid rgba(255,255,255,.28);
    border-radius: 34px;
    color: white;
    background: rgba(255,255,255,.11);
    font-size: 4.5rem;
}

.dice-stage.is-rolling .dice-idle-mark,
.dice-stage.is-result .dice-idle-mark { opacity: 0; }

.dice-rolling-label {
    position: absolute;
    z-index: 2;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: none;
    padding: 10px 16px;
    border-radius: 999px;
    color: white;
    background: rgba(0, 42, 39, .78);
    text-align: center;
    font-weight: 800;
}

.dice-stage.is-rolling .dice-rolling-label { display: block; }

.dice-result {
    scroll-margin-top: 18px;
    padding: clamp(26px, 4vw, 48px);
}

.dice-result[hidden] { display: none; }

.dice-result-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--dice-line);
}

.dice-pair-badge {
    flex: 0 0 auto;
    padding: 9px 16px;
    border-radius: 999px;
    color: #72500d;
    background: var(--dice-gold-soft);
    font-weight: 800;
}

.dice-result-owner {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 7px;
    margin: 22px 0 4px;
    color: var(--dice-teal-dark);
    font-size: clamp(1.05rem, 2vw, 1.28rem);
    font-weight: 700;
}

.dice-result-owner strong {
    color: #c4285d;
    font-size: clamp(1.3rem, 2.6vw, 1.75rem);
    font-weight: 900;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.dice-result-question {
    margin: 10px 0 10px;
    color: var(--dice-rose);
    font-size: clamp(1.2rem, 2.3vw, 1.55rem);
    font-weight: 800;
}

.dice-prediction {
    padding: clamp(20px, 3vw, 32px);
    border-left: 6px solid var(--dice-teal);
    border-radius: 18px;
    background: var(--dice-teal-soft);
    color: #25423f;
    font-size: clamp(1.08rem, 2vw, 1.3rem);
    white-space: pre-line;
}

.dice-original {
    margin-top: 18px;
    border: 1px solid var(--dice-line);
    border-radius: 16px;
    background: #fff;
}

.dice-original summary {
    padding: 14px 18px;
    color: var(--dice-teal-dark);
    cursor: pointer;
    font-weight: 800;
}

.dice-original p { margin: 0; padding: 0 18px 18px; white-space: pre-line; }

.dice-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.dice-secondary {
    padding: 10px 20px;
    border: 1px solid var(--dice-teal);
    color: var(--dice-teal-dark);
    background: #fff;
}

.dice-secondary.is-primary { color: white; background: var(--dice-teal); }

.dice-note {
    padding: 20px 24px;
    color: #655a4d;
    background: #fffaf0;
}

.dice-note strong { color: #81570e; }

.dice-error {
    margin-top: 18px;
    padding: 16px 20px;
    border: 1px solid #eab4c9;
    border-radius: 14px;
    color: #8e2450;
    background: #fff0f5;
}

.dice-error[hidden] { display: none; }

.dice-footer-wrap { margin-top: 28px; }

@media (max-width: 820px) {
    .dice-hero,
    .dice-intro-grid,
    .dice-rules-grid,
    .dice-workspace { grid-template-columns: 1fr; }
    .dice-hero-art { min-height: 210px; }
    .dice-hero-image { width: min(82vw, 390px); }
    .dice-workspace-copy { order: 1; }
    .dice-stage-wrap { order: 2; }
}

@media (max-width: 560px) {
    body { font-size: 17px; }
    .dice-page { width: min(100% - 20px, 1160px); padding-top: 12px; }
    .dice-site-header { align-items: flex-start; }
    .dice-home-link { min-height: 40px; padding: 6px 12px; font-size: .88rem; }
    .dice-hero { padding: 26px 22px; border-radius: 24px; }
    .dice-hero-art { min-height: 180px; }
    .dice-hero-image { width: min(88vw, 320px); border-radius: 26px; }
    .dice-profile-current { align-items: flex-start; }
    .dice-profile-input-row { grid-template-columns: 1fr; }
    .dice-profile-input-row button { width: 100%; }
    .dice-history-list { display: grid; }
    .dice-history-list button { width: 100%; border-radius: 12px; text-align: left; }
    .dice-intro, .dice-daily-rules, .dice-workspace, .dice-result { border-radius: 20px; }
    .dice-rules-grid article { padding: 15px; }
    .dice-result-header { display: block; }
    .dice-pair-badge { display: inline-flex; margin-top: 4px; }
    .dice-actions { display: grid; }
    .dice-secondary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
