*{box-sizing:border-box;font-family:Segoe UI, "Microsoft YaHei", Roboto, sans-serif}
html,body{height:100%;margin:0;background:#f7f4ef}
#app{min-height:100vh;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;padding:8px}
header{width:100%;display:flex;justify-content:center;padding:6px 0}
#turn{font-weight:700}
#board-area{flex:1;width:100%;display:flex;align-items:center;justify-content:center;flex-direction:column;gap:6px}
.board{width:100%;max-width:920px;aspect-ratio:9/10;position:relative;background:transparent;border-radius:10px}
#board-svg{position:absolute;inset:0;width:100%;height:100%;z-index:0}
.point{position:absolute;display:flex;align-items:center;justify-content:center;transform:translate(-50%,-50%);z-index:1}
.piece{position:relative;display:flex;align-items:center;justify-content:center;border-radius:50%;border:3px solid transparent;font-weight:700;overflow:visible}
.piece::before{content:"";position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);opacity:0.14;width:140%;height:140%;background-repeat:no-repeat;background-position:center center;background-size:contain;pointer-events:none;filter:grayscale(100%)}
.piece .label{position:relative;z-index:2;display:inline-block}
.piece.red{background:#ffefdf;color:#c11;border-color:#f7b2a1}
.piece.black{background:#fff;color:#111;border-color:#c3c3c3;transform:rotate(180deg)}
.point.selected{outline:3px solid rgba(0,128,0,0.18)}
/* per-piece SVG watermark patterns (subtle, use currentColor) */
.piece.type-r::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><rect x='14' y='28' width='72' height='44' rx='4' stroke='currentColor' stroke-width='8' fill='none' stroke-linejoin='round'/></svg>")}
.piece.type-n::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M20 70 C40 20 60 20 80 70' stroke='currentColor' stroke-width='8' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>")}
.piece.type-b::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M18 40 Q50 8 82 40' stroke='currentColor' stroke-width='8' fill='none' stroke-linecap='round'/><path d='M18 60 Q50 92 82 60' stroke='currentColor' stroke-width='8' fill='none' stroke-linecap='round'/></svg>")}
.piece.type-a::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><polygon points='50,12 82,50 50,88 12,50' stroke='currentColor' stroke-width='7' fill='none' stroke-linejoin='round'/></svg>")}
.piece.type-k::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><path d='M10 70 L25 38 L40 60 L58 30 L70 70 L90 20' stroke='currentColor' stroke-width='6' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>")}
.piece.type-c::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='40' r='22' stroke='currentColor' stroke-width='8' fill='none'/><circle cx='50' cy='72' r='6' stroke='currentColor' stroke-width='4' fill='none'/></svg>")}
.piece.type-p::before{background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='30' r='6' fill='currentColor'/><circle cx='50' cy='50' r='6' fill='currentColor'/><circle cx='50' cy='70' r='6' fill='currentColor'/></svg>")}

/* flipped board visual */
.board.flipped{transform:rotate(180deg);transition:transform 300ms}
.controls{width:100%;display:flex;flex-direction:column;gap:8px;padding:6px 8px;background:rgba(255,255,255,0.95);align-items:center}
.controls .btns{width:100%;display:flex;gap:8px;justify-content:space-between}
.controls button{flex:1;padding:10px;border-radius:8px;font-size:16px}
.status{padding:8px;text-align:center;font-weight:700;color:#2b6}
/* mobile defaults */
.board.wood{background-color:#e4c892;background-image:linear-gradient(180deg,rgba(255,255,255,0.06) 0%,rgba(0,0,0,0.03) 100%),repeating-linear-gradient(100deg,rgba(0,0,0,0.02) 0 1px,transparent 1px 6px)}
/* small screens adjustments */
@media (max-width:420px){
  .controls button{padding:10px;font-size:15px}
}

/* Font styles for piece labels (calligraphy options) */
/* Prefer web fonts for mobile; fall back to common system fonts */
.font-kaiti .piece .label{ font-family: 'Noto Serif SC', "KaiTi","STKaiti","楷体","Kaiti",serif; }
.font-xingkai .piece .label{ font-family: 'Zhi Mang Xing', "STXingkai","Xingkai","行楷","XingKai",serif; }
.font-lishu .piece .label{ font-family: 'ZCOOL XiaoWei', "LiSu","隶书","LiShu",serif; }
.font-caoshu .piece .label{ font-family: 'Zhi Mang Xing', "STCaiyun","草书","KaiTi",cursive; }
.font-zhuanshu .piece .label{ font-family: 'Noto Serif SC', "FZShuTi","篆书","Zhuan",serif; }

/* Force hide subtle watermark pseudo-element for pieces (user requested) */
.piece::before{display:none !important}