:root {
    --bg-base: #0b1b2b;
    --bg-mid: #112d46;
    --surface: #f6f1e7;
    --accent: #e3a12a;
    --line-soft: rgba(255, 255, 255, 0.18);
    --shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: 'Noto Sans Thai', sans-serif;
    color: var(--surface);
    background:
        radial-gradient(circle at 16% 20%, rgba(227, 161, 42, 0.2), transparent 42%),
        radial-gradient(circle at 84% 10%, rgba(35, 86, 118, 0.35), transparent 40%),
        linear-gradient(145deg, var(--bg-base), var(--bg-mid) 46%, #071220);
    overflow-x: hidden;
}

.noise-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.13;
    background-image: radial-gradient(rgba(255, 255, 255, 0.35) 0.4px, transparent 0.4px);
    background-size: 3px 3px;
}

.navbar {
    position: sticky;
    top: 10px;
    z-index: 15;
    padding: 0 12px;
}

.nav-container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-radius: 18px;
    border: 1px solid rgba(227, 161, 42, 0.28);
    background: linear-gradient(120deg, rgba(8, 25, 41, 0.88), rgba(16, 42, 66, 0.8));
    box-shadow: 0 16px 40px rgba(2, 11, 20, 0.42);
    backdrop-filter: blur(12px);
}

.logo {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
    font-family: 'Chakra Petch', sans-serif;
    text-decoration: none;
    color: #f9f3e4;
}

.logo-main {
    font-size: 1.35rem;
    letter-spacing: 1px;
    font-weight: 700;
    line-height: 1;
}

.logo-sub {
    font-size: 0.69rem;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: #b8c7dc;
}

.gold {
    color: var(--accent);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    color: #d7deea;
    text-decoration: none;
    font-size: 0.9rem;
    border: 1px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.nav-links a:hover {
    border-color: rgba(255, 255, 255, 0.24);
    background: rgba(255, 255, 255, 0.1);
    color: #fff3d8;
    transform: translateY(-1px);
}

.nav-links a.active {
    color: #1b1202;
    background: linear-gradient(135deg, #f0be62, #e5a53e);
    border-color: rgba(237, 186, 101, 0.8);
    font-weight: 700;
}

.nav-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    height: 32px;
    border-radius: 999px;
    font-size: 0.78rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #f7e8c5;
    background: rgba(227, 161, 42, 0.18);
    border: 1px solid rgba(227, 161, 42, 0.35);
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    padding: 9px 8px;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    margin: 5px 0;
    border-radius: 999px;
    background: #f9f3e4;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.menu-toggle.is-open span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-toggle.is-open span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.is-open span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.page-wrap {
    position: relative;
    z-index: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 34px 16px 60px;
}

.hero h1 {
    margin: 0;
    font-family: 'Chakra Petch', sans-serif;
    color: #7a9cff;
    font-size: clamp(1.6rem, 3.5vw, 2.6rem);
}

.hero p {
    margin: 12px 0 0;
    max-width: 980px;
    color: #e2ebfb;
    line-height: 1.55;
}

.panel {
    margin-top: 20px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: linear-gradient(140deg, rgba(9, 25, 41, 0.82), rgba(17, 41, 67, 0.74));
    box-shadow: var(--shadow);
    padding: 18px;
}

.pick-panel {
    text-align: center;
}

.deck-area {
    position: relative;
    width: min(740px, 96%);
    height: 410px;
    margin: 8px auto 0;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.15));
    overflow: hidden;
}

.deck-card {
    position: absolute;
    width: 136px;
    height: 206px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: #111;
    cursor: pointer;
    padding: 0;
    transform-origin: center center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.deck-card img {
    width: 100%;
    height: 100%;
    border-radius: 11px;
    object-fit: cover;
    display: block;
}

.deck-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.deck-card.selected {
    border-color: rgba(227, 161, 42, 0.98);
    box-shadow: 0 0 0 2px rgba(227, 161, 42, 0.35), 0 10px 24px rgba(0, 0, 0, 0.5);
}

.pick-order {
    position: absolute;
    right: 6px;
    top: 6px;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    color: #1f1300;
    background: #f0be62;
}

.pick-status {
    margin: 12px 0;
    font-size: 2rem;
    font-family: 'Chakra Petch', sans-serif;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.btn {
    border: none;
    border-radius: 999px;
    min-height: 40px;
    padding: 0 18px;
    font-family: 'Noto Sans Thai', sans-serif;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    color: #1f1300;
    background: linear-gradient(135deg, #f0be62, #e29a2f);
}

.btn-secondary {
    color: #eef4ff;
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid var(--line-soft);
}

.btn-ghost {
    color: #d8e3f5;
    background: rgba(5, 15, 28, 0.58);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.warning-box {
    margin: 8px auto 0;
    max-width: 500px;
    border-radius: 10px;
    padding: 8px 10px;
    color: #ffd8cf;
    border: 1px solid rgba(209, 83, 55, 0.5);
    background: rgba(209, 83, 55, 0.2);
}

.disclaimer-title {
    margin: 14px 0 4px;
    color: #ff6b57;
    font-weight: 700;
    text-align: left;
}

.disclaimer-text {
    margin: 0;
    text-align: left;
}

.hidden {
    display: none;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.result-header h2 {
    margin: 0;
    font-family: 'Chakra Petch', sans-serif;
}

.result-layout {
    margin-top: 14px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    align-items: stretch;
    min-height: auto;
}

.spread-board-wrap {
    border-radius: 14px;
    background: linear-gradient(145deg, #070f19, #0d1b2d);
    border: 1px solid rgba(255, 255, 255, 0.16);
    padding: 12px;
    height: 1000px;
    display: flex;
    justify-content: center;
}

.spread-stage {
    width: min(980px, 100%);
    height: 100%;
    display: block;
    position: relative;
    align-items: stretch;
}

.ads-overlay {
    position: absolute;
    left: 18px;
    top: 40px;
    width: 250px;
    height: calc(100% - 80px);
    z-index: 1;
}

.ads-overlay-inner {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 18px;
    border: 1px solid rgba(227, 161, 42, 0.35);
    background:
        linear-gradient(170deg, rgba(19, 40, 62, 0.92), rgba(6, 15, 26, 0.94)),
        radial-gradient(circle at 20% 18%, rgba(227, 161, 42, 0.2), transparent 45%);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.08),
        0 18px 40px rgba(0, 0, 0, 0.35),
        0 0 28px rgba(227, 161, 42, 0.12);
    padding: 14px;
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 12px;
}

.ads-label {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid rgba(227, 161, 42, 0.45);
    background: rgba(227, 161, 42, 0.14);
    font-family: 'Chakra Petch', sans-serif;
    letter-spacing: 1.2px;
    color: #f7dca0;
    font-size: 0.84rem;
    text-transform: uppercase;
}

.ads-overlay-inner::after {
    content: "วางโค้ดโฆษณา 250 x 1000";
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-radius: 12px;
    border: 1px dashed rgba(255, 255, 255, 0.28);
    background:
        repeating-linear-gradient(
            45deg,
            rgba(255, 255, 255, 0.05),
            rgba(255, 255, 255, 0.05) 10px,
            rgba(255, 255, 255, 0.02) 10px,
            rgba(255, 255, 255, 0.02) 20px
        );
    color: #dbe8ff;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spread-board {
    --card-w: 122px;
    --card-h: 183px;
    --card-half: 61px;
    --gap-x: 40px;
    --center-x: 50%;
    --trio-step: calc(var(--card-w) + var(--gap-x));
    --top-row: 40px;
    --middle-row: 350px;
    --bottom-row: 650px;
    --right-col-left: calc(var(--center-x) + 280px);
    --right-gap-y: 50px;
    --right-step-y: calc(var(--card-h) + var(--right-gap-y));
    display: block;
    position: relative;
    height: 100%;
    min-height: 960px;
    width: min(980px, 100%);
    justify-self: center;
    z-index: 2;
}

.spread-slot {
    width: var(--card-w);
    text-align: center;
    position: absolute;
    overflow: visible;
}

.spread-card {
    position: relative;
    width: var(--card-w);
    max-width: none;
    margin: 0 auto;
}

.spread-card img {
    width: 100%;
    aspect-ratio: 2 / 3;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.spread-card.cross img {
    transform: none;
}

.spread-card.reversed img {
    transform: scaleY(-1);
}

.spread-card.cross.reversed img {
    transform: scaleY(-1);
}

.slot-label {
    margin-top: 6px;
    font-size: 0.84rem;
    color: #dce7f8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-1 {
    left: calc(var(--center-x) - var(--card-half));
    top: var(--middle-row);
    z-index: 2;
}

.pos-2 {
    left: calc(var(--center-x) - var(--card-half) - var(--trio-step));
    top: var(--middle-row);
    transform: none;
    z-index: 2;
}

.pos-3 {
    left: calc(var(--center-x) - var(--card-half));
    top: var(--top-row);
}

.pos-4 {
    left: calc(var(--center-x) - var(--card-half));
    top: var(--bottom-row);
}

.pos-5 {
    left: calc(var(--center-x) - var(--card-half) + var(--trio-step));
    top: var(--middle-row);
}

.pos-6 {
    left: calc(var(--center-x) - var(--card-half) - var(--trio-step));
    top: var(--top-row);
}

.pos-7 {
    left: var(--right-col-left);
    top: calc(var(--top-row) + var(--right-step-y) * 3);
}

.pos-8 {
    left: var(--right-col-left);
    top: calc(var(--top-row) + var(--right-step-y) * 2);
}

.pos-9 {
    left: var(--right-col-left);
    top: calc(var(--top-row) + var(--right-step-y));
}

.pos-10 {
    left: var(--right-col-left);
    top: var(--top-row);
}

.interpretation-wrap {
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    height: auto;
    display: flex;
    flex-direction: column;
}

.interpretation-wrap h3 {
    margin: 0 0 10px;
}

.interpretation-list {
    display: grid;
    gap: 10px;
    flex: 0 0 auto;
    min-height: auto;
    max-height: 520px;
    overflow: auto;
    padding-right: 4px;
}

.interpret-item {
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
}

.interpret-item h4 {
    margin: 0;
    color: #f6c878;
    font-size: 0.96rem;
}

.interpret-card {
    margin: 6px 0 4px;
    color: #d5e4fa;
    font-size: 0.92rem;
}

.interpret-text {
    margin: 0;
    color: #eef4ff;
    font-size: 0.92rem;
    line-height: 1.5;
}

@media (max-width: 980px) {
    .menu-toggle {
        display: inline-block;
    }

    .nav-links {
        position: absolute;
        left: 12px;
        right: 12px;
        top: 66px;
        padding: 10px;
        border-radius: 14px;
        border: 1px solid rgba(255, 255, 255, 0.16);
        background: rgba(7, 18, 32, 0.95);
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .nav-links.is-open {
        display: flex;
    }

    .nav-chip {
        display: none;
    }

    .result-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .spread-board {
        --card-w: 107px;
        --card-h: 160px;
        --card-half: 53.5px;
        --gap-x: 30px;
        --center-x: 50%;
        --trio-step: calc(var(--card-w) + var(--gap-x));
        --top-row: 30px;
        --middle-row: 300px;
        --bottom-row: 560px;
        --right-col-left: calc(var(--center-x) + 210px);
        --right-gap-y: 50px;
        --right-step-y: calc(var(--card-h) + var(--right-gap-y));
        min-height: 860px;
        min-width: 760px;
    }

    .spread-stage {
        width: min(980px, 100%);
    }

    .ads-overlay {
        display: none;
    }

    .spread-board-wrap {
        overflow-x: auto;
    }

    .spread-board-wrap,
    .interpretation-wrap {
        height: auto;
    }
}

@media (max-width: 640px) {
    .deck-area {
        height: 330px;
    }

    .deck-card {
        width: 98px;
        height: 148px;
    }

    .pick-status {
        font-size: 1.35rem;
    }
}
