/* PTC Lục Nhâm Đại Độn – lucnham.css */
:root {
    --ln-red: #8b0000;
    --ln-red2: #5a0000;
    --ln-gold: #c9a227;
    --ln-bg: #fff8f0;
    --ln-border: #e0c090;
}

#ptc-lucnham-wrap,
.ln-wrap {
    font-family: 'Segoe UI', Arial, sans-serif;
    max-width: 1100px;
    margin: 0 auto;
    color: #222;
    padding-top: 30px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

#ln-result-wrap {
    max-width: 100%;
    overflow-x: hidden;
}

.ln-form-header {
    margin-bottom: 20px;
}

.ln-title {
    color: var(--ln-red);
    border-bottom: 2px solid var(--ln-red);
    padding-bottom: 8px;
    margin: 0 0 6px;
    font-size: 1.4rem;
}

.ln-subtitle {
    color: #666;
    font-size: .9rem;
    margin: 0;
    line-height: 1.5;
}

/* Form card layout */
.ln-form {
    background: #fff;
    border: 1px solid var(--ln-border);
    border-radius: 10px;
    padding: 20px 24px 24px;
    box-shadow: 0 2px 12px rgba(139, 0, 0, .06);
}

.ln-section {
    margin-bottom: 18px;
}

.ln-section:last-of-type {
    margin-bottom: 0;
}

.ln-section-title {
    margin: 0 0 12px;
    padding: 8px 14px;
    background: linear-gradient(90deg, var(--ln-bg) 0%, #fff 100%);
    border-left: 4px solid var(--ln-red);
    border-radius: 0 6px 6px 0;
    color: var(--ln-red);
    font-size: .92rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.ln-section-body {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 16px;
    align-items: flex-end;
    padding: 0 4px;
}

.ln-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 0;
}

.ln-field label {
    font-size: .82rem;
    font-weight: 600;
    color: #555;
    line-height: 1.2;
}

.ln-field-grow {
    flex: 1 1 220px;
    min-width: 180px;
}

.ln-field-sm {
    flex: 0 0 110px;
}

.ln-field-tz {
    flex: 1 1 160px;
}

.ln-input,
.ln-select {
    padding: 8px 12px;
    border: 1px solid #d4d0c8;
    border-radius: 6px;
    font-size: .9rem;
    width: 100%;
    box-sizing: border-box;
    background: #fff;
    color: #333;
    transition: border-color .2s, box-shadow .2s;
}

.ln-input:focus,
.ln-select:focus {
    outline: none;
    border-color: var(--ln-red);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, .1);
}

.ln-input {
    min-width: 0;
}

.ln-select {
    min-width: 88px;
    cursor: pointer;
    appearance: auto;
}

.ln-select-tz {
    min-width: 130px;
}

.ln-actions {
    text-align: center;
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 1px dashed var(--ln-border);
}

.ln-btn-primary {
    background: var(--ln-red);
    color: #fff;
    border: none;
    padding: 12px 40px;
    border-radius: 6px;
    font-size: 1rem;
    cursor: pointer;
    transition: background .2s;
}

.ln-btn-primary:hover {
    background: var(--ln-red2);
}

.ln-btn-sec {
    background: #555;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 5px;
    font-size: .85rem;
    cursor: pointer;
    margin: 0 4px;
}

.ln-btn-sec:hover {
    background: #333;
}

/* Loading */
.ln-loading {
    text-align: center;
    padding: 30px;
    color: var(--ln-red);
}

.ln-spinner {
    width: 42px;
    height: 42px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--ln-red);
    border-radius: 50%;
    animation: lnSpin .8s linear infinite;
    margin: 0 auto 10px;
}

@keyframes lnSpin {
    to { transform: rotate(360deg); }
}

.ln-result-toolbar {
    text-align: center;
    margin: 14px 0;
}

/* ═══ LÁ SỐ CHUYÊN NGHIỆP ═══ */
.ln-result-pro {
    background: #fff;
    border: 2px solid #1565c0;
    border-radius: 4px;
    padding: 12px 14px 10px;
    margin-top: 20px;
    max-width: 1050px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    font-size: 13px;
    line-height: 1.35;
    box-sizing: border-box;
    overflow-x: hidden;
}

.ln-pro-head {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid var(--ln-gold);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.ln-pro-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a5c20, #c9a227);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.ln-pro-head-center { flex: 1; text-align: center; }
.ln-pro-club { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: #1565c0; }
.ln-pro-url { margin: 2px 0; font-size: 11px; color: #888; }
.ln-pro-title {
    margin: 3px 0 0;
    font-size: 18px;
    font-weight: 800;
    color: #1565c0;
    letter-spacing: .03em;
    border-bottom: 3px solid #1565c0;
    display: inline-block;
    padding-bottom: 2px;
}
.ln-pro-seal {
    font-size: 1.1rem;
    color: var(--ln-red);
    font-weight: 700;
    opacity: .85;
    writing-mode: vertical-rl;
    border: 2px solid var(--ln-red);
    padding: 4px 2px;
    border-radius: 2px;
}

/* Info panels */
.ln-pro-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.ln-pro-info-col { display: flex; flex-direction: column; gap: 6px; }

.ln-pro-box {
    border: 1px solid #90caf9;
    background: #e3f2fd;
    padding: 4px 8px;
    border-radius: 3px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 3px 8px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.ln-pro-info-col:first-child .ln-pro-box:nth-child(odd) {
    background: #e8f5e9;
    border-color: #a5d6a7;
}

.ln-pro-info-col:first-child .ln-pro-box:nth-child(even) {
    background: #e3f2fd;
    border-color: #90caf9;
}

.ln-pro-info-col:last-child .ln-pro-box:nth-child(odd) {
    background: #fff8e1;
    border-color: #ffe082;
}

.ln-pro-info-col:last-child .ln-pro-box:nth-child(even) {
    background: #e8eaf6;
    border-color: #9fa8da;
}

.ln-pro-lbl {
    font-weight: 700;
    color: #1565c0;
    font-size: 12px;
    white-space: nowrap;
}

.ln-pro-lbl-inline { margin-left: 6px; }

.ln-pro-val {
    color: #333;
    font-size: 13px;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}
.ln-val-red { color: var(--ln-red); font-weight: 700; }

/* 4x4 Board */
.ln-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(4, auto);
    gap: 1px;
    border: 2px solid #1565c0;
    background: #1565c0;
    position: relative;
    align-items: stretch;
    font-size: 15px;
    width: 100%;
}

.ln-cell {
    background: #fffde7;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.ln-cell-green  { background: #e8f5e9; }
.ln-cell-pink   { background: #f3e5f5; }
.ln-cell-yellow { background: #fff8e1; }
.ln-cell-blue   { background: #e8eaf6; }

.ln-cell-rim {
    flex-shrink: 0;
    width: 100%;
    text-align: center;
    font-size: 0.82em;
    font-weight: 800;
    color: #c45c00;
    letter-spacing: .04em;
    line-height: 1;
    padding: 0 2px 2px;
    margin-top: auto;
    opacity: .92;
}

.ln-cell-head {
    background: #1565c0;
    color: #fff;
    font-weight: 700;
    text-align: center;
    padding: 2px 2px;
    font-size: 0.95em;
    line-height: 1.15;
}

.ln-cell-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    padding: 3px 4px 2px;
    text-align: center;
    line-height: 1.3;
    width: 100%;
    box-sizing: border-box;
    min-height: 0;
}

.ln-cell-tian {
    font-size: 1.25em;
    font-weight: 800;
    color: var(--ln-red);
    margin: 0;
    line-height: 1.15;
}

.ln-cell-jiang {
    font-size: 0.92em;
    color: #1a1a1a;
    font-weight: 600;
    line-height: 1.15;
}

.ln-cell-dun {
    font-size: 0.88em;
    color: #1565c0;
    font-weight: 600;
    line-height: 1.15;
}

.ln-cell-jian {
    font-size: 0.78em;
    color: #444;
    font-weight: 600;
    line-height: 1.15;
    white-space: nowrap;
}

.ln-mark {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 700;
    padding: 0 2px;
    border-radius: 2px;
    margin: 0 1px;
    line-height: 1.25;
}

.ln-mark-chuan  { background: var(--ln-red); color: #fff; }
.ln-mark-yima   { background: #2e7d32; color: #fff; }
.ln-mark-tianma { background: #1565c0; color: #fff; }
.ln-mark-dingma { background: #6a1b9a; color: #fff; }
.ln-mark-kong   { background: #555; color: #fff; }
.ln-mark-yue    { background: var(--ln-gold); color: #fff; }

/* Grid positions */
.ln-cell[data-key="si"]    { grid-area: 1 / 1 / 2 / 2; }
.ln-cell[data-key="wu"]    { grid-area: 1 / 2 / 2 / 3; }
.ln-cell[data-key="wei"]   { grid-area: 1 / 3 / 2 / 4; }
.ln-cell[data-key="shen"]  { grid-area: 1 / 4 / 2 / 5; }
.ln-cell[data-key="chen"]  { grid-area: 2 / 1 / 3 / 2; }
.ln-cell[data-key="you"]   { grid-area: 2 / 4 / 3 / 5; }
.ln-cell[data-key="mao"]   { grid-area: 3 / 1 / 4 / 2; }
.ln-cell[data-key="xu"]    { grid-area: 3 / 4 / 4 / 5; }
.ln-cell[data-key="yin"]   { grid-area: 4 / 1 / 5 / 2; }
.ln-cell[data-key="chou"]  { grid-area: 4 / 2 / 5 / 3; }
.ln-cell[data-key="zi"]    { grid-area: 4 / 3 / 5 / 4; }
.ln-cell[data-key="hai"]   { grid-area: 4 / 4 / 5 / 5; }

.ln-board-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
}

.ln-center {
    grid-area: 2 / 2 / 4 / 4;
    background: #fffef5;
    border: 1px solid #90caf9;
    padding: 4px 5px;
    overflow: visible;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 1;
    min-width: 0;
    width: 100%;
    align-self: stretch;
}

.ln-center-watermark {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 140px;
    color: rgba(201, 162, 39, .12);
    pointer-events: none;
    z-index: 0;
    line-height: 1;
}

.ln-cen-block {
    position: relative;
    z-index: 1;
    background: rgba(255,255,255,.94);
    border: 1px solid #bbdefb;
    border-radius: 2px;
    padding: 3px 5px;
    min-width: 0;
    overflow: visible;
}

.ln-cen-title {
    margin: 0 0 2px;
    font-size: 12px;
    font-weight: 800;
    color: #1565c0;
    text-align: center;
    letter-spacing: .04em;
}

.ln-cen-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    table-layout: fixed;
}

.ln-cen-table th,
.ln-cen-table td {
    border: 1px solid #bbdefb;
    padding: 2px 4px;
    text-align: center;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

.ln-cen-table thead th {
    background: #e3f2fd;
    color: #1565c0;
    font-weight: 700;
    font-size: 11px;
}

.ln-cen-table tbody th {
    background: #f5f5f5;
    color: #555;
    font-weight: 600;
    font-size: 11px;
}

.ln-cen-yue {
    margin: 2px 0 0;
    font-size: 12px;
    text-align: center;
    color: #333;
}

.ln-cen-yue strong { color: var(--ln-red); }

.ln-ke-jiang { font-weight: 700; color: #1565c0; font-size: 11px; }
.ln-ke-shang { font-weight: 700; color: var(--ln-red); font-size: 13px; }

.ln-ch-zhi { font-weight: 800; color: var(--ln-red); font-size: 14px; }

.ln-cen-foot {
    position: relative;
    z-index: 1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 10px;
    font-size: 11px;
    color: #555;
    padding-top: 1px;
}

.ln-pro-footer {
    text-align: center;
    font-size: 10px;
    color: #aaa;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #ddd;
}

.ln-image-result {
    text-align: center;
    max-width: 100%;
    overflow: hidden;
}

.ln-image-scroll {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fafafa;
    line-height: 0;
}

.ln-image-result img {
    max-width: 100%;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    image-rendering: auto;
}

.ln-image-hint {
    font-size: .8rem;
    color: #888;
    margin-top: 8px;
}

.ln-capture-wait {
    text-align: center;
    padding: 10px;
    color: var(--ln-red);
    font-size: .9rem;
    background: var(--ln-bg);
    border-radius: 6px;
    margin-bottom: 10px;
    border: 1px dashed var(--ln-border);
}

.ln-capture-fail {
    background: #fff3e0;
    border: 1px solid #ffb74d;
    color: #5d4037;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    margin-bottom: 8px;
    text-align: center;
}

.ln-view-hint {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin: 0 0 8px;
    padding: 4px 8px;
    background: #f5f5f5;
    border-radius: 4px;
}

/* ── Mobile: vừa màn hình, không tràn ── */
@media (max-width: 768px) {
    .ln-form {
        padding: 16px;
    }
    .ln-section-body {
        gap: 12px;
    }
    .ln-field-grow,
    .ln-field-sm,
    .ln-field-tz {
        flex: 1 1 calc(50% - 8px);
        min-width: 120px;
    }

    .ln-pro-info {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .ln-pro-info-col {
        min-width: 0;
    }
    .ln-result-pro {
        padding: 8px 6px;
        max-width: 100%;
        font-size: 13px;
        -webkit-text-size-adjust: 100%;
        text-size-adjust: 100%;
    }
    .ln-pro-head { flex-wrap: wrap; gap: 6px; }
    .ln-pro-logo { width: 32px; height: 32px; font-size: 1rem; }
    .ln-pro-club { font-size: 10px; letter-spacing: .04em; }
    .ln-pro-url { font-size: 10px; word-break: break-all; }
    .ln-pro-title { font-size: 14px; }
    .ln-pro-seal { font-size: .95rem; padding: 2px 1px; }

    .ln-pro-box {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 6px 8px;
    }
    .ln-pro-lbl {
        font-size: 11px;
        white-space: normal;
    }
    .ln-pro-lbl-inline {
        margin-left: 0;
        display: block;
        margin-top: 4px;
    }
    .ln-pro-val {
        font-size: 12px;
        line-height: 1.45;
        display: block;
        width: 100%;
    }

    .ln-board-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 2px;
    }
    .ln-board {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        font-size: 15px;
        grid-template-columns: 0.58fr 1.42fr 1.42fr 0.58fr;
    }
    .ln-cell-head {
        padding: 4px 2px;
        font-size: 15px;
    }
    .ln-cell {
        display: flex;
        flex-direction: column;
    }
    .ln-cell-body {
        flex: 1 1 auto;
        padding: 4px 3px 2px;
        gap: 3px;
        justify-content: flex-start;
    }
    .ln-cell-rim {
        font-size: 11px;
        font-weight: 800;
        padding: 0 2px 3px;
        color: #c45c00;
    }
    .ln-cell-tian { font-size: 17px; line-height: 1.2; }
    .ln-cell-jiang { font-size: 12px; line-height: 1.25; }
    .ln-cell-dun { font-size: 11px; }
    .ln-cell-jian {
        font-size: 10px;
        white-space: normal;
        word-break: break-word;
    }
    .ln-mark { font-size: 10px; padding: 1px 3px; }

    .ln-center {
        padding: 4px 3px;
        gap: 4px;
        overflow: visible;
    }
    .ln-cen-block {
        padding: 3px 3px;
        overflow: visible;
    }
    .ln-cen-title { font-size: 12px; }
    .ln-cen-table {
        font-size: 11px;
        table-layout: fixed;
    }
    .ln-cen-table th,
    .ln-cen-table td {
        padding: 2px 1px;
        line-height: 1.3;
        word-break: break-word;
    }
    .ln-cen-table thead th:first-child,
    .ln-cen-table tbody th {
        width: 14%;
    }
    .ln-cen-chuan tbody th {
        width: 12%;
    }
    .ln-cen-chuan td {
        font-size: 10px;
    }
    .ln-cen-chuan .ln-ch-zhi {
        font-size: 13px;
    }
    .ln-cen-yue {
        font-size: 11px;
        line-height: 1.35;
        word-break: break-word;
    }
    .ln-ch-zhi { font-size: 14px; }
    .ln-cen-foot {
        font-size: 10px;
        gap: 3px 5px;
        word-break: break-word;
    }
    .ln-center-watermark { font-size: 52px; }

    .ln-image-result img {
        width: 100%;
        max-width: 100%;
        height: auto;
    }

    .ln-result-toolbar {
        flex-wrap: wrap;
        gap: 6px;
    }
    .ln-result-toolbar .ln-btn {
        flex: 1 1 auto;
        min-width: 120px;
        font-size: .82rem;
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .ln-field-grow,
    .ln-field-sm,
    .ln-field-tz {
        flex: 1 1 100%;
    }
    .ln-result-pro { padding: 6px 4px; }
    .ln-board {
        font-size: 14px;
        grid-template-columns: 0.55fr 1.45fr 1.45fr 0.55fr;
    }
    .ln-cell-tian { font-size: 16px; }
    .ln-cell-jiang { font-size: 11px; }
    .ln-cen-table { font-size: 10px; }
    .ln-cen-chuan td { font-size: 9px; }
    .ln-cen-foot span { display: inline-block; }
}
