@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@400;500;600;700&family=Nunito+Sans:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

:root {
    --bg: #ffffff;
    --text: #111111;
    --muted: #6e6e73;
    --line: #d8d8dc;
    --panel: #f5f5f7;
    --purple: #8a00ff;
    --pink: #ff008a;
    --orange: #ff5a00;
    --header-h: 62px;
    --ad-h: 82px;
    --page-max: 520px;
    --radius: 18px;
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
    min-height: 100dvh;
    overflow: hidden;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.brand-flash {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    background: var(--bg);
    opacity: 1;
    transition: opacity 120ms ease;
}

.brand-flash.is-hidden { opacity: 0; pointer-events: none; }
.brand-flash img { width: min(58vw, 280px); height: auto; }

.app-shell {
    height: 100dvh;
    max-width: var(--page-max);
    margin: 0 auto;
    display: grid;
    grid-template-rows: var(--header-h) minmax(0, 1fr) var(--ad-h);
    background: var(--bg);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
}

.app-header {
    display: grid;
    grid-template-columns: 48px 1fr 48px;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-bottom: 0;
}

.icon-button {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

.icon-button:active { background: var(--panel); }

.header-logo-picture { justify-self: center; display: grid; place-items: center; }
.header-logo {
    width: 112px;
    max-height: 48px;
    object-fit: contain;
}

.landing {
    min-height: 0;
    display: grid;
    grid-template-rows: minmax(190px, 38%) minmax(0, 62%);
}

.discovery {
    min-height: 0;
    padding: 28px 8px 0;
    display: grid;
    align-content: start;
    gap: 18px;
}

.discovery-section { min-width: 0; text-align: center; }

.discovery-title {
    margin: 0 0 2px;
    font-size: clamp(19px, 4.8vw, 22px);
    line-height: 1.05;
    font-weight: 400;
    letter-spacing: -0.02em;
}

.discovery-section[data-section-id="game"] .discovery-title { color: var(--purple); }
.discovery-section[data-section-id="dice"] .discovery-title { color: var(--pink); }
.discovery-section[data-section-id="random"] .discovery-title { color: var(--orange); }

.discovery-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 3px 3px 5px;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
}

.discovery-row::before,
.discovery-row::after {
    flex: 0 0 auto;
    color: var(--text);
    font-size: 17px;
    line-height: 1;
}
.discovery-row::before { content: "‹"; }
.discovery-row::after { content: "›"; }
.discovery-row::-webkit-scrollbar { display: none; }

.discovery-item {
    flex: 0 0 auto;
    border: 0;
    padding: 2px 0;
    background: transparent;
    color: var(--text);
    font-size: clamp(13px, 3.3vw, 15px);
    font-weight: 400;
    white-space: nowrap;
    cursor: pointer;
    scroll-snap-align: center;
}
.discovery-item:active { opacity: 0.55; }

.roll-zone {
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: clamp(42px, 7vh, 72px);
    padding: 0 18px 24px;
}

.die-button {
    --die-size: clamp(150px, 34vw, 184px);
    --die-half: calc(var(--die-size) / 2);
    --die-radius: calc(var(--die-size) * 0.13);
    --die-material-a: #fffefa;
    --die-material-b: #eeeae1;
    --die-edge: rgb(95 87 74 / 0.16);
    --die-pip: #2b2b2d;
    --die-shadow-color: rgb(0 0 0 / 0.18);

    width: clamp(170px, 38vw, 205px);
    aspect-ratio: 1;
    position: relative;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    perspective: 760px;
}

.die-shadow {
    position: absolute;
    left: 50%;
    bottom: 5%;
    width: 70%;
    height: 16%;
    border-radius: 50%;
    background: var(--die-shadow-color);
    filter: blur(13px);
    transform: translateX(-50%);
    opacity: 0.58;
    transition: transform 180ms ease, opacity 180ms ease, filter 180ms ease;
}

.die-tilt {
    width: var(--die-size);
    height: var(--die-size);
    position: relative;
    display: block;
    transform-style: preserve-3d;
    transform: rotateX(-12deg) rotateY(-14deg);
    transform-origin: 50% 58%;
    will-change: transform;
}

.die-cube {
    position: absolute;
    inset: 0;
    display: block;
    transform-style: preserve-3d;
    transition: transform 250ms cubic-bezier(0.22, 0.72, 0.2, 1);
    will-change: transform;
}

.die-side {
    position: absolute;
    inset: 0;
    display: block;
    border: 1px solid var(--die-edge);
    border-radius: var(--die-radius);
    background:
        radial-gradient(circle at 28% 20%, rgb(255 255 255 / 0.96), transparent 34%),
        linear-gradient(145deg, var(--die-material-a), var(--die-material-b));
    box-shadow:
        inset 8px 9px 13px rgb(255 255 255 / 0.58),
        inset -9px -10px 14px rgb(118 104 85 / 0.10);
    backface-visibility: hidden;
    overflow: hidden;
}

.die-side::before {
    content: "";
    position: absolute;
    inset: 0;
    background-repeat: no-repeat;
    pointer-events: none;
}

.die-side[data-face="1"]::before {
    background-image: var(--pip);
    background-position: 50% 50%;
}

.die-side[data-face="2"]::before {
    background-image: var(--pip), var(--pip);
    background-position: 29% 29%, 71% 71%;
}

.die-side[data-face="3"]::before {
    background-image: var(--pip), var(--pip), var(--pip);
    background-position: 28% 28%, 50% 50%, 72% 72%;
}

.die-side[data-face="4"]::before {
    background-image: var(--pip), var(--pip), var(--pip), var(--pip);
    background-position: 29% 29%, 71% 29%, 29% 71%, 71% 71%;
}

.die-side[data-face="5"]::before {
    background-image: var(--pip), var(--pip), var(--pip), var(--pip), var(--pip);
    background-position: 29% 29%, 71% 29%, 50% 50%, 29% 71%, 71% 71%;
}

.die-side[data-face="6"]::before {
    background-image: var(--pip), var(--pip), var(--pip), var(--pip), var(--pip), var(--pip);
    background-position: 29% 25%, 71% 25%, 29% 50%, 71% 50%, 29% 75%, 71% 75%;
}

.die-side {
    --pip: radial-gradient(circle at 42% 35%, #4b4b4e 0 16%, var(--die-pip) 30% 60%, #18181a 72% 100%);
    background-size: auto;
}

.die-side::before {
    background-size: 18% 18%;
}

.die-side-front  { transform: rotateY(0deg) translateZ(var(--die-half)); }
.die-side-back   { transform: rotateY(180deg) translateZ(var(--die-half)); }
.die-side-right  { transform: rotateY(90deg) translateZ(var(--die-half)); }
.die-side-left   { transform: rotateY(-90deg) translateZ(var(--die-half)); }
.die-side-top    { transform: rotateX(90deg) translateZ(var(--die-half)); }
.die-side-bottom { transform: rotateX(-90deg) translateZ(var(--die-half)); }

/* Standard D6: opposite pairs 1–6, 2–5, 3–4. Rotating one physical cube keeps visible neighbours real. */
.die-cube[data-value="1"] { transform: rotateX(-90deg); }
.die-cube[data-value="2"] { transform: rotateY(0deg); }
.die-cube[data-value="3"] { transform: rotateY(-90deg); }
.die-cube[data-value="4"] { transform: rotateY(90deg); }
.die-cube[data-value="5"] { transform: rotateY(180deg); }
.die-cube[data-value="6"] { transform: rotateX(90deg); }

.die-button:active .die-tilt {
    transform: rotateX(-12deg) rotateY(-14deg) scale(0.94);
}

.die-button.is-rolling .die-tilt {
    animation: cubiri-dice-roll 430ms cubic-bezier(0.22, 0.72, 0.2, 1);
}

.die-button.is-rolling .die-shadow {
    animation: cubiri-dice-shadow 430ms cubic-bezier(0.22, 0.72, 0.2, 1);
}

@keyframes cubiri-dice-roll {
    0%   { transform: rotateX(-12deg) rotateY(-14deg) scale(1) translateY(0); }
    28%  { transform: rotateX(-18deg) rotateY(-22deg) scale(0.94) translateY(0); }
    67%  { transform: rotateX(2deg) rotateY(18deg) scale(1.035) translateY(-10px); }
    84%  { transform: rotateX(-14deg) rotateY(-8deg) scale(0.99) translateY(2px); }
    100% { transform: rotateX(-12deg) rotateY(-14deg) scale(1) translateY(0); }
}

@keyframes cubiri-dice-shadow {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.58; filter: blur(13px); }
    28% { transform: translateX(-50%) scale(0.88); opacity: 0.46; filter: blur(11px); }
    67% { transform: translateX(-50%) scale(1.16); opacity: 0.30; filter: blur(17px); }
    84% { transform: translateX(-50%) scale(0.94); opacity: 0.54; filter: blur(12px); }
}

:root[data-theme="dark"] .die-button { --die-shadow-color: rgb(0 0 0 / 0.48); }

.roll-label {
    margin: 0 0 4px;
    border: 0;
    padding: 8px 18px;
    background: linear-gradient(90deg, var(--purple) 0 47%, var(--pink) 58%, var(--orange) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-size: clamp(23px, 6vw, 29px);
    line-height: 1;
    font-weight: 400;
    letter-spacing: -0.03em;
    cursor: pointer;
}

.ad-slot {
    display: grid;
    place-items: center;
    border: 1px solid var(--orange);
    background: var(--bg);
    color: var(--orange);
    font-size: clamp(26px, 7vw, 34px);
    font-weight: 300;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgb(0 0 0 / 0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}
.drawer-backdrop.is-open { opacity: 1; pointer-events: auto; }

.drawer {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(86vw, 390px);
    padding: 18px 20px 28px;
    background: var(--bg);
    transform: translateX(-102%);
    transition: transform 210ms ease;
    overflow-y: auto;
    box-shadow: 16px 0 48px rgb(0 0 0 / 0.12);
}
.drawer-backdrop.is-open .drawer { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.drawer-title { margin: 0; font-size: 23px; }
.drawer-section { margin: 20px 0; }
.drawer-section h3 { margin: 0 0 8px; font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.drawer-list { display: grid; }
.drawer-item { display: block; width: 100%; padding: 11px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }

.status-toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--ad-h) + 20px);
    z-index: 200;
    max-width: calc(100vw - 40px);
    padding: 10px 14px;
    border-radius: 999px;
    background: rgb(17 17 17 / 0.9);
    color: white;
    font-size: 13px;
    transform: translate(-50%, 14px);
    opacity: 0;
    pointer-events: none;
    transition: 160ms ease;
}
.status-toast.is-visible { transform: translate(-50%, 0); opacity: 1; }

@media (min-width: 700px) {
    body { background: #f5f5f7; }
    .app-shell { box-shadow: 5px 5px 0 rgb(0 0 0 / 0.18); }
}

@media (max-height: 620px) {
    :root { --header-h: 56px; --ad-h: 72px; }
    .landing { grid-template-rows: minmax(175px, 43%) minmax(0, 57%); }
    .discovery { padding-top: 18px; gap: 13px; }
    .die-button { width: 145px; }
    .roll-label { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:root[data-theme="light"] {
    --bg: #fafaf7;
    --text: #1c1c1e;
    --text-2: #636366;
    --text-3: #8e8e93;
    --muted: #636366;
    --line: #d8d8dc;
    --panel: #f5f5f2;
}

:root[data-theme="dark"] {
    --bg: #000000;
    --text: #f5f5f7;
    --muted: #a1a1a6;
    --line: #2c2c2e;
    --panel: #1c1c1e;
}

:root[data-theme="dark"] body { background: #000000; }
:root[data-theme="dark"] .ad-slot { background: #000000; }
:root[data-theme="dark"] .status-toast { background: rgb(245 245 247 / 0.92); color: #111111; }


/* 2026-08-11 visual scale pass: match approved mockup proportions */
:root {
    --header-h: 112px;
}

.app-header {
    grid-template-columns: 88px 1fr 88px;
    padding: 10px 20px;
}

.icon-button {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    font-size: 48px;
}

.header-logo {
    max-width: 276px;
    max-height: 84px;
}

.discovery {
    padding-top: 22px;
    gap: 24px;
}

.discovery-title {
    font-size: 40px;
}

.discovery-item,
.discovery-edge {
    font-size: 30px;
}

.roll-label {
    font-size: 32px;
}

.ad-slot {
    font-size: 52px;
}

.drawer,
.drawer button,
.drawer a,
.drawer-title,
.drawer-section-title {
    font-size: 28px;
}

@media (max-width: 430px) {
    :root {
        --header-h: 100px;
    }

    .app-header {
        grid-template-columns: 72px 1fr 72px;
        padding: 8px 12px;
    }

    .icon-button {
        width: 68px;
        height: 68px;
        font-size: 42px;
    }

    .header-logo {
        max-width: 230px;
        max-height: 74px;
    }

    .discovery-title {
        font-size: 36px;
    }

    .discovery-item,
    .discovery-edge {
        font-size: 26px;
    }

    .roll-label {
        font-size: 30px;
    }

    .ad-slot {
        font-size: 44px;
    }
}


/* 2026-08-15 restore approved landing branding */
.header-logo {
    width: 224px;
    max-width: 224px;
    max-height: 96px;
}

.discovery-section[data-section-id="game"] .discovery-title { color: var(--purple); }
.discovery-section[data-section-id="dice"] .discovery-title { color: var(--pink); }
.discovery-section[data-section-id="random"] .discovery-title { color: var(--orange); }

@media (max-width: 430px) {
    .header-logo {
        width: 224px;
        max-width: 224px;
        max-height: 92px;
    }
}

/* 2026-08-15 header icon tuning only: keep approved logo untouched */
.app-header {
    position: relative;
}

.app-header > .icon-button:first-child,
.app-header > .icon-button:last-child {
    position: absolute;
    top: 0;
    width: 88px;
    height: 88px;
    font-size: 56px;
}

.app-header > .icon-button:first-child {
    left: 2px;
}

.app-header > .icon-button:last-child {
    right: 2px;
}

@media (max-width: 430px) {
    .app-header > .icon-button:first-child,
    .app-header > .icon-button:last-child {
        top: 0;
        width: 78px;
        height: 78px;
        font-size: 50px;
    }

    .app-header > .icon-button:first-child { left: 0; }
    .app-header > .icon-button:last-child { right: 0; }
}

/* 2026-08-15 dice polish + header lock. No other layout changes. */
.app-header > .header-logo-picture {
    grid-column: 2;
    justify-self: center;
}

.die-button {
    --die-radius: calc(var(--die-size) * 0.055);
}

.die-side {
    border-color: rgb(95 87 74 / 0.12);
    box-shadow:
        inset 5px 5px 10px rgb(255 255 255 / 0.50),
        inset -7px -8px 12px rgb(118 104 85 / 0.09),
        0 0 1px rgb(95 87 74 / 0.12);
}

.die-side {
    --pip: radial-gradient(
        circle at 42% 35%,
        #55565a 0 13%,
        #36373a 22%,
        var(--die-pip) 42% 56%,
        #151517 64%,
        rgb(0 0 0 / 0.20) 68%,
        transparent 72% 100%
    );
}

.die-cube {
    transition-duration: 460ms;
}

.die-button.is-rolling .die-tilt {
    animation-duration: 800ms;
}

.die-button.is-rolling .die-shadow {
    animation-duration: 800ms;
}


/* 2026-08-15 real Three.js D6 renderer. Other page layout intentionally untouched. */
.app-header > .header-logo-picture { grid-column: 2; justify-self: center; }
.die-button { width: clamp(190px, 42vw, 230px); aspect-ratio: 1; perspective: none; }
.die-stage { display:block; width:100%; height:100%; position:relative; }
.die-stage canvas { display:block; width:100% !important; height:100% !important; pointer-events:none; }
.die-button .die-shadow, .die-button .die-tilt, .die-button .die-cube, .die-button .die-side { display:none !important; }


/* 2026-08-15 Content Area v1
   Protected zones intentionally untouched: header, roll-zone/die, roll-label, ad-slot. */
.discovery {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 14px 0 12px;
    gap: 18px;
    scroll-snap-type: y proximity;
}

.discovery::-webkit-scrollbar { display: none; }

.discovery-section {
    min-width: 0;
    text-align: left;
    scroll-snap-align: start;
}

.discovery-title {
    margin: 0 18px 8px;
    font-size: clamp(19px, 4.6vw, 23px);
    line-height: 1.1;
    font-weight: 650;
    letter-spacing: -0.025em;
    color: var(--text) !important;
}

.discovery-row {
    display: flex;
    justify-content: flex-start;
    align-items: stretch;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 2px 18px 8px;
    scrollbar-width: none;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-padding-inline: 18px;
}

.discovery-row::-webkit-scrollbar { display: none; }
.discovery-row::before,
.discovery-row::after { content: none !important; display: none !important; }

.discovery-item {
    --card-a: #f4efff;
    --card-b: #e7dcff;
    flex: 0 0 clamp(116px, 31vw, 142px);
    min-height: 88px;
    border: 1px solid rgb(92 75 130 / 0.10);
    border-radius: 20px;
    padding: 12px 12px 11px;
    background:
        radial-gradient(circle at 20% 12%, rgb(255 255 255 / 0.82), transparent 38%),
        linear-gradient(145deg, var(--card-a), var(--card-b));
    color: var(--text);
    box-shadow:
        0 7px 18px rgb(31 20 56 / 0.07),
        inset 0 1px 0 rgb(255 255 255 / 0.70);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 9px;
    text-align: left;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.discovery-item[data-source="games"]:nth-child(3n + 2) {
    --card-a: #fff2f7;
    --card-b: #ffe0ec;
}

.discovery-item[data-source="games"]:nth-child(3n + 3) {
    --card-a: #fff5e8;
    --card-b: #ffe6c6;
}

.discovery-item[data-source="dice"] {
    --card-a: #eef8ff;
    --card-b: #dceeff;
}

.discovery-item[data-source="dice"]:nth-child(3n + 2) {
    --card-a: #f2efff;
    --card-b: #e3dcff;
}

.discovery-item[data-source="random"] {
    --card-a: #fff4e9;
    --card-b: #ffe1c3;
}

.discovery-item[data-source="random"]:nth-child(3n + 2) {
    --card-a: #eefaff;
    --card-b: #d9f2ff;
}

.discovery-item[data-source="random"]:nth-child(3n + 3) {
    --card-a: #f5efff;
    --card-b: #e6dcff;
}

.discovery-item:active {
    opacity: 0.86;
    transform: scale(0.975);
    box-shadow:
        0 3px 10px rgb(31 20 56 / 0.07),
        inset 0 1px 0 rgb(255 255 255 / 0.65);
}

.discovery-item-icon {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    font-size: 27px;
    line-height: 1;
    font-weight: 700;
    letter-spacing: -0.05em;
}

.discovery-item-label {
    display: block;
    width: 100%;
    font-size: clamp(15px, 3.8vw, 18px);
    line-height: 1.06;
    font-weight: 650;
    letter-spacing: -0.025em;
}

:root[data-theme="dark"] .discovery-item {
    border-color: rgb(255 255 255 / 0.08);
    filter: brightness(0.68) saturate(0.82);
    box-shadow:
        0 8px 20px rgb(0 0 0 / 0.26),
        inset 0 1px 0 rgb(255 255 255 / 0.10);
}

:root[data-theme="dark"] .discovery-item-icon,
:root[data-theme="dark"] .discovery-item-label {
    filter: brightness(1.46) saturate(1.12);
}

@media (max-width: 430px) {
    .discovery {
        padding-top: 10px;
        gap: 15px;
    }

    .discovery-title {
        margin-inline: 16px;
        margin-bottom: 7px;
        font-size: 20px;
    }

    .discovery-row {
        padding-inline: 16px;
        scroll-padding-inline: 16px;
    }

    .discovery-item {
        flex-basis: 112px;
        min-height: 82px;
        border-radius: 18px;
        padding: 11px;
    }

    .discovery-item-icon {
        min-width: 31px;
        height: 31px;
        font-size: 25px;
    }

    .discovery-item-label {
        font-size: 15px;
    }
}

/* 2026-08-15 Typography Lab. Blind variants intentionally affect only Content Area and Tap to Roll. */
@font-face {
    font-family: "Cubiri Geist";
    src: url("https://unpkg.com/geist@1.7.1/dist/fonts/geist-sans/Geist-Variable.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

:root[data-typography-variant="A"] { --cubiri-test-font: "Manrope", sans-serif; }
:root[data-typography-variant="B"] { --cubiri-test-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", sans-serif; }
:root[data-typography-variant="C"] { --cubiri-test-font: "Inter", sans-serif; }
:root[data-typography-variant="D"] { --cubiri-test-font: "Nunito Sans", sans-serif; }
:root[data-typography-variant="E"] { --cubiri-test-font: "Cubiri Geist", "Inter", sans-serif; }
:root[data-typography-variant="F"] { --cubiri-test-font: "Plus Jakarta Sans", sans-serif; }

.discovery,
.discovery-title,
.discovery-item,
.discovery-item-label,
.roll-label {
    font-family: var(--cubiri-test-font, -apple-system, BlinkMacSystemFont, sans-serif);
}

/* Desktop grab-to-scroll stays part of the Content Area experiment. */
@media (hover: hover) and (pointer: fine) {
    .discovery-row {
        cursor: grab;
        user-select: none;
        -webkit-user-select: none;
    }
    .discovery-row.is-grabbing {
        cursor: grabbing;
        scroll-snap-type: none;
    }
    .discovery-row.is-grabbing .discovery-item { pointer-events: none; }
}

.typography-lab-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: grid;
    place-items: center;
    padding: 22px;
    background: rgb(0 0 0 / 0.24);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms ease;
}
.typography-lab-backdrop.is-open { opacity: 1; pointer-events: auto; }
.typography-lab {
    width: min(360px, 100%);
    border: 1px solid rgb(127 127 127 / 0.18);
    border-radius: 24px;
    padding: 18px;
    background: color-mix(in srgb, var(--surface, #fff) 94%, transparent);
    color: var(--text);
    box-shadow: 0 24px 70px rgb(0 0 0 / 0.22);
    transform: translateY(8px) scale(0.985);
    transition: transform 150ms ease;
}
.typography-lab-backdrop.is-open .typography-lab { transform: translateY(0) scale(1); }
.typography-lab-head { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.typography-lab-head h2 { margin:0; font: 650 20px/1.1 -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing:-0.02em; }
.typography-lab-close {
    width:34px; height:34px; border:0; border-radius:50%; background:rgb(127 127 127 / 0.12);
    color:var(--text); font:400 25px/1 -apple-system, BlinkMacSystemFont, sans-serif; cursor:pointer;
}
.typography-lab-note { margin:12px 0 16px; color:var(--muted); font:400 13px/1.35 -apple-system, BlinkMacSystemFont, sans-serif; }
.typography-lab-grid { display:grid; grid-template-columns:repeat(3, 1fr); gap:10px; }
.typography-variant {
    min-height:54px; border:1px solid var(--line); border-radius:16px; background:rgb(127 127 127 / 0.07);
    color:var(--text); font:650 18px/1 -apple-system, BlinkMacSystemFont, sans-serif; cursor:pointer;
    transition:transform 100ms ease, background 100ms ease, border-color 100ms ease;
}
.typography-variant:active { transform:scale(0.97); }
.typography-variant.is-active { background:rgb(112 76 255 / 0.15); border-color:rgb(112 76 255 / 0.42); }


/* 2026-08-15 Settings appearance toggle. */
.settings-section-title {
    margin: 18px 0 8px;
    color: var(--text);
    font: 650 14px/1.2 -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: -0.01em;
}

.theme-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 4px;
    border-radius: 16px;
    background: rgb(127 127 127 / 0.10);
}

.theme-option {
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text);
    font: 650 15px/1 -apple-system, BlinkMacSystemFont, sans-serif;
    cursor: pointer;
    transition: transform 100ms ease, background 120ms ease, box-shadow 120ms ease;
}

.theme-option:active { transform: scale(0.98); }

.theme-option.is-active {
    background: var(--bg);
    box-shadow:
        0 1px 4px rgb(0 0 0 / 0.10),
        inset 0 0 0 1px rgb(127 127 127 / 0.12);
}

:root[data-theme="dark"] .theme-option.is-active {
    background: #2c2c2e;
    box-shadow:
        0 1px 5px rgb(0 0 0 / 0.42),
        inset 0 0 0 1px rgb(255 255 255 / 0.08);
}


/* 2026-08-15 Cubiri Dark Mode 1.0
   Night atmosphere: dark space, colored glass cards, brighter card content,
   and a subtle Cubiri aura behind the primary die. */
:root[data-theme="dark"] {
    --bg: #111318;
    --text: #f7f7fa;
    --muted: rgb(247 247 250 / 0.70);
    --line: rgb(255 255 255 / 0.09);
    --panel: #181b22;
}

:root[data-theme="dark"] body,
:root[data-theme="dark"] .app-shell,
:root[data-theme="dark"] main,
:root[data-theme="dark"] .discovery,
:root[data-theme="dark"] .roll-zone,
:root[data-theme="dark"] .ad-slot {
    background: var(--bg);
}

/* Dark cards are their own palette, not dimmed light cards. */
:root[data-theme="dark"] .discovery-item {
    --card-a: #2d2840;
    --card-b: #201d31;
    color: rgb(255 255 255 / 0.95);
    border-color: rgb(255 255 255 / 0.10);
    filter: none;
    background:
        radial-gradient(circle at 18% 10%, rgb(255 255 255 / 0.10), transparent 40%),
        linear-gradient(145deg, var(--card-a), var(--card-b));
    box-shadow:
        0 7px 18px rgb(0 0 0 / 0.26),
        inset 0 1px 0 rgb(255 255 255 / 0.08);
}

:root[data-theme="dark"] .discovery-item[data-source="games"]:nth-child(3n + 2) {
    --card-a: #412634;
    --card-b: #2c1d27;
}

:root[data-theme="dark"] .discovery-item[data-source="games"]:nth-child(3n + 3) {
    --card-a: #41301f;
    --card-b: #2b2319;
}

:root[data-theme="dark"] .discovery-item[data-source="dice"] {
    --card-a: #243744;
    --card-b: #1b2933;
}

:root[data-theme="dark"] .discovery-item[data-source="dice"]:nth-child(3n + 2) {
    --card-a: #302a46;
    --card-b: #242036;
}

:root[data-theme="dark"] .discovery-item[data-source="random"] {
    --card-a: #44301f;
    --card-b: #2f241b;
}

:root[data-theme="dark"] .discovery-item[data-source="random"]:nth-child(3n + 2) {
    --card-a: #203b47;
    --card-b: #192c35;
}

:root[data-theme="dark"] .discovery-item[data-source="random"]:nth-child(3n + 3) {
    --card-a: #342646;
    --card-b: #261d35;
}

:root[data-theme="dark"] .discovery-item-icon,
:root[data-theme="dark"] .discovery-item-label {
    color: rgb(255 255 255 / 0.95);
    filter: none;
    opacity: 1;
}

:root[data-theme="dark"] .discovery-title {
    color: rgb(255 255 255 / 0.96) !important;
}

/* Subtle Cubiri-colored atmosphere behind the die. */
:root[data-theme="dark"] .roll-zone {
    position: relative;
    isolation: isolate;
}

:root[data-theme="dark"] .roll-zone::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 47%;
    width: clamp(320px, 68vw, 410px);
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background:
        radial-gradient(circle at 36% 42%, rgb(126 54 255 / 0.30), transparent 38%),
        radial-gradient(circle at 60% 48%, rgb(255 40 125 / 0.20), transparent 42%),
        radial-gradient(circle at 57% 64%, rgb(255 92 0 / 0.14), transparent 46%);
    filter: blur(28px);
    pointer-events: none;
    z-index: -1;
}

:root[data-theme="dark"] .die-button {
    --die-shadow-color: rgb(0 0 0 / 0.36);
}

:root[data-theme="dark"] .roll-label {
    position: relative;
    z-index: 1;
}


/* 2026-08-15 Light typography palette */
:root[data-theme="light"] .roll-label,
:root[data-theme="light"] .discovery-title,
:root[data-theme="light"] .discovery-item-label {
    color: var(--text);
}

:root[data-theme="light"] .status-toast,
:root[data-theme="light"] .typography-lab-note {
    color: var(--text-2);
}




/* 2026-08-15 Settings dark-mode cleanup */
:root[data-theme="dark"] .typography-lab-backdrop {
    background: rgb(4 6 10 / 0.58);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

:root[data-theme="dark"] .typography-lab {
    background: rgb(24 27 34 / 0.96);
    color: #f7f7fa;
    border-color: rgb(255 255 255 / 0.10);
    box-shadow:
        0 26px 80px rgb(0 0 0 / 0.46),
        inset 0 1px 0 rgb(255 255 255 / 0.04);
}

:root[data-theme="dark"] .typography-lab-head h2,
:root[data-theme="dark"] .settings-section-title {
    color: #f7f7fa;
}

:root[data-theme="dark"] .typography-lab-note {
    color: rgb(247 247 250 / 0.62);
}

:root[data-theme="dark"] .typography-lab-close {
    background: rgb(255 255 255 / 0.08);
    color: rgb(255 255 255 / 0.88);
}

:root[data-theme="dark"] .theme-toggle {
    background: #111318;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.05);
}

:root[data-theme="dark"] .theme-option {
    color: rgb(247 247 250 / 0.70);
}

:root[data-theme="dark"] .theme-option.is-active {
    background: #30333b;
    color: #ffffff;
    box-shadow:
        0 2px 7px rgb(0 0 0 / 0.40),
        inset 0 0 0 1px rgb(255 255 255 / 0.07);
}

:root[data-theme="dark"] .typography-variant {
    background: #252830;
    border-color: rgb(255 255 255 / 0.07);
    color: rgb(247 247 250 / 0.72);
}

:root[data-theme="dark"] .typography-variant.is-active {
    background: rgb(116 72 255 / 0.24);
    border-color: rgb(137 101 255 / 0.72);
    color: #ffffff;
}


/* 2026-08-15 Light Atmosphere A+C v3
   Restores the stronger asymmetric composition; overflow is deliberately visible
   so the atmosphere softly bleeds upward beneath the lower Content Area. */
:root[data-theme="light"] .roll-zone {
    position: relative;
    isolation: isolate;
    overflow: visible;
    background: transparent;
}

:root[data-theme="light"] .roll-zone::before {
    content: "";
    position: absolute;
    left: 39%;
    top: 26%;
    width: clamp(700px, 120vw, 940px);
    height: clamp(470px, 80vw, 640px);
    transform: translate(-50%, -50%) rotate(-13deg);
    border-radius: 50%;
    background: radial-gradient(
        ellipse at 24% 22%,
        rgb(255 188 88 / 0.16) 0%,
        rgb(255 205 132 / 0.095) 30%,
        rgb(255 225 184 / 0.045) 49%,
        transparent 76%
    );
    filter: blur(78px);
    pointer-events: none;
    z-index: -2;
}

:root[data-theme="light"] .roll-zone::after {
    content: "";
    position: absolute;
    inset: -34% -22% -2% -22%;
    background:
        radial-gradient(ellipse 36% 46% at 24% 52%,
            rgb(116 72 255 / 0.13) 0%,
            rgb(116 72 255 / 0.060) 42%,
            transparent 80%),
        radial-gradient(ellipse 37% 42% at 74% 55%,
            rgb(255 52 132 / 0.115) 0%,
            rgb(255 52 132 / 0.050) 43%,
            transparent 80%),
        radial-gradient(ellipse 42% 36% at 63% 26%,
            rgb(255 126 45 / 0.105) 0%,
            rgb(255 126 45 / 0.043) 45%,
            transparent 82%);
    filter: blur(60px);
    pointer-events: none;
    z-index: -1;
}

:root[data-theme="light"] .die-button {
    --die-shadow-color: rgb(72 62 58 / 0.15);
}



/* 2026-08-15 Light cards: porcelain pass v2 */
:root[data-theme="light"] .discovery-item {
    border-color: rgb(74 72 80 / 0.085);
    background:
        radial-gradient(
            ellipse at 12% 8%,
            rgb(255 255 255 / 0.98) 0%,
            rgb(255 255 255 / 0.78) 20%,
            rgb(255 255 255 / 0.26) 42%,
            transparent 58%
        ),
        linear-gradient(
            150deg,
            color-mix(in srgb, var(--card-a) 72%, white 28%) 0%,
            color-mix(in srgb, var(--card-a) 78%, white 22%) 44%,
            color-mix(in srgb, var(--card-b) 86%, white 14%) 100%
        );
    box-shadow:
        0 2px 4px rgb(34 30 42 / 0.055),
        0 5px 11px rgb(34 30 42 / 0.045),
        inset 0 1px 0 rgb(255 255 255 / 0.96),
        inset 0 -1px 0 rgb(80 72 96 / 0.030);
}

:root[data-theme="light"] .discovery-item:active {
    box-shadow:
        0 1px 3px rgb(34 30 42 / 0.05),
        inset 0 1px 0 rgb(255 255 255 / 0.92);
}

/* 2026-08-15 Light tiles: Cubiri Liquid Glass v1 */
:root[data-theme="light"] .discovery-item{
 position:relative; overflow:hidden;
 border:1px solid rgb(255 255 255 / .82);
 background:
  linear-gradient(135deg,rgb(255 255 255 / .54),rgb(255 255 255 / .14) 46%,rgb(255 255 255 / .30)),
  linear-gradient(145deg,color-mix(in srgb,var(--card-a) 38%,transparent),color-mix(in srgb,var(--card-b) 48%,transparent));
 -webkit-backdrop-filter:blur(24px) saturate(1.55) brightness(1.06);
 backdrop-filter:blur(24px) saturate(1.55) brightness(1.06);
 box-shadow:
  0 10px 24px rgb(37 31 52 / .10),
  inset 1px 1px 0 rgb(255 255 255 / .98),
  inset -1px -1px 0 rgb(64 55 80 / .09);
}
:root[data-theme="light"] .discovery-item::before{
 content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none;
 background:
  radial-gradient(ellipse at 20% 5%,rgb(255 255 255 / .95),transparent 38%),
  linear-gradient(115deg,transparent 22%,rgb(255 255 255 / .42) 43%,transparent 61%);
 opacity:.72;
}
:root[data-theme="light"] .discovery-item::after{
 content:""; position:absolute; inset:1px; border-radius:inherit; pointer-events:none;
 box-shadow:
  inset 0 1px 1px rgb(255 255 255 / .90),
  inset 0 -1px 1px rgb(46 37 62 / .10),
  inset 1px 0 1px rgb(255 255 255 / .50);
}
:root[data-theme="light"] .discovery-item-icon,
:root[data-theme="light"] .discovery-item-label{position:relative;z-index:2;}

/* 2026-08-15 Light tiles: Liquid Glass color boost v1 */
:root[data-theme="light"] .discovery-item[data-source="games"] {
    --glass-tint-a: rgb(120 86 255 / 0.30);
    --glass-tint-b: rgb(175 128 255 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="games"]:nth-child(3n + 2) {
    --glass-tint-a: rgb(255 72 142 / 0.30);
    --glass-tint-b: rgb(255 150 186 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="games"]:nth-child(3n + 3) {
    --glass-tint-a: rgb(255 154 46 / 0.31);
    --glass-tint-b: rgb(255 205 112 / 0.17);
}
:root[data-theme="light"] .discovery-item[data-source="dice"] {
    --glass-tint-a: rgb(80 170 255 / 0.29);
    --glass-tint-b: rgb(145 205 255 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="dice"]:nth-child(3n + 2) {
    --glass-tint-a: rgb(136 96 255 / 0.29);
    --glass-tint-b: rgb(188 160 255 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="random"] {
    --glass-tint-a: rgb(255 147 58 / 0.29);
    --glass-tint-b: rgb(255 196 118 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="random"]:nth-child(3n + 2) {
    --glass-tint-a: rgb(53 190 220 / 0.29);
    --glass-tint-b: rgb(133 225 240 / 0.16);
}
:root[data-theme="light"] .discovery-item[data-source="random"]:nth-child(3n + 3) {
    --glass-tint-a: rgb(166 92 255 / 0.29);
    --glass-tint-b: rgb(207 157 255 / 0.16);
}

:root[data-theme="light"] .discovery-item {
    background:
        linear-gradient(
            135deg,
            rgb(255 255 255 / 0.34) 0%,
            rgb(255 255 255 / 0.07) 42%,
            rgb(255 255 255 / 0.13) 100%
        ),
        radial-gradient(
            ellipse at 76% 88%,
            var(--glass-tint-a, rgb(120 86 255 / 0.28)) 0%,
            var(--glass-tint-b, rgb(175 128 255 / 0.15)) 54%,
            transparent 82%
        ),
        linear-gradient(
            145deg,
            color-mix(in srgb, var(--card-a) 26%, transparent),
            color-mix(in srgb, var(--card-b) 34%, transparent)
        );
    -webkit-backdrop-filter: blur(24px) saturate(1.85) brightness(1.03);
    backdrop-filter: blur(24px) saturate(1.85) brightness(1.03);
}

:root[data-theme="light"] .discovery-item::before { opacity: 0.54; }

/* 2026-08-15 Restore Cubiri gradient to Tap to Roll */
:root[data-theme="light"] .roll-label {
    background: linear-gradient(
        90deg,
        rgb(120 86 255) 0%,
        rgb(120 86 255) 28%,
        rgb(255 72 142) 58%,
        rgb(255 154 46) 100%
    );
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
