*{box-sizing:border-box}
html,body{margin:0;padding:0}
html{overflow-x:hidden}
body{font:16px/1.4 system-ui,sans-serif;color:#222;background:#f4f1ea;padding:8px 8px 24px;overflow-x:hidden}
h1{font-size:18px;margin:0 0 8px}
.top{position:sticky;top:0;z-index:10;background:#f4f1ea;padding:4px 0 8px;border-bottom:1px solid #d4cfc3}
.toolbar{display:flex;gap:8px;align-items:center;flex-wrap:wrap}
button,select,input{font:inherit}
button{cursor:pointer;padding:8px 12px;min-height:44px;min-width:44px;touch-action:manipulation;background:#fff;border:1px solid #bbb;border-radius:4px}
button[aria-pressed=true]{background:#214f83;color:#fff;border-color:#214f83}
label{display:inline-flex;align-items:center;gap:6px;min-height:44px}
select{min-height:44px;min-width:72px;padding:6px;font-size:16px}
.note,#message,#selection,#timing{margin:4px 0}
.note{font-size:13px;color:#333}
#message{min-height:20px;font-weight:700}
#selection,#timing{font-family:ui-monospace,monospace;font-size:13px}

.classic-board-wrap{overflow-x:hidden;overflow-y:visible;-webkit-overflow-scrolling:touch;background:#efece3;border:1px solid #d4cfc3;border-radius:8px;padding:10px;touch-action:manipulation;-webkit-tap-highlight-color:transparent;margin:8px 0}
.c-board{display:block;position:relative;width:100%;max-width:100%;background:#efece3}
.c-strip{background:#fffef6;box-shadow:0 0 0 1px #222;width:100%;max-width:100%;margin:0 auto}
.c-paper{border-collapse:collapse;width:100%;max-width:100%;table-layout:fixed;font-size:16px;font-variant-numeric:tabular-nums;font-family:"Noto Serif TC","Songti TC","PMingLiU","Kaiti TC","Noto Serif","Times New Roman",serif;color:#111;margin:0;user-select:none;-webkit-user-select:none}
.c-paper th,.c-paper td{border:1px solid #2a2a2a;padding:0;text-align:center;white-space:nowrap;background:#fffef6;color:#111}
.c-paper th{background:#f0ebe0;color:#111;font-weight:700;font-size:13px;height:26px}
.c-paper tr.c-mon th{background:#e7e0d0;font-size:13px;letter-spacing:.4px;height:22px;font-weight:700}
.c-meta{font-size:15px;font-weight:600;width:11%}
.c-num{position:relative;width:auto;min-width:0;height:34px;font-size:18px;font-weight:700;cursor:pointer;line-height:34px;touch-action:manipulation}
.c-txt{position:relative;z-index:1;display:block}
.c-ring,.c-box{position:absolute;pointer-events:none;z-index:2;inset:1px}
.c-ring{border:2px solid #c1121f;border-radius:50%}
.c-box{border:2px solid #1d4ed8;border-radius:0}
.c-num.match-front{background:#e8f0fe}
.c-num.match-hit{background:#fde8e8}
.c-ov{position:absolute;left:0;top:0;overflow:visible;pointer-events:none;z-index:3}
tr.hl td{background:#fff3c4}

.c-label{padding:2px 6px;font-size:11px;line-height:1.25;min-width:0;width:28%;text-align:left;white-space:nowrap;overflow:hidden}
.c-label .c-per,.c-label .c-dt{display:block;font-variant-numeric:tabular-nums}
.review-bar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:6px 0}
.review-bar[hidden]{display:none !important}
.review-badge{display:inline-block;padding:4px 10px;border-radius:4px;font-weight:700;font-size:14px}
.review-badge.hit{background:#eaf7ed;color:#075627}
.review-badge.miss{background:#fde8e8;color:#9b1c1c}
.review-head{font-size:14px}
tr.win td{background:#f7f7f7}
.c-compact th:first-child{min-width:0;width:28%;padding:0 4px}

tr.pred td,tr.pred .c-pred-wrap{background:#fcfbf6;border:1px solid #2a2a2a}
.c-pred-wrap{padding:4px 4px 6px;position:relative}
.pred-head{font-size:12px;font-weight:700;letter-spacing:.4px;padding:0 2px 4px;color:#333}
.pred-segs{display:flex;flex-direction:column;gap:0;width:100%;min-width:0}
.pred-seg{display:flex;align-items:center;gap:4px;padding:2px 0;border-top:1px solid #e4dfd2}
.pred-seg:first-child{border-top:0}
.pred-seg.on{background:#f3ead2}
.pred-seg-lab{flex:0 0 auto;min-width:52px;width:52px;min-height:36px;padding:4px 4px;font-size:12px;font-weight:700;line-height:1.1;border:1px solid #b8b09a;background:#f0ebe0;border-radius:4px;color:#222;touch-action:none;user-select:none}
.pred-seg.on .pred-seg-lab{background:#e6d7a8;border-color:#8a7a40}
.pred-seg-nums{flex:1 1 auto;display:grid;grid-template-columns:repeat(13,minmax(0,1fr));min-width:0;touch-action:none}
.pred-seg-nums .c-num{display:block;height:32px;line-height:32px;font-size:15px;border:1px solid #d0cbbd;background:#fcfbf6;touch-action:none}
.pred-seg.on .pred-seg-nums .c-num{background:#f7f0da}
.pred-seg-nums .c-num.match-hit{background:#fde8e8}
.pred-bubble{position:absolute;z-index:6;transform:translate(-50%,calc(-100% - 6px));background:#222;color:#fff;font-weight:700;font-size:18px;line-height:1;padding:6px 9px;border-radius:8px;pointer-events:none;box-shadow:0 1px 4px rgba(0,0,0,.25)}
.pred-bubble[hidden]{display:none !important}
.pred-bubble::after{content:"";position:absolute;left:50%;bottom:-5px;margin-left:-5px;border:5px solid transparent;border-top-color:#222;border-bottom-width:0}

#results{display:grid;grid-template-columns:repeat(4,minmax(200px,1fr));gap:8px;overflow-x:auto;margin-top:8px}
.result{border:1px solid #aaa;padding:8px;background:#fff}
.result.active{border:2px solid #214f83;padding:7px}
.matches{height:180px;overflow:auto;margin-top:8px}
.matches button{display:block;width:100%;text-align:left;border:0;border-bottom:1px solid #ddd;background:#fff;font-size:13px;min-height:40px;border-radius:0}
.matches button.hit{color:#075627;background:#eaf7ed}
@media (max-width:640px){
  body{padding:6px 6px 20px}
  h1{font-size:16px}
  .classic-board-wrap{padding:6px}
  .c-num{height:34px;line-height:34px;font-size:18px}
  .pred-seg-lab{min-width:48px;width:48px;min-height:34px;font-size:11px}
  .pred-seg-nums .c-num{height:32px;line-height:32px;font-size:14px}
  #results{grid-template-columns:1fr}
}
@media print{
  .top,#results,#timing{display:none !important}
  body,.classic-board-wrap{background:#fff}
  .classic-board-wrap{border:0;padding:0;overflow:visible}
}
