@charset "utf-8";

:root {
    --bg-start: #f3f8ff;
    --bg-end: #fbfdff;
    --panel: rgba(255, 255, 255, 0.88);
    --panel-strong: #ffffff;
    --border: rgba(132, 168, 228, 0.22);
    --border-strong: rgba(112, 153, 227, 0.36);
    --text-primary: #1e2b45;
    --text-secondary: #60708f;
    --text-soft: #7e8ca7;
    --blue-strong: #2f6fe4;
    --blue-mid: #75a9ff;
    --blue-light: #dbe9ff;
    --blue-glow: rgba(75, 131, 239, 0.18);
    --gold: #d8a051;
    --gold-soft: #f5d39d;
    --coral: #ff7f6a;
    --shadow: 0 20px 45px rgba(77, 119, 180, 0.12);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", "Noto Sans Thai", sans-serif;
    color: var(--text-primary);
    background:
        radial-gradient(circle at top left, rgba(132, 183, 255, 0.22), transparent 32%),
        radial-gradient(circle at top right, rgba(195, 223, 255, 0.35), transparent 28%),
        linear-gradient(180deg, var(--bg-start) 0%, var(--bg-end) 100%);
}

body {
    padding: 32px;
}

button,
input,
textarea,
select {
    font: inherit;
}

button {
    cursor: pointer;
    border: 0;
}

.page-shell {
    max-width: 1360px;
    margin: 0 auto;
}

.hero-panel,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    padding: 28px 30px;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
}

.eyebrow,
.section-kicker {
    margin: 0 0 10px;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--blue-strong);
}

h1,
h2 {
    margin: 0;
    letter-spacing: -0.03em;
}

h1 {
    font-size: clamp(2rem, 3vw, 3rem);
}

h2 {
    font-size: 1.2rem;
}

.hero-copy {
    max-width: 720px;
    margin: 14px 0 0;
    color: var(--text-secondary);
    line-height: 1.7;
}

.workspace-grid {
    display: grid;
    grid-template-columns: minmax(420px, 0.95fr) minmax(420px, 1.05fr);
    gap: 24px;
}

.control-column,
.result-column {
    display: grid;
    gap: 20px;
    align-content: start;
}

.panel {
    padding: 24px;
    border-radius: var(--radius-lg);
}

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.field-label,
.field-block span,
.field-block > label {
    display: block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-weight: 600;
}

.main-textarea,
.text-input,
.select-input {
    width: 100%;
    border: 1px solid rgba(113, 152, 221, 0.22);
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.main-textarea {
    min-height: 280px;
    resize: vertical;
    padding: 18px 18px 20px;
    line-height: 1.7;
}

.text-input,
.select-input {
    min-height: 50px;
    padding: 0 16px;
}

.main-textarea:focus,
.text-input:focus,
.select-input:focus {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 4px var(--blue-glow);
}

.number-stepper {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px 52px;
    min-height: 50px;
    overflow: hidden;
    border: 1px solid rgba(113, 152, 221, 0.22);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.9);
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.number-stepper:focus-within {
    border-color: var(--blue-mid);
    box-shadow: 0 0 0 4px var(--blue-glow);
}

.number-stepper .text-input {
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    appearance: textfield;
}

.number-stepper .text-input::-webkit-inner-spin-button,
.number-stepper .text-input::-webkit-outer-spin-button {
    margin: 0;
    appearance: none;
}

.number-stepper-button {
    display: grid;
    place-items: center;
    padding: 0;
    border: 0;
    border-left: 1px solid rgba(113, 152, 221, 0.22);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 1.75rem;
    line-height: 1;
    cursor: pointer;
    transition: background 140ms ease, color 140ms ease;
}

.number-stepper-button:hover:not(:disabled) {
    background: rgba(113, 152, 221, 0.1);
    color: var(--blue-mid);
}

.number-stepper-button:focus-visible {
    position: relative;
    z-index: 1;
    outline: 2px solid var(--blue-mid);
    outline-offset: -3px;
}

.number-stepper-button:active:not(:disabled) {
    background: rgba(113, 152, 221, 0.18);
}

.number-stepper-button:disabled {
    color: var(--text-soft);
    cursor: not-allowed;
    opacity: 0.5;
}

.number-stepper:has(.text-input:disabled) {
    background: rgba(232, 238, 249, 0.72);
}

.form-grid,
.toggle-grid,
.favorite-editor,
.lock-editor-head,
.result-actions,
.favorite-actions,
.lock-rows {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.random-type-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
}

.random-type-grid .mode-card {
    min-height: 104px;
}

.group-settings {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid rgba(113, 152, 221, 0.16);
    border-radius: var(--radius-md);
    background: rgba(245, 249, 255, 0.78);
}

.group-settings .form-grid {
    margin-top: 0;
}

.number-settings {
    margin-top: 14px;
    padding: 16px;
    border: 1px solid rgba(113, 152, 221, 0.16);
    border-radius: var(--radius-md);
    background: rgba(245, 249, 255, 0.78);
}

#number_max_field {
    margin-top: 14px;
}

.group-fill-policy {
    display: block;
    margin-top: 14px;
}

.is-hidden {
    display: none !important;
}

.text-input:disabled {
    color: var(--text-soft);
    background: rgba(232, 238, 249, 0.72);
    cursor: not-allowed;
}

.toggle-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 18px;
}

.toggle-grid.single-toggle {
    grid-template-columns: minmax(0, 1fr);
}

.toggle-card,
.mode-card {
    position: relative;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(113, 152, 221, 0.18);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(243, 248, 255, 0.88));
}

.toggle-card input {
    inline-size: 22px;
    block-size: 22px;
    accent-color: var(--blue-strong);
}

.toggle-title,
.mode-name {
    display: block;
    font-weight: 700;
}

.toggle-caption,
.mode-description {
    display: block;
    margin-top: 4px;
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.mode-grid.random-type-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mode-card {
    text-align: left;
    min-height: 132px;
    transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.mode-card.is-active {
    border-color: rgba(47, 111, 228, 0.4);
    box-shadow: 0 16px 28px rgba(56, 108, 203, 0.14);
    transform: translateY(-2px);
}

.primary-button,
.secondary-button,
.ghost-button,
.mini-button,
.inline-lock-button {
    border-radius: 999px;
    font-weight: 700;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.mini-button:hover,
.inline-lock-button:hover,
.mode-card:hover {
    transform: translateY(-1px);
}

.primary-button {
    min-height: 52px;
    padding: 0 22px;
    color: #ffffff;
    background: linear-gradient(135deg, #3d7aee 0%, #6ca4ff 100%);
    box-shadow: 0 14px 24px rgba(52, 110, 211, 0.22);
}

.secondary-button,
.ghost-button,
.mini-button,
.inline-lock-button {
    min-height: 46px;
    padding: 0 18px;
}

.secondary-button {
    color: var(--blue-strong);
    background: rgba(218, 233, 255, 0.82);
    border: 1px solid rgba(100, 147, 236, 0.24);
}

.ghost-button,
.mini-button,
.inline-lock-button {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(115, 152, 218, 0.18);
}

.mini-button,
.inline-lock-button {
    min-height: 36px;
    padding: 0 14px;
    font-size: 0.9rem;
}

.danger-button {
    color: #c85755;
}

.favorite-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 14px;
}

.favorite-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-actions,
.result-stack {
    display: grid;
    gap: 14px;
}

.helper-text,
.empty-state {
    color: var(--text-secondary);
}

.lock-editor-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    margin-bottom: 14px;
}

.lock-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.helper-text {
    margin: 0;
    line-height: 1.6;
}

.lock-row {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(120, 159, 226, 0.18);
    background: rgba(255, 255, 255, 0.78);
}

.result-panel {
    min-height: 100%;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: rgba(217, 231, 255, 0.9);
    color: var(--blue-strong);
    font-weight: 700;
}

.validation-message {
    display: none;
    margin-top: 14px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    background: rgba(255, 239, 233, 0.92);
    color: #b85f54;
    border: 1px solid rgba(255, 168, 149, 0.42);
}

.validation-message.is-visible {
    display: block;
}

.round-block + .round-block {
    margin-top: 8px;
}

.round-title {
    margin: 10px 0 12px;
    color: var(--text-secondary);
    font-weight: 700;
}

.rank-list {
    display: grid;
    gap: 12px;
    max-height: 680px;
    overflow: auto;
    padding-right: 6px;
}

.rank-list::-webkit-scrollbar {
    width: 8px;
}

.rank-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(126, 162, 226, 0.4);
}

.rank-card {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 16px 20px;
    border-radius: 18px;
    border: 1px solid rgba(236, 207, 167, 0.48);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 250, 245, 0.96)),
        linear-gradient(90deg, rgba(249, 215, 176, 0.15), transparent 45%);
    box-shadow: 0 16px 30px rgba(214, 177, 130, 0.08);
    opacity: 0;
    transform: translateY(12px);
    animation: result-in 420ms ease forwards;
}

.rank-card.is-secondary {
    grid-template-columns: 90px minmax(0, 1fr);
    border-color: rgba(217, 225, 239, 0.92);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 252, 255, 0.96));
    box-shadow: 0 14px 28px rgba(98, 118, 163, 0.07);
}

.rank-accent {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--gold);
}

.rank-card.is-secondary .rank-accent {
    color: #8e98aa;
}

.rank-number {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.rank-laurel {
    font-size: 1.2rem;
    opacity: 0.76;
}

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

.rank-name {
    font-size: clamp(1.05rem, 1.4vw, 1.45rem);
    font-weight: 700;
}

.rank-meta {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.lock-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 240, 235, 0.9);
    color: var(--coral);
    font-weight: 700;
}

.unlock-lock-button {
    color: #c85755;
    border-color: rgba(232, 132, 117, 0.24);
    background: rgba(255, 239, 235, 0.9);
}

.rank-list.mode-gacha .rank-card {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(246, 242, 255, 0.96)),
        radial-gradient(circle at top right, rgba(121, 146, 255, 0.18), transparent 32%);
}

.rank-list.mode-card .rank-card,
.rank-list.mode-card {
    all: unset;
}

.rank-list.mode-card .rank-card {
    display: block;
}

.rank-list.mode-card {
    display: grid;
}

.rank-list.mode-card .rank-card {
    border-radius: 18px;
}

.rank-list.mode-card .rank-content {
    display: block;
}

.rank-list.mode-card .rank-meta {
    margin-top: 10px;
    justify-content: flex-start;
}

.rank-list.mode-card .rank-name {
    margin-bottom: 2px;
}

.rank-list.mode-card .rank-card.is-secondary {
    border-color: rgba(185, 197, 220, 0.84);
}

.rank-list.mode-card .rank-card {
    position: relative;
}

.rank-list.mode-card .rank-accent {
    justify-content: flex-start;
}

.rank-list.mode-card .rank-content {
    align-self: stretch;
}

.rank-list.mode-card .rank-card::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
}

.rank-list.mode-card {
    gap: 12px;
}

.rank-list.mode-card .rank-card:last-child {
    margin-bottom: 0;
}

.rank-list.mode-card .rank-card .rank-meta .inline-lock-button {
    background: rgba(255, 255, 255, 0.74);
}

.rank-list.mode-card {
    overflow: visible;
    max-height: none;
}

.rank-list.mode-card .rank-card {
    min-height: 88px;
}

.rank-list.mode-card .rank-card.is-secondary .rank-number {
    font-size: 1.6rem;
}

.rank-list.mode-card .rank-card.is-secondary .rank-name {
    font-size: 1.08rem;
}

.rank-list.mode-card .rank-card.is-secondary .rank-meta {
    gap: 8px;
}

.rank-list.mode-card .rank-card.is-secondary .lock-badge {
    font-size: 0.88rem;
}

.rank-list.mode-card .rank-card.is-secondary .inline-lock-button {
    font-size: 0.84rem;
}

.rank-list.mode-card .rank-card.is-secondary .rank-accent {
    gap: 6px;
}

.rank-list.mode-card .rank-card.is-secondary .rank-content {
    gap: 10px;
}

.rank-list.mode-card .rank-card.is-secondary::after {
    box-shadow: none;
}

.rank-list.mode-card .rank-card::after {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.rank-list.mode-gacha .rank-card::after {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(137, 154, 255, 0.05);
}

.rank-list.mode-card .rank-card {
    padding-right: 22px;
}

.rank-list.mode-gacha .rank-card .rank-name::before {
    content: "★ ";
    color: var(--gold);
}

.rank-list.mode-card .rank-card {
    background-clip: padding-box;
}

.rank-list.mode-card .rank-card:not(.is-secondary) {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 241, 0.95)),
        linear-gradient(90deg, rgba(248, 218, 172, 0.16), transparent 45%);
}

.rank-list.mode-card .rank-card.is-secondary {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 255, 0.95));
}

.rank-list.mode-card .rank-card .rank-accent {
    min-width: 60px;
}

.rank-list.mode-card .rank-card .rank-content {
    width: 100%;
}

.rank-list.mode-card .rank-card .rank-name {
    line-height: 1.3;
}

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

.group-card {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(113, 152, 221, 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 250, 255, 0.95)),
        linear-gradient(90deg, rgba(117, 169, 255, 0.12), transparent 48%);
    box-shadow: 0 14px 28px rgba(77, 119, 180, 0.08);
    opacity: 0;
    transform: translateY(12px);
    animation: result-in 420ms ease forwards;
}

.group-card-title {
    display: flex;
    align-items: center;
    min-height: 32px;
    margin-bottom: 12px;
    color: var(--blue-strong);
    font-weight: 800;
}

.group-member-list {
    display: grid;
    gap: 10px;
}

.group-member {
    display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(206, 221, 247, 0.72);
}

.group-member.is-empty {
    color: var(--text-soft);
    background: rgba(239, 244, 252, 0.72);
    border-style: dashed;
}

.group-member-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 28px;
    block-size: 28px;
    border-radius: 999px;
    background: rgba(217, 231, 255, 0.95);
    color: var(--blue-strong);
    font-weight: 800;
}

.group-member-name {
    min-width: 0;
    overflow-wrap: anywhere;
    font-weight: 700;
}

.group-member-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.duplicate-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(255, 240, 235, 0.9);
    color: var(--coral);
    font-size: 0.86rem;
    font-weight: 800;
}

.family-result-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.family-pair-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(113, 152, 221, 0.22);
    background:
        radial-gradient(circle at top right, rgba(118, 167, 255, 0.16), transparent 42%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(241, 247, 255, 0.94));
    box-shadow: 0 12px 24px rgba(77, 119, 180, 0.08);
    opacity: 0;
    transform: translateY(12px);
    animation: result-in 420ms ease forwards;
}

.family-person {
    min-width: 0;
}

.family-person strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 1.08rem;
}

.family-role {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    margin-bottom: 7px;
    padding: 0 8px;
    border-radius: 999px;
    background: rgba(217, 231, 255, 0.85);
    color: var(--blue-strong);
    font-size: 0.82rem;
    font-weight: 700;
}

.family-arrow + .family-person .family-role {
    background: rgba(255, 239, 228, 0.9);
    color: #cf735b;
}

.family-arrow {
    color: var(--blue-strong);
    font-size: 1.35rem;
    font-weight: 800;
}

.result-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    color: #ffffff;
    background: linear-gradient(135deg, #3d7aee, #75a9ff);
    font-weight: 800;
    white-space: nowrap;
}

.number-lock-action {
    cursor: pointer;
    border: 1px solid transparent;
    transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.number-lock-action:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(52, 110, 211, 0.2);
}

.number-lock-action.is-locked {
    background: linear-gradient(135deg, #f17d70, #ff9a85);
}

.family-number {
    justify-self: end;
}

.empty-state {
    margin: 0;
    padding: 14px 0 2px;
}

@keyframes result-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 1180px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    body {
        padding: 18px;
    }

    .hero-panel,
    .panel {
        padding: 20px;
        border-radius: 22px;
    }

    .hero-panel {
        flex-direction: column;
    }

    .form-grid,
    .toggle-grid,
    .favorite-actions,
    .result-actions,
    .mode-grid,
    .group-result-grid,
    .favorite-editor {
        grid-template-columns: 1fr;
    }

    .family-result-list {
        grid-template-columns: 1fr;
    }

    .lock-row,
    .lock-editor-head {
        grid-template-columns: 1fr;
    }

    .lock-actions {
        justify-content: stretch;
    }

    .lock-actions button {
        flex: 1 1 180px;
    }

    .family-pair-card {
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    }

    .family-number {
        grid-column: 1 / -1;
        justify-self: stretch;
    }

    .rank-card,
    .rank-card.is-secondary {
        grid-template-columns: 1fr;
    }

    .rank-content {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Favorite Lists — reference-card treatment */
.control-column > .saved-sets-panel {
    padding: 24px;
    overflow: hidden;
    border: 1px solid rgba(93, 137, 220, 0.18);
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 42px rgba(46, 94, 170, 0.11);
}

.saved-sets-head {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 38px;
    gap: 14px;
    align-items: center;
}

.saved-sets-mark {
    display: grid;
    place-items: center;
    inline-size: 46px;
    block-size: 46px;
    border-radius: 13px;
    color: #3169ee;
    background: linear-gradient(145deg, #edf3ff, #e6edff);
}

.saved-sets-mark svg {
    inline-size: 24px;
    block-size: 24px;
    fill: currentColor;
}

.saved-sets-heading h2 {
    color: #13285b;
    font-size: 1.3rem;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.saved-sets-heading p {
    margin: 4px 0 0;
    color: #7282a8;
    font-size: 0.85rem;
    font-weight: 600;
}

.saved-sets-toggle {
    display: grid;
    place-items: center;
    inline-size: 38px;
    block-size: 38px;
    padding: 0;
    border: 1px solid #dce5f6;
    border-radius: 50%;
    color: #376cf0;
    background: #ffffff;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 180ms ease;
}

.saved-sets-toggle:hover {
    border-color: #bfcff2;
    box-shadow: 0 7px 18px rgba(50, 105, 235, 0.12);
}

.saved-sets-toggle svg {
    inline-size: 20px;
    block-size: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 180ms ease;
}

.saved-sets-toggle[aria-expanded="false"] svg {
    transform: rotate(180deg);
}

.saved-sets-content {
    margin-top: 28px;
}

.saved-sets-content[hidden] {
    display: none;
}

.saved-sets-panel .favorite-editor {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-bottom: 18px;
}

.saved-sets-panel .field-block > span:first-child,
.saved-sets-panel .field-block > label {
    margin-bottom: 9px;
    color: #24375f;
    font-size: 0.88rem;
    font-weight: 700;
}

.favorite-control-shell {
    position: relative;
    display: block;
    margin: 0;
}

.favorite-control-shell > svg {
    position: absolute;
    z-index: 1;
    top: 50%;
    left: 14px;
    inline-size: 21px;
    block-size: 21px;
    color: #7181a8;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    transform: translateY(-50%);
    pointer-events: none;
}

.saved-sets-panel .favorite-control-shell .text-input,
.saved-sets-panel .favorite-control-shell .select-input {
    min-height: 54px;
    padding-left: 47px;
    border: 1px solid #d6e0f3;
    border-radius: 14px;
    color: #152957;
    background: #ffffff;
    font-weight: 600;
}

.favorite-load-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 94px;
    gap: 10px;
}

.favorite-select-shell {
    min-width: 0;
}

.favorite-load-button,
.favorite-save-button,
.favorite-manage-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.favorite-load-button:hover,
.favorite-save-button:hover,
.favorite-manage-button:hover {
    transform: translateY(-1px);
}

.favorite-load-button {
    min-height: 54px;
    padding: 0 12px;
    border: 1px solid #d6e0f3;
    border-radius: 14px;
    color: #2868ef;
    background: #ffffff;
}

.favorite-load-button svg,
.favorite-save-button svg,
.favorite-manage-button svg {
    inline-size: 21px;
    block-size: 21px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.favorite-save-button {
    width: 100%;
    min-height: 56px;
    padding: 0 18px;
    border-radius: 14px;
    color: #ffffff;
    background: linear-gradient(135deg, #5786f8 0%, #2f63ea 100%);
    box-shadow: 0 10px 22px rgba(47, 99, 234, 0.22);
    font-size: 0.96rem;
}

.favorite-manage-title {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    margin: 22px 0 14px;
    color: #7080a7;
    font-size: 0.85rem;
    font-weight: 700;
}

.favorite-manage-title::before,
.favorite-manage-title::after {
    content: "";
    height: 1px;
    background: #e0e7f4;
}

.saved-sets-panel .favorite-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.favorite-manage-button {
    min-width: 0;
    min-height: 50px;
    padding: 0 8px;
    border: 1px solid #d6e0f3;
    border-radius: 13px;
    color: #2d69ec;
    background: #ffffff;
    font-size: 0.76rem;
    line-height: 1.2;
}

.favorite-manage-button.is-danger {
    color: #df3b38;
    border-color: #f1c7c6;
}

.favorite-manage-button:focus-visible,
.favorite-load-button:focus-visible,
.favorite-save-button:focus-visible,
.saved-sets-toggle:focus-visible {
    outline: 3px solid rgba(61, 119, 238, 0.24);
    outline-offset: 2px;
}

@media (max-width: 430px) {
    .control-column > .saved-sets-panel {
        padding: 19px;
        border-radius: 23px;
    }

    .saved-sets-head {
        grid-template-columns: 42px minmax(0, 1fr) 36px;
        gap: 11px;
    }

    .saved-sets-mark {
        inline-size: 42px;
        block-size: 42px;
    }

    .saved-sets-heading h2 {
        font-size: 1.15rem;
    }

    .favorite-load-row {
        grid-template-columns: 1fr;
    }

    .saved-sets-panel .favorite-actions {
        grid-template-columns: 1fr;
    }

    .favorite-manage-button {
        min-height: 46px;
        font-size: 0.86rem;
    }
}

/* Mockup-aligned layout corrections */
@media (min-width: 861px) {
    .workspace-grid {
        grid-template-columns: 390px minmax(0, 1fr);
        gap: 20px;
    }

    .result-panel .panel-head h2 {
        font-size: clamp(2.4rem, 4vw, 3.75rem);
        line-height: 1.08;
    }
}

.control-column > .panel:first-child {
    position: static;
}

.control-column > .panel {
    min-width: 0;
}

.control-column > .panel:nth-child(1) {
    padding: 22px;
}

.control-column > .panel:nth-child(1) .panel-head {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(139, 166, 208, 0.24);
}

.control-column > .panel:nth-child(1) .panel-head h2 {
    font-size: 1.25rem;
}

.random-type-grid .mode-card {
    align-items: center;
    justify-content: center;
    min-height: 72px;
    padding: 10px 7px;
    text-align: center;
}

.random-type-grid .mode-description,
.control-column > .panel:nth-child(4) .mode-description {
    display: none;
}

.random-type-grid .mode-name {
    font-size: 0.78rem;
}

.control-column > .panel:nth-child(4) .mode-card {
    min-height: 54px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    text-align: center;
}

.control-column > .panel:nth-child(4) .mode-name {
    font-size: 0.82rem;
}

.lock-editor-head {
    grid-template-columns: 1fr;
    gap: 12px;
}

.lock-actions {
    justify-content: stretch;
}

.lock-actions button {
    flex: 1 1 145px;
}

.helper-text {
    font-size: 0.88rem;
}

.favorite-editor,
.favorite-actions {
    grid-template-columns: 1fr;
}

.favorite-actions {
    gap: 8px;
}

.result-panel {
    padding: 30px 34px;
    background:
        radial-gradient(circle at 90% 0%, rgba(100, 166, 255, 0.1), transparent 28%),
        rgba(255, 255, 255, 0.94);
}

.result-panel .panel-head {
    align-items: center;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(139, 166, 208, 0.28);
}

.result-panel .section-kicker {
    font-size: 0.84rem;
}

.result-actions {
    margin: 16px 0 18px;
}

.result-actions #btn_go {
    font-size: 1.05rem;
}

.result-stack:empty {
    display: grid;
    place-items: center;
    min-height: 380px;
    border: 1px dashed rgba(105, 152, 229, 0.3);
    border-radius: 18px;
    color: var(--text-secondary);
    text-align: center;
}

.result-stack:empty::before {
    max-width: 280px;
    content: "พร้อมสุ่มแล้ว\A\A กดเริ่มสุ่มเพื่อดูผลลัพธ์ที่นี่";
    white-space: pre-line;
    font-size: 1rem;
    line-height: 1.7;
}

@media (max-width: 860px) {
    .control-column > .panel:nth-child(1) {
        padding: 18px;
    }

    .random-type-grid .mode-card {
        min-height: 62px;
    }

    .result-panel {
        padding: 22px 18px;
    }

    .result-panel .panel-head {
        padding-bottom: 15px;
    }

    .result-panel .panel-head h2 {
        font-size: 2rem;
    }

    .result-stack:empty {
        min-height: 240px;
    }
}

/* Keep the Favorite Lists card above legacy compact-control overrides. */
.control-column > article.panel.saved-sets-panel {
    padding: 24px;
    border-radius: 28px;
}

.saved-sets-panel .favorite-actions #btn_delete_favorite {
    grid-column: auto;
    justify-self: stretch;
    padding: 0 8px;
}

@media (max-width: 430px) {
    .control-column > article.panel.saved-sets-panel {
        padding: 19px;
        border-radius: 23px;
    }

    .saved-sets-panel .favorite-actions #btn_delete_favorite {
        min-height: 46px;
    }
}

/* Compact controls: lock editor, saved sets, and number locking. */
.control-column > .panel:nth-child(3) {
    padding: 20px;
}

.control-column > .panel:nth-child(3) .panel-head {
    margin-bottom: 10px;
}

.lock-editor-head {
    gap: 10px;
    margin-bottom: 12px;
}

.lock-editor-head .helper-text {
    padding: 10px 12px;
    border-left: 3px solid var(--blue-mid);
    border-radius: 8px;
    background: rgba(238, 246, 255, 0.78);
    font-size: 0.82rem;
    line-height: 1.5;
}

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

.lock-actions button {
    min-height: 40px;
    padding: 0 10px;
    font-size: 0.84rem;
}

.lock-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 13px;
    border-radius: 13px;
    background: #fbfdff;
    box-shadow: none;
}

.lock-row .field-block span {
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.lock-row .select-input {
    min-height: 42px;
    padding: 0 10px;
}

.lock-row .lock-row-remove {
    grid-column: 1 / -1;
    justify-self: end;
    min-height: 32px;
    padding: 0 12px;
    color: #d25656;
    border-color: rgba(218, 91, 91, 0.2);
    background: #fff7f7;
}

.lock-rows .empty-state {
    padding: 13px;
    border: 1px dashed rgba(112, 153, 227, 0.34);
    border-radius: 12px;
    background: rgba(249, 252, 255, 0.86);
    font-size: 0.84rem;
}

.control-column > .panel:nth-child(2) {
    padding: 18px;
}

.control-column > .panel:nth-child(2) .panel-head {
    margin-bottom: 10px;
}

.favorite-editor {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 10px;
}

.favorite-editor .field-block span {
    margin-bottom: 5px;
    font-size: 0.8rem;
}

.favorite-editor .text-input,
.favorite-editor .select-input {
    min-height: 40px;
}

.favorite-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.favorite-actions button {
    min-height: 38px;
    padding: 0 8px;
    font-size: 0.78rem;
    line-height: 1.2;
}

.favorite-actions #btn_delete_favorite {
    grid-column: 1 / -1;
    justify-self: start;
    padding-inline: 14px;
}

.number-lock-action {
    border: 1px dashed rgba(255, 255, 255, 0.55);
    background: linear-gradient(135deg, #4b8dff, #206ce8);
}

.number-lock-action::after {
    content: " · กดเพื่อเปลี่ยน";
    font-size: 0.72rem;
    font-weight: 600;
    opacity: 0.82;
}

.number-lock-action.is-locked {
    background: linear-gradient(135deg, #f17d70, #ff9a85);
}

@media (max-width: 860px) {
    .lock-actions {
        grid-template-columns: 1fr;
    }

    .favorite-actions button {
        min-height: 42px;
    }

    .number-lock-action::after {
        content: "";
    }
}

.group-member-meta .number-lock-action,
.group-member-meta .inline-lock-button {
    min-height: 30px;
    font-size: 0.75rem;
}

.family-lock-action {
    grid-column: 1 / -1;
    justify-self: start;
}

.group-card-title {
    justify-content: space-between;
    gap: 10px;
}

.group-number-action::after {
    content: "";
}

.group-number-action {
    min-height: 32px;
    padding: 0 10px;
    font-size: 0.75rem;
}

@media (max-width: 860px) {
    .family-lock-action {
        justify-self: stretch;
    }
}

/* Refined dashboard presentation */
:root {
    --bg-start: #edf6ff;
    --bg-end: #f9fbff;
    --panel: rgba(255, 255, 255, 0.94);
    --text-primary: #132553;
    --text-secondary: #64749a;
    --blue-strong: #1467ee;
    --blue-mid: #4f96ff;
    --blue-glow: rgba(28, 107, 239, 0.16);
    --shadow: 0 16px 36px rgba(53, 103, 181, 0.1);
    --radius-lg: 22px;
    --radius-md: 14px;
    --radius-sm: 10px;
}

body {
    padding: 24px;
    background:
        radial-gradient(circle at 5% 0%, rgba(152, 204, 255, 0.28), transparent 30%),
        linear-gradient(180deg, var(--bg-start), var(--bg-end));
}

.page-shell {
    max-width: 1480px;
}

.hero-panel {
    display: none;
}

.control-column > .panel:nth-child(1) {
    order: 1;
}

.control-column > .panel:nth-child(3) {
    order: 2;
}

.control-column > .panel:nth-child(2) {
    order: 3;
}

.control-column > .panel:nth-child(4) {
    order: 4;
}

.hero-panel {
    margin-bottom: 18px;
    padding: 6px 8px 12px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.hero-panel h1 {
    font-size: clamp(1.7rem, 3vw, 2.45rem);
}

.hero-copy {
    max-width: 840px;
    margin-top: 8px;
    font-size: 0.94rem;
}

.workspace-grid {
    grid-template-columns: minmax(310px, 360px) minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.control-column,
.result-column {
    gap: 14px;
}

.panel {
    padding: 20px;
    border-radius: var(--radius-lg);
    border-color: rgba(127, 169, 230, 0.24);
    box-shadow: var(--shadow);
}

.control-column > .panel:first-child {
    position: sticky;
    top: 18px;
}

.panel-head {
    margin-bottom: 14px;
}

.section-kicker {
    margin-bottom: 6px;
    font-size: 0.7rem;
}

.main-textarea {
    min-height: 220px;
    padding: 13px 14px;
    border-radius: 12px;
}

.text-input,
.select-input {
    min-height: 44px;
    padding: 0 12px;
    border-radius: 11px;
}

.field-label,
.field-block span,
.field-block > label {
    margin-bottom: 7px;
    font-size: 0.9rem;
}

.number-stepper {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    min-height: 44px;
    border-radius: 11px;
}

.number-stepper-button {
    font-size: 1.5rem;
}

.form-grid {
    gap: 10px;
    margin-top: 12px;
}

.random-type-grid {
    gap: 8px;
    margin-top: 14px;
}

.random-type-grid .mode-card {
    min-height: 88px;
}

.mode-card {
    min-height: 92px;
    padding: 12px;
    border-radius: 12px;
}

.mode-name {
    font-size: 0.9rem;
}

.mode-description,
.toggle-caption {
    font-size: 0.77rem;
    line-height: 1.35;
}

.group-settings,
.number-settings {
    margin-top: 12px;
    padding: 12px;
    border-radius: 12px;
}

.toggle-grid {
    margin-top: 12px;
}

.toggle-card {
    padding: 12px;
    border-radius: 12px;
}

.favorite-actions {
    gap: 8px;
}

.favorite-editor {
    gap: 10px;
}

.result-panel {
    min-height: calc(100vh - 110px);
}

.result-panel .panel-head h2 {
    font-size: clamp(1.4rem, 2.5vw, 2.15rem);
}

.status-pill {
    min-height: 36px;
    padding: 0 12px;
    font-size: 0.85rem;
}

.result-actions {
    grid-template-columns: minmax(0, 1.2fr) minmax(120px, 0.8fr);
    gap: 10px;
    margin-bottom: 14px;
}

.result-actions #btn_clear_locks_preview {
    grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.ghost-button {
    min-height: 48px;
    padding: 0 16px;
}

.rank-list {
    max-height: none;
    gap: 10px;
    padding-right: 0;
}

.rank-card,
.rank-card.is-secondary {
    grid-template-columns: 76px minmax(0, 1fr);
    padding: 14px 16px;
    border-radius: 15px;
    border-color: rgba(212, 185, 142, 0.45);
    background: linear-gradient(135deg, #ffffff, #fffaf5);
    box-shadow: 0 10px 22px rgba(138, 143, 163, 0.08);
}

.rank-number {
    font-size: 1.8rem;
}

.rank-content {
    gap: 12px;
}

.rank-name {
    font-size: clamp(1.1rem, 2vw, 1.5rem);
}

.rank-meta {
    gap: 7px;
}

.inline-lock-button,
.result-number {
    min-height: 34px;
    padding: 0 11px;
    font-size: 0.82rem;
}

.group-result-grid,
.family-result-list {
    gap: 10px;
}

.group-card,
.family-pair-card {
    padding: 14px;
    border-radius: 15px;
}

.family-pair-card {
    gap: 10px;
}

.family-person strong {
    font-size: 1rem;
}

@media (max-width: 860px) {
    body {
        padding: 12px;
    }

    .hero-panel {
        padding: 2px 4px 10px;
    }

    .hero-copy {
        display: none;
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }

    .control-column > .panel:first-child {
        position: static;
    }

    .result-panel {
        min-height: 0;
    }

    .result-actions {
        grid-template-columns: 1fr;
    }

    .result-actions #btn_clear_locks_preview {
        grid-column: auto;
    }

    .result-panel .panel-head {
        align-items: center;
    }

    .rank-card,
    .rank-card.is-secondary {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    .rank-content {
        align-items: stretch;
    }

    .rank-meta {
        justify-content: flex-start;
    }
}

/* Preview — reference-card treatment */
.result-column > article.result-panel {
    min-height: calc(100vh - 48px);
    padding: 38px 40px;
    overflow: hidden;
    border: 1px solid rgba(107, 150, 222, 0.18);
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 44px rgba(46, 94, 170, 0.1);
}

.preview-head {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    margin-bottom: 28px;
}

.preview-heading .section-kicker {
    margin-bottom: 8px;
    color: #1467ee;
    font-size: 0.76rem;
    letter-spacing: 0.16em;
}

.preview-heading h2,
.result-column > article.result-panel .preview-heading h2 {
    color: #102757;
    font-size: clamp(2.35rem, 4vw, 3.7rem);
    line-height: 1.08;
    letter-spacing: -0.045em;
}

.preview-status-detail {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 10px 0 0;
    color: #7181a8;
    font-size: 0.95rem;
    font-weight: 600;
}

.status-check {
    display: grid;
    place-items: center;
    inline-size: 20px;
    block-size: 20px;
    border-radius: 50%;
    color: #fff;
    background: #3474ef;
    font-size: 0.72rem;
    font-weight: 800;
}

.result-column > article.result-panel .status-pill {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    color: #2d6bed;
    background: #eef4ff;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-pill svg {
    inline-size: 21px;
    block-size: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.result-panel .result-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 28px;
}

.result-panel .result-actions #btn_clear_locks_preview {
    grid-column: 1 / -1;
}

.result-panel .result-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 58px;
    padding: 0 18px;
    border-radius: 13px;
    font-size: 0.96rem;
}

.result-panel .result-actions button svg {
    inline-size: 22px;
    block-size: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.result-panel .result-actions #btn_go {
    color: #fff;
    background: linear-gradient(135deg, #3978f4 0%, #2462ea 100%);
    box-shadow: 0 10px 22px rgba(38, 98, 234, 0.2);
}

.result-panel .result-actions #btn_clear {
    color: #18315f;
    border-color: #d8e2f3;
    background: #fff;
}

.result-panel .result-actions #btn_clear_locks_preview {
    color: #ee5e5a;
    border-color: #f4caca;
    background: #fff;
}

.result-panel .validation-message {
    margin: 0 0 20px;
}

.result-panel .result-stack {
    gap: 24px;
}

.result-panel .result-stack:empty {
    min-height: 420px;
    border-color: rgba(105, 152, 229, 0.26);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(249, 252, 255, 0.76), rgba(255, 255, 255, 0.9));
}

.result-panel .round-block + .round-block {
    margin-top: 24px;
}

.result-panel .round-title {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    margin: 0 0 18px;
    padding: 0 8px;
    border-bottom: 1px solid #dfe8f5;
    color: #1a315c;
    font-weight: 700;
}

.round-title-label {
    align-self: stretch;
    display: inline-flex;
    align-items: center;
}

.round-title-label::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 8px;
    width: 64px;
    height: 4px;
    border-radius: 4px 4px 0 0;
    background: #3977f1;
}

.round-count {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    color: #7183aa;
    background: #f0f5fd;
    font-size: 0.85rem;
}

.result-panel .rank-list {
    gap: 12px;
    max-height: none;
    overflow: visible;
    padding: 0;
}

.result-panel .rank-card,
.result-panel .rank-card.is-secondary {
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    min-height: 82px;
    padding: 12px 18px;
    border: 1px solid #dfe8f5;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 7px 18px rgba(56, 91, 150, 0.045);
}

.result-panel .rank-accent,
.result-panel .rank-card.is-secondary .rank-accent {
    min-width: 0;
    color: #e9a51d;
}

.rank-medal {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    inline-size: 64px;
    block-size: 56px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff5da, #fffaf0);
}

.rank-medal::before,
.rank-medal::after {
    position: absolute;
    bottom: 8px;
    color: currentColor;
    font-size: 1.15rem;
    line-height: 1;
}

.rank-medal::before {
    left: 5px;
    content: "❧";
    transform: rotate(22deg);
}

.rank-medal::after {
    right: 5px;
    content: "❦";
    transform: rotate(-22deg);
}

.result-panel .rank-number {
    position: relative;
    z-index: 1;
    color: currentColor;
    font-size: 1.8rem;
    font-weight: 800;
}

.result-panel .rank-card:nth-child(2) .rank-accent {
    color: #8e9bb2;
}

.result-panel .rank-card:nth-child(2) .rank-medal {
    background: linear-gradient(145deg, #f0f3f8, #fafbfe);
}

.result-panel .rank-card:nth-child(3) .rank-accent {
    color: #c66b32;
}

.result-panel .rank-card:nth-child(3) .rank-medal {
    background: linear-gradient(145deg, #fff0e7, #fff9f5);
}

.result-panel .rank-card.is-secondary .rank-medal {
    inline-size: 54px;
    block-size: 54px;
    color: #5d8fe9;
    background: #edf4ff;
}

.result-panel .rank-card.is-secondary .rank-medal::before,
.result-panel .rank-card.is-secondary .rank-medal::after {
    display: none;
}

.result-panel .rank-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.result-panel .rank-name,
.result-panel .rank-card.is-secondary .rank-name {
    color: #102757;
    font-size: clamp(1.05rem, 1.7vw, 1.35rem);
    font-weight: 800;
}

.result-panel .rank-meta {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.result-panel .inline-lock-button {
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid #cddcf7;
    border-radius: 999px;
    color: #315da9;
    background: #fff;
    font-size: 0.84rem;
    font-weight: 700;
}

.result-panel .inline-lock-button.unlock-lock-button {
    color: #eb5b58;
    border-color: #f3c8c7;
    background: #fff6f5;
}

.preview-help {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    margin-top: 24px;
    padding: 18px 20px;
    border-radius: 15px;
    background: linear-gradient(135deg, #eff5ff, #f7faff);
}

.preview-help[hidden] {
    display: none;
}

.preview-help-icon {
    display: grid;
    place-items: center;
    inline-size: 42px;
    block-size: 42px;
    border-radius: 50%;
    color: #fff;
    background: #3474ef;
    font-family: Georgia, serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.preview-help-copy {
    display: grid;
    gap: 3px;
    color: #7181a7;
    font-size: 0.82rem;
}

.preview-help-copy strong {
    color: #2d6ce9;
    font-size: 0.9rem;
}

.reroll-unlocked-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid #7ba3f5;
    border-radius: 12px;
    color: #3470e9;
    background: #fff;
    font-size: 0.85rem;
    font-weight: 700;
}

.reroll-unlocked-button svg {
    inline-size: 21px;
    block-size: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 860px) {
    .result-column > article.result-panel {
        min-height: 0;
        padding: 24px 18px;
        border-radius: 24px;
    }

    .preview-head {
        align-items: flex-start;
    }

    .preview-heading h2,
    .result-column > article.result-panel .preview-heading h2 {
        font-size: 2.2rem;
    }

    .result-column > article.result-panel .status-pill {
        min-height: 38px;
        padding: 0 12px;
        font-size: 0.78rem;
    }

    .result-panel .rank-card,
    .result-panel .rank-card.is-secondary {
        grid-template-columns: 64px minmax(0, 1fr);
        padding: 11px 12px;
    }

    .rank-medal {
        inline-size: 56px;
    }

    .result-panel .rank-content {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
    }

    .result-panel .rank-meta {
        justify-content: flex-start;
    }

    .preview-help {
        grid-template-columns: 42px minmax(0, 1fr);
    }

    .reroll-unlocked-button {
        grid-column: 1 / -1;
    }
}

@media (max-width: 520px) {
    .preview-head {
        display: grid;
    }

    .result-column > article.result-panel .status-pill {
        justify-self: start;
    }

    .result-panel .result-actions {
        grid-template-columns: 1fr;
    }

    .result-panel .result-actions #btn_clear_locks_preview {
        grid-column: auto;
    }
}

/* Final layout precedence: must remain after all dashboard rules. */
@media (min-width: 861px) {
    .workspace-grid {
        grid-template-columns: 390px minmax(0, 1fr);
        gap: 20px;
    }

    .result-panel .panel-head h2 {
        font-size: clamp(2.4rem, 4vw, 3.75rem);
        line-height: 1.08;
    }
}

.control-column > .panel:first-child {
    position: static;
}

.control-column > .panel {
    min-width: 0;
}

.control-column > .panel:nth-child(1) {
    padding: 22px;
}

.control-column > .panel:nth-child(1) .panel-head {
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(139, 166, 208, 0.24);
}

.random-type-grid .mode-card {
    align-items: center;
    justify-content: center;
    min-height: 72px;
    padding: 10px 7px;
    text-align: center;
}

.random-type-grid .mode-description,
.control-column > .panel:nth-child(4) .mode-description {
    display: none;
}

.random-type-grid .mode-name {
    font-size: 0.78rem;
}

.control-column > .panel:nth-child(4) .mode-card {
    min-height: 54px;
    align-items: center;
    justify-content: center;
    padding: 8px;
    text-align: center;
}

.lock-editor-head {
    grid-template-columns: 1fr;
    gap: 12px;
}

.lock-actions {
    justify-content: stretch;
}

.lock-actions button {
    flex: 1 1 145px;
}

.favorite-editor,
.favorite-actions {
    grid-template-columns: 1fr;
}

.result-panel {
    padding: 30px 34px;
    background:
        radial-gradient(circle at 90% 0%, rgba(100, 166, 255, 0.1), transparent 28%),
        rgba(255, 255, 255, 0.94);
}

.result-panel .panel-head {
    align-items: center;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(139, 166, 208, 0.28);
}

.result-actions {
    margin: 16px 0 18px;
}

.result-stack:empty {
    display: grid;
    place-items: center;
    min-height: 380px;
    border: 1px dashed rgba(105, 152, 229, 0.3);
    border-radius: 18px;
    color: var(--text-secondary);
    text-align: center;
}

.result-stack:empty::before {
    max-width: 280px;
    content: "พร้อมสุ่มแล้ว\A\A กดเริ่มสุ่มเพื่อดูผลลัพธ์ที่นี่";
    white-space: pre-line;
    font-size: 1rem;
    line-height: 1.7;
}

@media (max-width: 860px) {
    .control-column > .panel:nth-child(1) {
        padding: 18px;
    }

    .random-type-grid .mode-card {
        min-height: 62px;
    }

    .result-panel {
        padding: 22px 18px;
    }

    .result-panel .panel-head {
        padding-bottom: 15px;
    }

    .result-panel .panel-head h2 {
        font-size: 2rem;
    }

    .result-stack:empty {
        min-height: 240px;
    }
}
