/* ==========================================================================
   กระดานหมากฮอสในบทความ — สีและรูปทรงยกมาจากเกม makhosthai.com
   (public_html/css/club.css .play-board .sq / .piece)
   ใช้ร่วมกันทั้งหน้าเขียนบทความ (กดวางหมาก) และหน้าอ่าน (ล็อกตำแหน่ง)
   ========================================================================== */

.mkh-wrap {
    --mkh-light: #f4efe0;
    --mkh-dark: #6f9c76;
    --mkh-frame: #4c7a5d;
    --mkh-white: #fbf8ee;
    --mkh-white-rim: #2f6f4f;
    --mkh-black: #2f6f4f;
    --mkh-black-rim: #23543c;
    --mkh-crown: #b58a1a;
    --mkh-crown-on-dark: #f2d489;
}

/* ---------- ตัวกระดาน ---------- */
.mkh-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--mkh-frame);
    box-shadow: 0 6px 22px rgba(20, 30, 24, .16);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.mkh-sq {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    font: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.mkh-sq.mkh-light { background: var(--mkh-light); }
.mkh-sq.mkh-dark  { background: var(--mkh-dark); }
/* ช่องสว่าง = เดินไม่ได้ ทำแบนลงให้เห็นว่าไม่ใช่ช่องเล่น (เฉพาะโหมดเขียน) */
.mkh-sq.mkh-light.mkh-blocked { cursor: not-allowed; }
.mkh-sq.mkh-light.mkh-blocked .mkh-piece { opacity: .35; }
.mkh-sq.mkh-dark { cursor: pointer; }

/* ---------- ตัวหมาก (วงกลมแบนคม เหมือนในเกม) ---------- */
.mkh-piece {
    position: relative;
    display: block;
    width: 76%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    box-sizing: border-box;
    background: transparent;
    border: 0;
    pointer-events: none;
    transition: transform .12s ease;
}
.mkh-piece.mkh-empty { visibility: hidden; }

.mkh-piece.mkh-w,
.mkh-piece.mkh-k {
    background: var(--mkh-white);
    border: 2px solid var(--mkh-white-rim);
}
.mkh-piece.mkh-b,
.mkh-piece.mkh-q {
    background: var(--mkh-black);
    border: 2px solid var(--mkh-black-rim);
}

/* วงมงกุฎ = ตัวใหญ่ (ฮอส) */
.mkh-piece.mkh-k::before,
.mkh-piece.mkh-q::before {
    content: "";
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    border: 2px solid var(--mkh-crown);
}
.mkh-piece.mkh-q::before { border-color: var(--mkh-crown-on-dark); }

/* ---------- พิกัด a-h / 1-8 มุมช่อง ---------- */
.mkh-coord {
    position: absolute;
    font-size: 9px;
    line-height: 1;
    font-weight: 600;
    letter-spacing: .02em;
    pointer-events: none;
    opacity: .55;
}
.mkh-coord-file { right: 3px; bottom: 2px; }
.mkh-coord-rank { left: 3px; top: 2px; }
.mkh-light .mkh-coord { color: #6f9c76; }
.mkh-dark .mkh-coord  { color: #f4efe0; }

/* ==========================================================================
   หน้าอ่าน — ล็อก ไม่กดได้
   ========================================================================== */
.mkh-figure {
    margin: 1.6em 0;
}
.mkh-figure .mkh-board {
    max-width: 420px;
    margin: 0 auto;
}
.mkh-figure figcaption {
    margin: .85em auto 0;
    max-width: 420px;
    text-align: center;
    font-size: .95em;
    line-height: 1.6;
    font-weight: 600;
    color: #245B45;
    padding: 0 .5em;
}
.mkh-figure figcaption::before {
    content: "\2014\00a0";
    color: #C8F169;
    font-weight: 700;
}
.mkh-figure figcaption:empty { display: none; }

/* ==========================================================================
   หน้าเขียน — แผงวางหมาก
   ========================================================================== */
.mkh-panel {
    border: 1px solid #E5DFD5;
    border-radius: 16px;
    background: #FFFDF7;
    overflow: hidden;
}

.mkh-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #EDE7DC;
    background: linear-gradient(180deg, #FFFFFF 0%, #FFFDF7 100%);
}

.mkh-title {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    font-weight: 700;
    color: #245B45;
    letter-spacing: .01em;
}
.mkh-title svg { width: 15px; height: 15px; flex: none; }

.mkh-panel-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 208px;
    gap: 16px;
    padding: 14px;
    align-items: start;
}

@media (max-width: 560px) {
    .mkh-panel-body { grid-template-columns: minmax(0, 1fr); gap: 12px; padding: 12px; }
}

/* --- แผงควบคุมด้านข้าง --- */
.mkh-side { display: flex; flex-direction: column; gap: 10px; }

.mkh-picks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
@media (max-width: 560px) {
    .mkh-picks { grid-template-columns: 1fr 1fr; }
}

.mkh-pick {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 4px 7px;
    border: 1px solid #E5DFD5;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.mkh-pick:hover { border-color: #C8F169; }
.mkh-pick.mkh-on {
    border-color: #245B45;
    background: #F5FAEF;
    box-shadow: 0 0 0 2px rgba(36, 91, 69, .12);
}
.mkh-pick .mkh-swatch {
    width: 26px; height: 26px;
    border-radius: 50%;
    box-sizing: border-box;
}
.mkh-pick .mkh-swatch.mkh-w { background: var(--mkh-white); border: 2px solid var(--mkh-white-rim); }
.mkh-pick .mkh-swatch.mkh-b { background: var(--mkh-black); border: 2px solid var(--mkh-black-rim); }
.mkh-pick .mkh-swatch.mkh-k::before,
.mkh-pick .mkh-swatch.mkh-q::before {
    content: ""; display: block; width: 100%; height: 100%;
    border-radius: 50%; box-sizing: border-box;
}
.mkh-pick .mkh-swatch.mkh-k::before { border: 2px solid var(--mkh-crown); }
.mkh-pick .mkh-swatch.mkh-q::before { border: 2px solid var(--mkh-crown-on-dark); }
.mkh-pick .mkh-plabel {
    font-size: 10.5px;
    font-weight: 600;
    color: #4B4F4B;
    line-height: 1.2;
    text-align: center;
}
.mkh-pick .mkh-pcount {
    font-size: 10px;
    color: #9AA09A;
    font-variant-numeric: tabular-nums;
}
.mkh-pick.mkh-on .mkh-pcount { color: #245B45; }
.mkh-pick.mkh-full .mkh-pcount { color: #b45309; }
/* ปุ่มของฝ่ายที่เต็มแล้ว: หรี่ลงแต่ยังกดได้เพื่อสลับไปดูอีกฝ่าย */
.mkh-pick.mkh-disabled .mkh-swatch { opacity: .38; }

/* --- ปุ่มล่าง --- */
.mkh-actions { display: flex; gap: 8px; }
.mkh-btn {
    flex: 1;
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid #E5DFD5;
    background: #fff;
    color: #3C413C;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
    white-space: nowrap;
}
.mkh-btn:hover { background: #F7F4EC; border-color: #D6CFC0; }
.mkh-btn.mkh-primary {
    background: #245B45;
    border-color: #245B45;
    color: #FFFDF7;
}
.mkh-btn.mkh-primary:hover { background: #1d4a38; }

.mkh-tip {
    font-size: 10.5px;
    line-height: 1.5;
    color: #8A8F8A;
}
.mkh-flash {
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
    opacity: 0;
    transition: opacity .2s;
    min-height: 1em;
}
.mkh-flash.mkh-show { opacity: 1; }

/* ---------- เปิด/ปิดกระดาน: toggle switch ---------- */
.mkh-switch-row {
    display: flex;
    align-items: center;
    gap: 11px;
}
.mkh-switch-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: #F1F7EC;
    color: #245B45;
}
.mkh-switch-icon svg { width: 17px; height: 17px; }

.mkh-switch-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.mkh-switch-t { font-size: 13.5px; font-weight: 700; color: #1E201E; line-height: 1.3; }
.mkh-switch-s { font-size: 11px; color: #8A908A; line-height: 1.35; }

.mkh-switch { position: relative; flex: none; display: inline-block; cursor: pointer; line-height: 0; }
.mkh-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }

.mkh-switch-track {
    display: block;
    width: 48px;
    height: 28px;
    border-radius: 999px;
    background: #DED8CC;
    box-shadow: inset 0 1px 2px rgba(30, 32, 30, .12);
    transition: background .18s ease;
}
.mkh-switch-thumb {
    display: block;
    width: 22px;
    height: 22px;
    margin: 3px;
    border-radius: 50%;
    background: #FFFDF7;
    box-shadow: 0 1px 3px rgba(30, 32, 30, .28);
    transition: transform .18s cubic-bezier(.3, .9, .35, 1);
}

.mkh-switch input:checked + .mkh-switch-track { background: #245B45; }
.mkh-switch input:checked + .mkh-switch-track .mkh-switch-thumb { transform: translateX(20px); }
.mkh-switch input:focus-visible + .mkh-switch-track {
    outline: 2px solid #C8F169;
    outline-offset: 2px;
}
.mkh-switch:hover .mkh-switch-track { filter: brightness(.97); }

@media (max-width: 420px) {
    .mkh-switch-icon { display: none; }
    .mkh-switch-t { font-size: 13px; }
}

/* ช่องหัวข้อกระดาน (caption) ใต้ปุ่มล้างกระดาน */
.mkh-cap-field { display:block; margin-top:14px; }
.mkh-cap-label { display:block; margin-bottom:6px; font-size:12.5px; font-weight:600; color:#245b45; }
.mkh-cap-field input {
  width:100%; box-sizing:border-box; padding:10px 13px;
  border:1px solid #DED8CC; border-radius:10px;
  background:#fffdf7; color:#2b2b2b; font-size:14px; font-family:inherit;
}
.mkh-cap-field input:focus { outline:none; border-color:#245b45; box-shadow:0 0 0 3px rgba(36,91,69,.12); }

/* เลขช่อง 1-32 บนช่องเข้ม */
.mkh-coord-num {
  position: absolute; top: 1px; right: 3px;
  font-size: 9px; font-weight: 700; line-height: 1;
  color: rgba(255, 255, 255, .62);
  font-family: 'Inter', system-ui, sans-serif;
  pointer-events: none; user-select: none;
  letter-spacing: -.2px;
}
.mkh-sq { position: relative; }
@media (max-width: 640px) { .mkh-coord-num { font-size: 7.5px; top: 0; right: 2px; } }

/* ---------- ย้าย/ลบหมาก: ลาก, เลือก, ถังขยะ ---------- */
.mkh-grid .mkh-sq[draggable="true"] { cursor: grab; touch-action: none; }
.mkh-grid .mkh-sq[draggable="true"]:active { cursor: grabbing; }
.mkh-grid .mkh-sq.mkh-dragging { opacity: .35; }
.mkh-grid .mkh-sq.mkh-dropok::after {
    content: ""; position: absolute; inset: 3px; border-radius: 6px;
    border: 2px dashed #245B45; background: rgba(200,241,105,.35); pointer-events: none;
}
.mkh-grid .mkh-sq.mkh-sel { box-shadow: inset 0 0 0 3px #245B45; }
.mkh-grid .mkh-sq.mkh-sel .mkh-piece:not(.mkh-empty) { transform: scale(1.08); }

.mkh-trash {
    display: flex; align-items: center; gap: .5em;
    margin-top: .55em; padding: .55em .8em;
    border: 1.5px dashed #cfc9b8; border-radius: 12px;
    color: #8a8f8a; font-size: .8em; background: #faf7ee;
    cursor: pointer; user-select: none;
    transition: background .18s, border-color .18s, color .18s, transform .18s;
}
.mkh-trash svg { width: 18px; height: 18px; flex: 0 0 auto; }
.mkh-trash-label { line-height: 1.3; }
.mkh-trash-sq { margin-left: auto; font-weight: 700; }
.mkh-trash.mkh-hot { border-color: #245B45; color: #245B45; background: #f2f8f0; }
.mkh-trash.mkh-over {
    border-color: #245B45; color: #fff; background: #245B45;
    transform: scale(1.03); border-style: solid;
}


/* ---------- dropzone overlay ระหว่างลากหมาก ---------- */
.mkh-dropshield {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 59;
}
.mkh-dropshield.mkh-on { display: block; }
.mkh-dropshield.mkh-on {
    outline: 2px dashed rgba(36, 91, 69, .25);
    outline-offset: -6px;
}

/* ---------- dialog แทรกรูปจาก image address ---------- */
.mkh-dlg {
    position: fixed;
    inset: 0;
    z-index: 90;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(36, 40, 36, .42);
    backdrop-filter: blur(3px);
}
.mkh-dlg.on { display: flex; }
.mkh-dlg-box {
    width: 100%;
    max-width: 420px;
    background: #fffdf7;
    border: 1px solid #e6e2d6;
    border-radius: 18px;
    padding: 20px 20px 16px;
    box-shadow: 0 18px 44px rgba(20, 24, 20, .22);
}
.mkh-dlg-box h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: #245b45;
}
.mkh-dlg-sub {
    margin: 0 0 12px;
    font-size: 12.5px;
    color: #6b6f6b;
}
#mkhImgUrl {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    font-size: 13px;
    border: 1px solid #d9d5c8;
    border-radius: 10px;
    background: #fff;
    color: #2b2f2b;
    outline: none;
}
#mkhImgUrl:focus {
    border-color: #c8f169;
    box-shadow: 0 0 0 3px rgba(200, 241, 105, .35);
}
.mkh-dlg-err {
    min-height: 16px;
    margin: 6px 0 0;
    font-size: 12px;
    color: #c2410c;
}
.mkh-dlg-acts {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}
.mkh-dlg-acts button {
    border: 0;
    border-radius: 10px;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.mkh-dlg-ghost {
    background: #f1efe6;
    color: #4b4f4b;
}
.mkh-dlg-main {
    background: #245b45;
    color: #fffdf7;
}
.mkh-dlg-main:hover { background: #1d4a38; }

/* ปุ่ม image ใน Quill toolbar — ให้เข้าธีมเดียวกับปุ่มอื่น */
.ql-snow .ql-toolbar .ql-image { opacity: .86; }
