/* Cờ tướng – toàn bộ CSS của trò (tiền tố cotuong-). Nạp sau style.css.
   Khung cảnh: tấm chiếu tre trải dưới đất, bàn cờ giấy (bìa) kẻ ô nâu đỏ, "Sở hà – Hán giới" giữa sông;
   quân tròn bằng gỗ, mặt màu kem, chữ đỏ hoặc đen trong vòng tròn. */
body[data-scene="cotuong"] {
  background-color: #c8a465;
  background-image:
    radial-gradient(ellipse 70% 50% at 25% 15%, rgba(255, 244, 210, .28), transparent 70%),
    radial-gradient(ellipse 60% 50% at 80% 90%, rgba(90, 60, 10, .22), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 118px, rgba(92, 62, 20, .35) 118px 121px),
    repeating-linear-gradient(0deg, rgba(120, 82, 28, .22) 0 1.5px, rgba(255, 240, 200, .12) 1.5px 3px, transparent 3px 7px, rgba(120, 82, 28, .12) 7px 8px);
}
body[data-scene="cotuong"] .cotuong-backlink { color: #4a2a0c; }

/* ---- Quân tròn ---- */
.cotuong-disc { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 50%; container-type: inline-size; position: relative;
  background: radial-gradient(circle at 38% 30%, #fff6dc 0, #f4dca6 48%, #e2b873 82%, #c99650 100%);
  box-shadow: inset 0 -2px 0 rgba(120, 70, 20, .35), 0 2px 0 #8a5a2b, 0 3px 5px rgba(40, 20, 0, .45); }
.cotuong-disc::before { content: ""; position: absolute; inset: 9%; border-radius: 50%; border: max(1px, 3cqw) solid currentColor; opacity: .85; }
.cotuong-disc b { position: relative; line-height: 1; font-weight: 700; white-space: nowrap; }
.cotuong-c0 { color: #b8231b; } .cotuong-c1 { color: #1d1d1f; }
.cotuong-han b { font: 700 56cqw/1 "Noto Serif TC", "STKaiti", "KaiTi", "Kaiti TC", "PMingLiU", "WenQuanYi Zen Hei", serif; translate: 0 -2%; }
.cotuong-vi b { font: 700 24cqw/1 var(--f-body); letter-spacing: -.03em; }
.cotuong-vi.cotuong-c0 b, .cotuong-vi.cotuong-c1 b { text-shadow: 0 1px 0 rgba(255, 255, 255, .5); }

/* ================= Màn chọn ================= */
.cotuong-setup { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); max-width: 660px; }
.cotuong-head { display: flex; gap: 14px; align-items: center; }
.cotuong-headart { display: block; width: 76px; height: 76px; flex: none; border-radius: 12px; border: 3px solid #5a2e12; box-shadow: 0 3px 0 rgba(60, 30, 0, .3); background-size: cover; }
.cotuong-h1 { font: 700 2.6rem/1.05 "Mali", var(--f-hand); color: #a8231b; text-shadow: 2px 2px 0 #fff1cf; }
.cotuong-head p { margin: 4px 0 0; color: #4a2a0c; font-size: .95rem; }
.cotuong-box { background: #fff8e6; border: 2px solid #5a2e12; border-radius: 16px; padding: 14px 16px 16px; display: grid; gap: 14px; box-shadow: 0 5px 0 rgba(90, 46, 18, .25); }
.cotuong-field { display: grid; gap: 6px; }
.cotuong-field h2 { font: 400 1.3rem/1.1 var(--f-hand); color: #a8231b; }
.cotuong-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.cotuong-seg button { font: 600 .9rem/1.2 var(--f-body); padding: .55em .9em; border-radius: 999px; border: 1.5px solid #8a3a1b; background: #fff; color: #6b2a12; cursor: pointer; text-align: left; }
.cotuong-seg button[aria-checked="true"] { background: #a8231b; border-color: #a8231b; color: #fff8ea; }
.cotuong-rnote { min-height: 1.3em; }
.cotuong-sample { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
.cotuong-sample .cotuong-disc { width: 46px; }
.cotuong-box .btn.ink { background: #a8231b; border-color: #6b1510; box-shadow: 2px 3px 0 rgba(107, 21, 16, .3); }
.cotuong-rules { background: #fff8e6; border: 1.5px dashed #8a3a1b; border-radius: 14px; padding: 12px 18px; }
.cotuong-rules summary { font-family: var(--f-hand); font-size: 1.4rem; color: #a8231b; cursor: pointer; }
.cotuong-rules p, .cotuong-rules li { font-size: .95rem; }
.cotuong-rules ul { padding-left: 1.2em; }
.cotuong-note { color: var(--muted); font-size: .86rem !important; }

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

.cotuong-pl { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 10px; border-radius: 10px; background: rgba(255, 248, 230, .55); color: #3b1f08; border: 1.5px solid transparent; transition: border-color .2s, background .2s; min-height: 40px; }
.cotuong-pl.on { border-color: #a8231b; background: rgba(255, 248, 230, .9); }
.cotuong-dotc { width: 16px; height: 16px; border-radius: 50%; flex: none; border: 3px solid currentColor; background: #f4dca6; }
.cotuong-dotc0 { color: #b8231b; } .cotuong-dotc1 { color: #1d1d1f; }
.cotuong-pname { font-weight: 600; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.cotuong-pname em { font-style: normal; font-weight: 400; color: #7a5228; font-size: .85em; }
.cotuong-caps { display: flex; align-items: center; flex: 1; min-width: 0; overflow: hidden; }
.cotuong-caps .cotuong-disc { width: 20px; flex: none; margin-right: -4px; box-shadow: 0 1px 0 #8a5a2b; }
.cotuong-caps b { margin-left: 8px; font-size: .8rem; color: #a8231b; }
.cotuong-clock { font: 700 1.05rem/1 var(--f-body); font-variant-numeric: tabular-nums; padding: 6px 9px; border-radius: 8px; background: #5a2e12; color: #f4dca6; min-width: 4.4em; text-align: center; margin-left: auto; }
.cotuong-clock.run { background: #fff8e6; color: #5a2e12; box-shadow: inset 0 0 0 2px #5a2e12; }
.cotuong-clock.low.run { background: #ffd8cf; color: #a01818; }

/* Bàn giấy */
.cotuong-paper { padding: 7px; border-radius: 4px; background-color: #f6e7c3;
  background-image: radial-gradient(rgba(140, 90, 30, .10) 1px, transparent 1.3px), radial-gradient(ellipse at 30% 20%, rgba(255, 255, 255, .5), transparent 60%), radial-gradient(ellipse at 80% 85%, rgba(170, 110, 40, .14), transparent 60%);
  background-size: 5px 5px, auto, auto; box-shadow: 0 1px 0 #d8bf8a, 0 6px 14px rgba(60, 35, 5, .35); rotate: -.4deg; }
.cotuong-board { position: relative; width: 100%; aspect-ratio: 9 / 10; touch-action: manipulation; container-type: inline-size; }
.cotuong-svgwrap, .cotuong-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.cotuong-rv { font: 400 60px/1 var(--f-hand); fill: #a8231b; text-anchor: middle; dominant-baseline: central; letter-spacing: 2px; }
.cotuong-rvh { font: 700 62px/1 "Noto Serif TC", "STKaiti", "KaiTi", "PMingLiU", "WenQuanYi Zen Hei", serif; letter-spacing: 0; }
.cotuong-pts { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(9, 1fr); grid-template-rows: repeat(10, 1fr); z-index: 3; }
.cotuong-pt { position: relative; border: 0; padding: 0; margin: 0; background: none; cursor: pointer; border-radius: 50%; }
.cotuong-pt.cotuong-dot::after { content: ""; position: absolute; left: 36%; top: 36%; width: 28%; height: 28%; border-radius: 50%; background: rgba(30, 120, 50, .72); box-shadow: 0 0 0 2px rgba(255, 255, 255, .7); }
.cotuong-pt.cotuong-capt::after { content: ""; position: absolute; inset: 1%; border-radius: 50%; border: max(3px, .8cqw) solid rgba(30, 140, 50, .85); }
.cotuong-pt.cotuong-from::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 2px dashed rgba(168, 35, 27, .75); }
.cotuong-pt.cotuong-hint::after { content: ""; position: absolute; inset: 0; border-radius: 50%; background: rgba(255, 210, 30, .45); box-shadow: 0 0 0 3px #e0a400; }
.cotuong-pcs { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.cotuong-pc { position: absolute; left: 0; top: 0; width: 11.111%; height: 10%; display: grid; place-items: center; transition: transform .26s cubic-bezier(.3, .7, .3, 1), opacity .3s; will-change: transform; }
.cotuong-pc .cotuong-disc { width: 90%; transition: translate .15s, scale .15s, box-shadow .15s; }
.cotuong-pc.cotuong-moving { z-index: 5; }
.cotuong-pc.cotuong-moving .cotuong-disc { scale: 1.1; box-shadow: 0 2px 0 #8a5a2b, 0 10px 14px rgba(40, 20, 0, .35); }
.cotuong-pc.cotuong-sel { z-index: 4; }
.cotuong-pc.cotuong-sel .cotuong-disc { translate: 0 -6%; scale: 1.08; box-shadow: 0 0 0 max(2px, .6cqw) #2f8a3e, 0 2px 0 #8a5a2b, 0 8px 12px rgba(40, 20, 0, .4); }
.cotuong-pc.cotuong-last .cotuong-disc { box-shadow: 0 0 0 max(2px, .5cqw) #e0a400, 0 2px 0 #8a5a2b, 0 3px 5px rgba(40, 20, 0, .45); }
.cotuong-pc.cotuong-chk .cotuong-disc { box-shadow: 0 0 0 max(3px, .7cqw) #e3241b, 0 0 18px 6px rgba(230, 30, 20, .75), 0 2px 0 #8a5a2b; }
@media (prefers-reduced-motion: no-preference) { .cotuong-pc.cotuong-chk .cotuong-disc { animation: cotuong-pulse .9s ease-in-out 2; } }
@keyframes cotuong-pulse { 50% { scale: 1.12; } }
.cotuong-pc.cotuong-gone { opacity: 0; scale: .5; transition: opacity .32s, scale .32s; }
.cotuong-chkbanner { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 6; pointer-events: none; white-space: nowrap; font: 700 clamp(1.5rem, 8cqw, 3.2rem)/1 "Mali", var(--f-hand); color: #fff8e6; padding: .2em .6em; border-radius: 12px; background: rgba(168, 35, 27, .92); box-shadow: 0 4px 14px rgba(0, 0, 0, .35); opacity: 0; }
@media (prefers-reduced-motion: no-preference) { .cotuong-chkbanner { animation: cotuong-banner 1.1s ease-out; } }
@media (prefers-reduced-motion: reduce) { .cotuong-chkbanner { opacity: .9; } }
@keyframes cotuong-banner { 0% { opacity: 0; scale: .6; } 20% { opacity: 1; scale: 1.05; } 70% { opacity: 1; scale: 1; } 100% { opacity: 0; } }

.cotuong-side { display: grid; gap: 10px; background: #fff8e6; border: 2px solid #5a2e12; border-radius: 14px; padding: 10px 12px 12px; box-shadow: 0 4px 0 rgba(90, 46, 18, .25); min-width: 0; }
.cotuong-status { margin: 0; min-height: 1.5em; font: 400 1.25rem/1.25 var(--f-hand); color: #6b1510; }
.cotuong-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cotuong-acts .btn { border-color: #6b2a12; color: #6b2a12; box-shadow: 1px 2px 0 rgba(90, 46, 18, .2); padding: .5em .7em; }
.cotuong-acts .btn.red { border-color: var(--red); color: var(--red); }
.cotuong-acts .btn.ink { background: #a8231b; border-color: #6b1510; color: #fff8ea; }
.cotuong-acts .btn:disabled { opacity: .45; cursor: default; }
.cotuong-moves { margin: 0; padding: 6px 8px; list-style: none; max-height: 8.5em; overflow-y: auto; background: #f6e7c3; border-radius: 8px; font: .9rem/1.5 var(--f-body); color: #3b1f08; display: grid; grid-template-columns: repeat(auto-fill, minmax(9em, 1fr)); column-gap: 10px; }
.cotuong-moves span { color: #9a7650; font-variant-numeric: tabular-nums; }
.cotuong-moves i { font-style: normal; } .cotuong-n0 { color: #a8231b; }
.cotuong-moves .cotuong-empty { color: #9a7650; grid-column: 1 / -1; }
@media (min-width: 900px) { .cotuong-moves { max-height: 22em; grid-template-columns: 1fr 1fr; } }
@media (max-width: 899.98px) { .cotuong-side { padding: 8px 10px 10px; } .cotuong-status { font-size: 1.15rem; } }
@media (max-width: 420px) { .cotuong-paper { padding: 4px; } .cotuong-acts .btn { font-size: .84rem; padding: .48em .6em; } #app:has(.cotuong-play) { padding-top: 8px; } }
.art-cotuong { background: #f6e7c3 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 96 96'%3E%3Cdefs%3E%3CradialGradient id='g' cx='.38' cy='.3' r='.75'%3E%3Cstop offset='0' stop-color='%23fff6dc'/%3E%3Cstop offset='.55' stop-color='%23f4dca6'/%3E%3Cstop offset='1' stop-color='%23d4a560'/%3E%3C/radialGradient%3E%3C/defs%3E%3Crect width='96' height='96' fill='%23f6e7c3'/%3E%3Cpath d='M6 0V96M0 6H96M34 0V96M0 34H96M62 0V96M0 62H96M90 0V96M0 90H96M34 6L90 62M90 6L34 62' fill='none' stroke='%235a2e12' stroke-width='1.6'/%3E%3Crect x='2' y='2' width='92' height='92' fill='none' stroke='%235a2e12' stroke-width='3'/%3E%3Ccircle cx='62' cy='35.6' r='17' fill='%238a5a2b'/%3E%3Ccircle cx='62' cy='34' r='17' fill='url(%23g)'/%3E%3Ccircle cx='62' cy='34' r='13.600000000000001' fill='none' stroke='%231d1d1f' stroke-width='1.4'/%3E%3Ctext x='62' y='40.12' text-anchor='middle' font-size='17.85' font-weight='700' font-family='Noto Serif TC,STKaiti,KaiTi,PMingLiU,WenQuanYi Zen Hei,serif' fill='%231d1d1f'%3E%E5%B0%87%3C/text%3E%3Ccircle cx='34' cy='63.6' r='21' fill='%238a5a2b'/%3E%3Ccircle cx='34' cy='62' r='21' fill='url(%23g)'/%3E%3Ccircle cx='34' cy='62' r='16.8' fill='none' stroke='%23b8231b' stroke-width='1.4'/%3E%3Ctext x='34' y='69.56' text-anchor='middle' font-size='22.05' font-weight='700' font-family='Noto Serif TC,STKaiti,KaiTi,PMingLiU,WenQuanYi Zen Hei,serif' fill='%23b8231b'%3E%E5%B8%A5%3C/text%3E%3C/svg%3E") center/cover no-repeat; }
.cotuong-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); }
.cotuong-resume > div:first-child { display: grid; gap: 2px; min-width: 0; }
.cotuong-resume b { font: 400 1.35rem/1.1 var(--f-hand); color: #a8231b; }
.cotuong-resume span { font-size: .88rem; color: #6b2a12; }
.cotuong-resume-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.cotuong-resume .btn.ink { background: #a8231b; border-color: #6b1510; }
.cotuong-resume .btn:not(.ink) { border-color: #a8231b; color: #a8231b; box-shadow: 2px 3px 0 rgba(107, 21, 16, .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(.cotuong-play) { max-width: none; padding-top: 8px; }
  .cotuong-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); }
  .cotuong-layout, .cotuong-left { display: contents; }
  .cotuong-bar { grid-column: 1; grid-row: 1; gap: 6px; }
  .cotuong-back, .cotuong-icon { min-width: 40px; min-height: 40px; }
  .cotuong-bar .rot-btn { min-height: 40px; }
  .cotuong-bt b { font-size: 1.25rem; }
  .cotuong-pl-top { grid-column: 1; grid-row: 2; }
  .cotuong-pl-bot { grid-column: 1; grid-row: 4; }
  .cotuong-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; }
  .cotuong-status { font-size: 1.1rem; }
  .cotuong-acts .btn { min-height: 40px; padding: .35em .6em; }
  .cotuong-moves { max-height: none; min-height: 3em; }
  .cotuong-paper { grid-column: 2; grid-row: 1 / -1; align-self: center; width: calc((100dvh - 36px) * .9 + 14px); }
}
