/* Cờ vua – toàn bộ CSS của trò (tiền tố covua-). Nạp sau style.css.
   Khung cảnh: mặt bàn gỗ nâu sẫm, bàn cờ gỗ hai màu có khung gỗ óc chó; quân cờ SVG tự vẽ. */
body[data-scene="covua"] {
  background-color: #5b3720;
  background-image:
    radial-gradient(ellipse 80% 50% at 30% 10%, rgba(255, 214, 160, .16), transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(0, 0, 0, .22), transparent 70%),
    repeating-linear-gradient(92deg, rgba(0, 0, 0, .07) 0 3px, transparent 3px 11px, rgba(255, 220, 170, .04) 11px 13px, transparent 13px 23px),
    repeating-linear-gradient(88deg, rgba(0, 0, 0, .05) 0 1px, transparent 1px 37px);
}
body[data-scene="covua"] .covua-backlink { color: #fbe7c4; }
.covua-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.covua-pc .covua-svg { width: 90%; height: 90%; }

/* ================= Màn chọn ================= */
.covua-setup { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); max-width: 640px; }
.covua-head { display: flex; gap: 14px; align-items: center; color: #fbe7c4; }
.covua-headart { display: block; width: 76px; height: 76px; flex: none; border-radius: 12px; border: 3px solid #2a170b; box-shadow: 0 3px 0 rgba(0, 0, 0, .3); background-size: cover; }
.covua-h1 { font: 700 2.6rem/1.05 "Mali", var(--f-hand); color: #fff3dc; text-shadow: 2px 2px 0 #2a170b; }
.covua-head p { margin: 4px 0 0; color: #f0d8b0; font-size: .95rem; }
.covua-box { background: #fffaf0; border: 2px solid #2a170b; border-radius: 16px; padding: 14px 16px 16px; display: grid; gap: 14px; box-shadow: 0 5px 0 rgba(0, 0, 0, .25); }
.covua-field { display: grid; gap: 6px; }
.covua-field h2 { font: 400 1.3rem/1.1 var(--f-hand); color: #6b3a1b; }
.covua-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.covua-seg button { font: 600 .9rem/1.2 var(--f-body); padding: .55em .9em; border-radius: 999px; border: 1.5px solid #8a5a32; background: #fff; color: #5b3720; cursor: pointer; }
.covua-seg button[aria-checked="true"] { background: #5b3720; border-color: #5b3720; color: #fff8ea; }
.covua-rnote { min-height: 1.3em; }
.covua-box .btn.ink { background: #5b3720; border-color: #2a170b; box-shadow: 2px 3px 0 rgba(42, 23, 11, .3); }
.covua-rules { background: #fffaf0; border: 1.5px dashed #8a5a32; border-radius: 14px; padding: 12px 18px; }
.covua-rules summary { font-family: var(--f-hand); font-size: 1.4rem; color: #6b3a1b; cursor: pointer; }
.covua-rules p, .covua-rules li { font-size: .95rem; }
.covua-rules ul { padding-left: 1.2em; }
.covua-note { color: var(--muted); font-size: .86rem !important; }

/* ================= Màn chơi ================= */
.covua-play { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.covua-bar { display: flex; align-items: center; gap: 8px; color: #fbe7c4; }
.covua-back { font: 1.7rem/1 var(--f-hand); color: #fbe7c4; background: none; border: 0; padding: 2px 8px 2px 0; cursor: pointer; }
.covua-bt { flex: 1; min-width: 0; display: grid; }
.covua-bt b { font: 700 1.45rem/1.1 "Mali", var(--f-hand); color: #fff3dc; text-shadow: 1px 1px 0 #2a170b; }
.covua-sub { font-size: .8rem; color: #e9cfa5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.covua-icon { background: none; border: 0; font-size: 1.3rem; cursor: pointer; padding: 6px; }
.covua-layout { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.covua-left { display: grid; gap: 6px; width: 100%; max-width: min(100%, calc(100svh - 190px)); min-width: 0; justify-self: center; }
@media (min-width: 900px) {
  .covua-layout { grid-template-columns: minmax(0, auto) 290px; justify-content: center; }
  .covua-left { width: min(620px, calc(100svh - 190px)); max-width: none; }
}

/* Hàng người chơi */
.covua-pl { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 10px; border-radius: 10px; background: rgba(255, 246, 228, .1); color: #fbe7c4; border: 1.5px solid transparent; transition: border-color .2s, background .2s; min-height: 40px; }
.covua-pl.on { border-color: #f4c873; background: rgba(255, 246, 228, .18); }
.covua-dotc { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 2px solid #1d120a; }
.covua-dotc0 { background: #fbf6ea; } .covua-dotc1 { background: #2d2724; border-color: #c9b490; }
.covua-pname { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.covua-pname em { font-style: normal; font-weight: 400; color: #e3c79c; font-size: .85em; }
.covua-caps { display: flex; align-items: center; flex: 1; min-width: 0; overflow: hidden; }
.covua-caps i { display: block; width: 18px; height: 18px; margin-right: -5px; flex: none; }
.covua-caps b { margin-left: 8px; font-size: .8rem; color: #f4c873; }
.covua-clock { font: 700 1.05rem/1 var(--f-body); font-variant-numeric: tabular-nums; padding: 6px 9px; border-radius: 8px; background: #2a170b; color: #e9d6b4; min-width: 4.4em; text-align: center; margin-left: auto; }
.covua-clock.run { background: #fff3dc; color: #2a170b; }
.covua-clock.low.run { background: #ffd8cf; color: #a01818; }

/* Bàn cờ */
.covua-frame { padding: 9px; border-radius: 10px; background: linear-gradient(135deg, #3b2213, #24140a 60%, #3d2414); box-shadow: 0 8px 20px rgba(0, 0, 0, .45), inset 0 0 0 2px rgba(255, 220, 170, .12); }
.covua-board { position: relative; width: 100%; aspect-ratio: 1; border-radius: 3px; overflow: hidden; container-type: inline-size; touch-action: manipulation; }
.covua-sqs { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.covua-sq { position: relative; border: 0; padding: 0; margin: 0; cursor: pointer; font: inherit; }
.covua-l { background-color: #f1d9ad; background-image: repeating-linear-gradient(100deg, rgba(160, 110, 50, .07) 0 2px, transparent 2px 7px); }
.covua-d { background-color: #b37a47; background-image: repeating-linear-gradient(80deg, rgba(70, 35, 10, .12) 0 2px, transparent 2px 6px); }
.covua-rk, .covua-fl { position: absolute; font: 700 max(9px, 2.6cqw)/1 var(--f-body); pointer-events: none; }
.covua-rk { left: 3%; top: 4%; } .covua-fl { right: 4%; bottom: 3%; }
.covua-l .covua-rk, .covua-l .covua-fl { color: #a26a3a; } .covua-d .covua-rk, .covua-d .covua-fl { color: #f6e3c0; }
.covua-sq.covua-last::before { content: ""; position: absolute; inset: 0; background: rgba(240, 200, 40, .42); }
.covua-sq.covua-sel::before { content: ""; position: absolute; inset: 0; background: rgba(60, 140, 60, .5); }
.covua-sq.covua-hint::before { content: ""; position: absolute; inset: 0; background: rgba(255, 220, 40, .55); box-shadow: inset 0 0 0 3px #e0a400; }
.covua-sq.covua-dot::after { content: ""; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%; background: rgba(30, 80, 30, .42); z-index: 3; pointer-events: none; }
.covua-sq.covua-capt::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: max(3px, .9cqw) solid rgba(30, 80, 30, .5); z-index: 3; pointer-events: none; }
.covua-sq.covua-chk { background-image: radial-gradient(circle, rgba(255, 30, 20, .95) 0, rgba(230, 20, 10, .55) 40%, rgba(200, 0, 0, 0) 72%); }
@media (prefers-reduced-motion: no-preference) { .covua-sq.covua-chkfx { animation: covua-pulse .5s ease-out 2; } }
@keyframes covua-pulse { 50% { box-shadow: inset 0 0 0 5px rgba(255, 40, 30, .9); } }
.covua-pcs { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.covua-pc { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; display: grid; place-items: center; transition: transform .24s cubic-bezier(.3, .7, .3, 1), opacity .3s; filter: drop-shadow(0 2px 1.5px rgba(0, 0, 0, .45)); will-change: transform; }
.covua-pc.covua-moving { z-index: 4; }
.covua-pc.covua-gone { opacity: 0; transition: opacity .3s, scale .3s; scale: .6; }
@media (prefers-reduced-motion: no-preference) { .covua-pc.covua-promo { animation: covua-grow .35s ease-out; } }
@keyframes covua-grow { from { scale: .4; } }
.covua-chkbanner { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 6; pointer-events: none; font: 700 clamp(1.6rem, 9cqw, 3.4rem)/1 "Mali", var(--f-hand); color: #fff; padding: .2em .6em; border-radius: 12px; background: rgba(170, 20, 20, .88); box-shadow: 0 4px 14px rgba(0, 0, 0, .4); opacity: 0; }
@media (prefers-reduced-motion: no-preference) { .covua-chkbanner { animation: covua-banner 1.1s ease-out; } }
@media (prefers-reduced-motion: reduce) { .covua-chkbanner { opacity: .9; } }
@keyframes covua-banner { 0% { opacity: 0; scale: .6; } 20% { opacity: 1; scale: 1.05; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; scale: 1; } }
.covua-promo-box { position: absolute; z-index: 8; width: 12.5%; display: grid; background: #fffaf0; border-radius: 6px; box-shadow: 0 4px 16px rgba(0, 0, 0, .5); overflow: hidden; }
.covua-promo-box button { aspect-ratio: 1; border: 0; background: #fffaf0; padding: 8%; cursor: pointer; }
.covua-promo-box button:hover, .covua-promo-box button:focus-visible { background: #f4c873; }
.covua-promo-box .covua-promo-x { aspect-ratio: auto; padding: 4px; font: 700 1rem var(--f-body); color: #6b3a1b; background: #ead8b8; }

/* Cột bên: trạng thái, nút, biên bản */
.covua-side { display: grid; gap: 10px; background: #fffaf0; border: 2px solid #2a170b; border-radius: 14px; padding: 10px 12px 12px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); min-width: 0; }
.covua-status { margin: 0; min-height: 1.5em; font: 400 1.25rem/1.25 var(--f-hand); color: #5b3720; }
.covua-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.covua-acts .btn { border-color: #5b3720; color: #5b3720; box-shadow: 1px 2px 0 rgba(42, 23, 11, .2); padding: .5em .7em; }
.covua-acts .btn.red { border-color: var(--red); color: var(--red); }
.covua-acts .btn.ink { background: #5b3720; color: #fff8ea; }
.covua-acts .btn:disabled { opacity: .45; cursor: default; }
.covua-moves { margin: 0; padding: 6px 8px; list-style: none; max-height: 8.5em; overflow-y: auto; background: #f6ecd8; border-radius: 8px; font: .9rem/1.5 var(--f-body); color: #3b2213; display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5em, 1fr)); column-gap: 10px; }
.covua-moves span { color: #9a7650; font-variant-numeric: tabular-nums; }
.covua-moves .covua-empty { color: #9a7650; grid-column: 1 / -1; }
@media (min-width: 900px) { .covua-moves { max-height: 22em; grid-template-columns: 1fr 1fr; } }
@media (max-width: 899.98px) { .covua-side { padding: 8px 10px 10px; } .covua-status { font-size: 1.15rem; } }
@media (max-width: 420px) { .covua-frame { padding: 5px; border-radius: 8px; } .covua-acts .btn { font-size: .84rem; padding: .48em .6em; } #app:has(.covua-play) { padding-top: 8px; } }
.art-covua { background: #b37a47 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E%3Crect x='0' y='0' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='24' y='0' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='48' y='0' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='72' y='0' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='0' y='24' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='24' y='24' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='48' y='24' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='72' y='24' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='0' y='48' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='24' y='48' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='48' y='48' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='72' y='48' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='0' y='72' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='24' y='72' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='48' y='72' width='24' height='24' fill='%23b37a47'/%3E%3Crect x='72' y='72' width='24' height='24' fill='%23f1d9ad'/%3E%3Crect x='0' y='0' width='96' height='96' fill='none' stroke='%233b2213' stroke-width='4'/%3E%3Cg transform='translate(2 4) scale(.56)'%3E%3Cg fill='%232d2724' stroke='%230f0c0b' stroke-width='3.2' stroke-linejoin='round'%3E%3Cpath d='M46.5 5h7v6.5h6.5v7h-6.5V27h-7v-8.5H40v-7h6.5z'/%3E%3Cpath d='M50 29c-5.5 0-9 3.6-9.4 8C32.8 32.6 20.5 36.8 20.5 48c0 8.2 5 14 9 21h41c4-7 9-12.8 9-21 0-11.2-12.3-15.4-20.1-11-.4-4.4-3.9-8-9.4-8z'/%3E%3Cpath d='M29.5 69h41l1.5 8H28z'/%3E%3Cpath d='M27 77h46l4 4.5V88H23v-6.5z'/%3E%3Cpath fill='none' stroke='%23d9cdb2' stroke-width='2.6' stroke-linecap='round' d='M50 37v31M31 63h38'/%3E%3C/g%3E%3C/g%3E%3Cg transform='translate(40 30) scale(.62)'%3E%3Cg fill='%23fbf6ea' stroke='%232b2118' stroke-width='3.2' stroke-linejoin='round'%3E%3Cpath d='M33 77c-1.5-13 3.5-22 14-28.5-6.5-.5-12 1.8-16.5 6.3-4.6 1.5-9.2-1.4-9.2-6 .5-6.5 7-14.3 14.7-19.3L40 17l7.5 7.2L53 14l4.4 10.6C71 29 79.5 43 77.5 61L76 77z'/%3E%3Cpath d='M27 77h46l4 4.5V88H23v-6.5z'/%3E%3Cpath fill='none' stroke='%237a6650' stroke-width='2.6' stroke-linecap='round' d='M61 31c6 8 9.5 18 9.5 31'/%3E%3Ccircle fill='%237a6650' stroke='none' cx='40.5' cy='35' r='3'/%3E%3Ccircle fill='%237a6650' stroke='none' cx='25.5' cy='49' r='1.8'/%3E%3C/g%3E%3C/g%3E%3Cg transform='translate(0 52) scale(.42)'%3E%3Cg fill='%23fbf6ea' stroke='%232b2118' stroke-width='3.2' stroke-linejoin='round'%3E%3Cpath d='M50 19a11.5 11.5 0 0 1 6.8 20.8C61.5 42 64.5 45 64.5 48.5h-6.5c1.6 9.5 7 18.5 12.5 28.5H29.5C35 67 40.4 58 42 48.5h-6.5c0-3.5 3-6.5 7.7-8.7A11.5 11.5 0 0 1 50 19z'/%3E%3Cpath d='M27 77h46l4 4.5V88H23v-6.5z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") center/cover no-repeat; }
.covua-resume { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; justify-content: space-between; padding: 12px 14px; background: #fff3c4; border: 2.5px solid #e0a400; border-radius: 14px; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.covua-resume > div:first-child { display: grid; gap: 2px; min-width: 0; }
.covua-resume b { font: 400 1.35rem/1.1 var(--f-hand); color: #6b3a1b; }
.covua-resume span { font-size: .88rem; color: #5b3720; }
.covua-resume-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.covua-resume .btn.ink { background: #5b3720; border-color: #2a170b; }
.covua-resume .btn:not(.ink) { border-color: #5b3720; color: #5b3720; box-shadow: 2px 3px 0 rgba(42, 23, 11, .2); }

/* ================= Điện thoại xoay ngang ================= */
/* Cột trái: tiêu đề, người chơi trên, trạng thái + nút + biên bản (tự cuộn), người chơi dưới; cột phải: bàn cờ cao bằng màn hình. */
@media (orientation: landscape) and (max-height: 540px) {
  #app:has(.covua-play) { max-width: none; padding-top: 8px; }
  .covua-play { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto auto minmax(0, 1fr) auto; column-gap: 14px; row-gap: 6px; height: calc(100dvh - 18px); }
  .covua-layout, .covua-left { display: contents; }
  .covua-bar { grid-column: 1; grid-row: 1; gap: 6px; }
  .covua-back, .covua-icon { min-width: 40px; min-height: 40px; }
  .covua-bar .rot-btn { min-height: 40px; }
  .covua-bt b { font-size: 1.25rem; }
  .covua-pl-top { grid-column: 1; grid-row: 2; }
  .covua-pl-bot { grid-column: 1; grid-row: 4; }
  .covua-side { grid-column: 1; grid-row: 3; align-content: start; gap: 8px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 10px; }
  .covua-status { font-size: 1.1rem; }
  .covua-acts .btn { min-height: 40px; padding: .35em .6em; }
  .covua-moves { max-height: none; min-height: 3em; }
  .covua-frame { grid-column: 2; grid-row: 1 / -1; align-self: center; width: calc(100dvh - 22px); }
}
