:root{font-family:system-ui,-apple-system,"Segoe UI","Microsoft YaHei",sans-serif;color:#362c2a;background:#f5efe6;font-synthesis:none;--blue:#2865ba;--purple:#8750b3;--gold:#ffd65a;--red:#a52c36}
*{box-sizing:border-box}body{margin:0}button{font:inherit;border:0;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;min-height:46px}button:disabled{cursor:default;opacity:.4}button:focus-visible{outline:3px solid #df9e20;outline-offset:3px}button:active:not(:disabled){transform:translateY(2px)}[hidden]{display:none!important}
.game{max-width:480px;margin:auto;padding:20px 16px max(16px,env(safe-area-inset-bottom));min-height:100dvh}.masthead{display:flex;align-items:center;justify-content:space-between;margin-bottom:20px}.eyebrow{font-size:11px;letter-spacing:2.4px;font-weight:800;color:#9a7665;margin:0 0 4px}h1{font-size:28px;letter-spacing:-1px;margin:0;font-weight:900}h1 span{color:var(--red)}.icon-button{border:1px solid #dcccbc;border-radius:50%;background:transparent;width:44px;font-weight:700;color:#8b6656;font-size:20px}
.players{display:grid;grid-template-columns:1fr 1fr;gap:10px}.player{border:1px solid #e6dbcf;background:#fffaf3;border-radius:14px;padding:12px 10px;display:flex;gap:8px;align-items:center;position:relative;transition:border-color .2s,box-shadow .2s}.player.active{border-color:currentColor;box-shadow:0 0 0 1px currentColor}.blue{color:var(--blue)}.purple{color:var(--purple)}.avatar{display:grid;place-items:center;font-style:normal;border-radius:50%;background:currentColor;width:30px;height:30px;flex-shrink:0;font-size:0}.avatar:after{content:"●";color:#fff;font-size:16px}.player strong{font-size:14px;display:block;white-space:nowrap}.player small{font-size:11px;font-weight:500}.player span{display:block;font-size:12px;color:#786f68;margin-top:3px}.count{color:#4c413a}.crowns{display:none}
.turnbar{display:flex;align-items:center;justify-content:space-between;gap:8px;margin:18px 0 10px}.turnbar strong{font-size:14px}.turnbar span{font-size:11px;color:#897b70;white-space:nowrap}.board{height:clamp(294px,90vw,410px);padding:14px 12px 10px;background:radial-gradient(ellipse at 50% 10%,#c7514c 0,transparent 60%),linear-gradient(150deg,#ad343e,#86232d);border:1px solid #8f2530;border-radius:20px;box-shadow:inset 0 1px #ffffff40,inset 0 -5px #5c142432,0 10px 22px #6b22231c;color:#ffedc9;display:flex;flex-direction:column;overflow:hidden}
.board-top{display:flex;justify-content:space-between;align-items:center;font-size:10px;color:#f8d9b0;letter-spacing:1px;height:24px;flex-shrink:0;padding:0 3px}.board-top>span:first-child{font-weight:800}.board-top em{font-family:Georgia,serif;font-weight:normal;font-size:12px}.board-top>span:last-child{letter-spacing:0;font-size:10px}.columns{display:grid;grid-template-columns:repeat(11,minmax(0,1fr));gap:5px;min-height:0;flex:1}.track{display:flex;flex-direction:column;min-width:0}.spaces{display:flex;flex-direction:column-reverse;gap:3px;flex:1;position:relative;min-height:0}.space{height:calc((100% - 36px)/13);flex-shrink:0;position:relative;background:linear-gradient(#fff3d3,#ead6ae);border-radius:3px;box-shadow:0 1px 0 #4617244d,inset 0 1px #fff9;transition:background .25s}.space.summit{background:linear-gradient(#ffe9af,#eac47b)}.track-number{height:22px;display:grid;place-items:center;flex-shrink:0;font-size:13px;font-weight:800;color:#fff1da}.claimed .space{opacity:.55}.claimed.owner0 .space{background:#adc5e8}.claimed.owner1 .space{background:#d7b9e8}.claimed .track-number{color:#ffe19b}.claim-badge{position:absolute;bottom:calc((var(--length) * (100% + 3px) / 13) + 1px);width:100%;font-size:10px;text-align:center;white-space:nowrap;color:#ffe79c;line-height:14px}
.piece{position:absolute;width:8px;height:8px;bottom:0;border-radius:50%;z-index:2;box-shadow:0 1px 2px #0005,0 0 0 1px #fff;pointer-events:none;transition:bottom .28s ease,opacity .2s;opacity:0}.piece.p0{background:var(--blue);left:12%}.piece.p1{background:var(--purple);right:12%}.piece.temp{border-radius:2px;background:var(--gold);width:9px;height:9px;left:calc(50% - 4.5px);transform:translateY(-3px) rotate(45deg);box-shadow:0 0 0 1.5px #7b4c16,0 2px 4px #0006;z-index:3}.piece.visible{opacity:1}.legend{display:flex;justify-content:center;align-items:center;gap:5px;font-size:10px;color:#8c7e72;margin:12px 0 14px}.legend>span{display:inline-block;width:6px;height:6px;border-radius:50%;margin-left:8px}.blue-dot{background:var(--blue)}.purple-dot{background:var(--purple)}.gold-dot{background:#e4b636;transform:rotate(45deg);border-radius:0!important}
.play-panel{background:#fffaf3;border:1px solid #e6dbcf;border-radius:18px;padding:16px 14px 10px;box-shadow:0 4px 12px #5f3e2710}.dice-row{display:flex;justify-content:center;gap:12px;margin-bottom:15px}.die{width:48px;height:48px;display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);gap:3px;padding:9px;background:linear-gradient(145deg,#fff,#f7eee1);border:1px solid #e6d4c0;border-radius:11px;box-shadow:0 3px 0 #ddc6ab,0 5px 8px #60331616}.pip{border-radius:50%;background:#493731;visibility:hidden}.pip.on{visibility:visible}.die.unknown:after{content:"?";grid-area:1/1/4/4;align-self:center;justify-self:center;color:#b9a18c;font-weight:700;font-size:22px}.rolling .die{animation:roll .36s ease-in-out infinite alternate}.rolling .die:nth-child(even){animation-delay:.1s}@keyframes roll{from{transform:translateY(0) rotate(-7deg)}to{transform:translateY(-4px) rotate(7deg)}}
.prompt{display:flex;justify-content:space-between;align-items:center;gap:8px;margin-bottom:12px}.prompt strong{font-size:14px}.prompt span{font-size:11px;color:#948172}.choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}.choice{background:#f6ead9;border:1px solid #e2c8a6;border-radius:10px;color:#774e35;min-height:50px;font-size:16px;font-weight:800;padding:6px 0}.choice small{display:block;font-size:10px;font-weight:500;margin-top:2px;color:#93745b}.choices:not(:empty){margin-bottom:10px}.controls{display:flex;gap:8px}.controls button{flex:1}.primary{color:#fff7e8;background:linear-gradient(#b43e46,#9b2b36);border-radius:12px;min-height:50px;padding:10px 16px;font-weight:750;box-shadow:0 3px 0 #76202b;letter-spacing:.5px}.save{color:#6e4d2b;background:#f1dfbd;border:1px solid #dfc79e;border-radius:12px;font-weight:700}.event{color:#8b7766;font-size:12px;line-height:1.5;text-align:center;min-height:18px;margin:12px 0 0}.event.error{color:#ac303b}footer{display:flex;justify-content:space-between;align-items:center;font-size:10px;color:#aa9887;padding-top:8px}footer button{background:none;color:#8d7765;font-size:11px;padding:0 2px;min-height:36px}
dialog{border:1px solid #e1d0bb;border-radius:24px;background:#fffaf2;color:#3e3029;width:calc(100% - 32px);max-width:390px;padding:30px 24px;text-align:center;box-shadow:0 24px 80px #3a132c40;max-height:90dvh;overflow:auto}dialog::backdrop{background:#301e27a8;backdrop-filter:blur(5px)}dialog h2{font-size:28px;margin:10px 0 14px}dialog p{font-size:14px;line-height:1.8;color:#8b7161}dialog .primary{width:100%;margin-top:14px}.entry-dice{font-size:68px;line-height:1.3;color:var(--red);transform:rotate(-12deg);margin-bottom:18px}.fine{font-size:11px!important;margin:20px 0 0}.dialog-close{position:absolute;right:12px;top:8px;background:none;color:#947c6a;font-size:26px;width:40px}.rules{text-align:left;padding-left:22px;font-size:14px;line-height:1.8;color:#89705d}.rules li{padding-left:3px;margin:14px 0}.rules strong{display:block;color:#4b362a}.result-symbol{font-size:58px;color:#d6a033;margin-top:14px}.final-score{padding:12px;border-block:1px solid #ebdcc7;color:#6c4d35;line-height:2}.text-button{background:transparent;color:#967152;width:100%;margin-top:10px}
@media(min-width:600px){body{background:radial-gradient(ellipse at 20% 20%,#eedcc7,transparent 70%),#f5efe6}.game{margin:24px auto;background:#f9f3e9;border:1px solid #e5d5c2;border-radius:28px;padding:24px;box-shadow:0 24px 70px #61402815;min-height:0}.crowns{display:block;font-size:12px;position:absolute;right:9px;top:12px}.board{height:390px}.masthead{margin-bottom:20px}}
@media(max-width:359px){.game{padding:14px 10px}.masthead{margin-bottom:14px}h1{font-size:25px}.player{padding:10px 7px;gap:5px}.player strong{font-size:12px}.avatar{width:25px;height:25px}.columns{gap:4px}.board{padding-inline:9px}.prompt span{font-size:10px}.turnbar span{font-size:10px}.dice-row{gap:10px}.legend{gap:4px}.piece.p0{left:5%}.piece.p1{right:5%}}
@media(prefers-reduced-motion:reduce){*,*:before,*:after{animation:none!important;transition:none!important}}

/* Preview layers never reposition the authoritative pieces. */
.preview-track .track-number{color:#d5fff1;background:#155d58;border-radius:4px;text-shadow:none}
.preview-track .spaces{background:linear-gradient(0deg,#3cd3b92e,transparent);border-radius:5px}
.preview-track .space{box-shadow:0 0 0 1px #93e9d477,inset 0 1px #fff9}
.preview-track .preview-target{background:#b9f0dc;outline:2px solid #37bda6;outline-offset:0;box-shadow:0 0 11px 3px #49dec299,inset 0 0 0 1px #f3fff8;z-index:1}
.preview-piece{position:absolute;width:11px;height:11px;left:calc(50% - 5.5px);transform:translateY(-2px) rotate(45deg);background:#146e63b8;border:1.5px dashed #effff8;border-radius:2px;z-index:4;opacity:0;pointer-events:none;box-shadow:0 0 7px #4de1c4aa}
.preview-piece:after{content:attr(data-steps);position:absolute;left:-7px;top:-16px;transform:rotate(-45deg);font-size:10px;font-weight:800;line-height:15px;min-width:19px;text-align:center;background:#154f4b;color:#e5fff6;border:1px solid #8fe6d0;border-radius:4px;box-shadow:0 1px 3px #42172255}
.preview-piece.visible{opacity:1}
.piece.preview-source{outline:2px solid #a9f5de;outline-offset:2px}
.choice.preview-choice,.choice.selected-choice{border-color:#286e62;box-shadow:inset 0 0 0 1px #398b78,0 2px 5px #174f4518;background:#d9eddf;color:#154f46}
.choice.selected-choice small{color:#326457}
.choice.selected-choice{position:relative}
.choice.selected-choice:after{content:"已选";position:absolute;right:3px;top:-8px;font-size:9px;line-height:15px;padding:0 4px;border-radius:3px;background:#24685b;color:#f2fff8}
.preview-status{color:#225d51;background:#e3f0e8;border:1px solid #b3d7c9;border-radius:8px;padding:8px;font-size:12px;line-height:1.7;text-align:center;margin:0 0 10px;overflow-wrap:anywhere}
#confirm-choice{background:linear-gradient(#2b7c6b,#195e52);box-shadow:0 3px 0 #103e38;color:#f3fff5;min-height:52px}
#confirm-choice:before{content:"◇";margin-right:7px;color:#a9f0d8}

/* Bone-white faces, fine paper flecks and recessed ink pips; entirely local CSS. */
.die{
  --rest-tilt:-2deg;
  position:relative;isolation:isolate;transform:rotate(var(--rest-tilt));
  background:radial-gradient(ellipse at 22% 12%,#fff9e7,transparent 65%),linear-gradient(135deg,#e7d9b9,#f3e8cc 46%,#d5c39f);
  border:1px solid #b9a586;border-radius:9px 7px 10px 7px;
  box-shadow:inset 0 1px 1px #ffffe8,inset -2px -3px 4px #80674423,0 3px 0 #ad9471,0 5px 8px #50382929;
}
.die:before{
  content:"";position:absolute;inset:1px;border-radius:inherit;pointer-events:none;z-index:0;
  background-image:radial-gradient(#674b3233 .55px,transparent .8px),radial-gradient(#fff9df99 .6px,transparent .9px),repeating-linear-gradient(103deg,transparent 0 9px,#8e775510 10px,transparent 11px 19px);
  background-size:5px 7px,8px 6px,100% 100%;background-position:1px 2px,3px 0,0 0;opacity:.52;
}
.die:nth-child(2){--rest-tilt:1.5deg}
.die:nth-child(3){--rest-tilt:-1deg}
.die:nth-child(4){--rest-tilt:2deg}
.pip{position:relative;z-index:1;background:#3c3028;box-shadow:inset 0 1px 1px #140f0dcc,0 1px 0 #fff4d799;border-radius:46% 52% 47% 50%}
.die.unknown:after{position:relative;z-index:1;color:#90795a;font-family:Georgia,serif}
.rolling .die{animation:dice-tumble .44s cubic-bezier(.2,.65,.4,1) both;animation-delay:75ms}
.rolling .die:nth-child(2){animation-delay:100ms}
.rolling .die:nth-child(3){animation-delay:125ms}
.rolling .die:nth-child(4){animation-delay:150ms}
.rolling .pip{opacity:.5}
.waiting-result .die{opacity:.78}
.settled .die{animation:dice-land .13s ease-out both}
.connection-result .result-symbol{color:#8b6a57;font-size:44px}
.connection-result #result-title{color:#8f433e}
.header-actions{display:flex;align-items:center;gap:8px}
.sound-toggle{background:transparent;border:1px solid #dcccbc;border-radius:9px;padding:0 9px;min-height:44px;font-size:12px;color:#695143;white-space:nowrap}
.sound-toggle[aria-pressed="false"]{color:#927e6d;background:#eee3d6}
@keyframes dice-tumble{
  0%{transform:translateY(0) rotate(var(--rest-tilt)) scale(1)}
  22%{transform:translateY(-9px) rotate(-17deg) scale(.94)}
  48%{transform:translateY(-3px) rotate(13deg) scale(1.03)}
  72%{transform:translateY(-5px) rotate(-7deg) scale(.98)}
  100%{transform:translateY(0) rotate(var(--rest-tilt)) scale(1)}
}
@keyframes dice-land{
  0%{transform:translateY(1px) rotate(var(--rest-tilt)) scale(1.035)}
  100%{transform:translateY(0) rotate(var(--rest-tilt)) scale(1)}
}

.waiting-panel { margin: 10px 0; padding: 14px; border: 1px solid #b89b58; border-radius: 16px; background: #fff1cc; }
.waiting-panel button { min-height:44px; margin:4px; }
.waiting-panel[hidden] { display:none; }
.room-strip { display:flex; align-items:center; justify-content:space-between; gap:8px; margin:0 0 10px; font-size:12px; color:#705e4b; }
.room-strip button { padding:8px 10px; border:1px solid #cbbda5; border-radius:10px; background:#fff8e9; color:#5f493c; }
.room-input { display:block; margin:16px 0 8px; font-size:13px; }
#room-code { display:block; width:100%; min-width:0; min-height:44px; box-sizing:border-box; padding:10px; border:1px solid #cbbda5; border-radius:10px; text-align:center; text-transform:uppercase; letter-spacing:3px; font-size:18px; margin-bottom:10px; background:#fffaf0; }
#entry button { min-height:44px; }
#entry #create-room { margin-bottom:8px; }
.pairing-toast { position:fixed; inset:0; z-index:20; display:grid; place-items:center; padding:20px; background:#35111e55; pointer-events:none; }
.pairing-toast[hidden] { display:none; }
.pairing-card { box-sizing:border-box; width:min(100%,310px); padding:26px 20px; text-align:center; border:2px solid #d6b66d; border-radius:24px; background:#722332; color:#fff5df; box-shadow:0 12px 44px #38141c66; }
.pairing-card span { color:#edcf85; font-size:32px; }
.pairing-card h2 { margin:8px 0; font-size:27px; }
.pairing-card p { color:#efdec3; margin:8px 0 16px; }
.pairing-card strong { color:#f4d78f; font-size:20px; }
#invite-notice { padding:10px; border:1px solid #cbbda5; border-radius:10px; overflow-wrap:anywhere; }
.rules-button { min-height:44px; border:1px solid #d5c0a7; border-radius:12px; background:#fff7e7; color:#744b3d; padding:8px; white-space:nowrap; font-size:12px; }
#nickname { display:block; width:100%; box-sizing:border-box; min-height:44px; background:#fffaf0; border:1px solid #cbbda5; border-radius:10px; padding:10px; font:inherit; }
.player > div { min-width:0; }
.player strong { white-space:normal; overflow-wrap:anywhere; }
.player .nickname { display:inline; margin:0; color:inherit; font-size:inherit; }
.players .crowns { display:none; }
.choices-title { font-size:13px; color:#725747; margin:8px 0; font-weight:600; }
.rules-copy { text-align:left; overflow-wrap:anywhere; }
.rules-copy h3 { margin:24px 0 10px; color:#792d37; }
.rules-copy h4 { margin:18px 0 6px; }
.rules-copy p { color:#695344; }
.secondary-entry { margin-top:14px; font-size:12px; color:#886652; }
.claim-toast { position:fixed; inset:0; z-index:21; display:grid; place-items:center; padding:20px; pointer-events:none; }
.claim-toast[hidden] { display:none; }
.claim-card { width:min(100%,320px); padding:20px; box-sizing:border-box; background:#742c35f5; border:2px solid #d4b471; border-radius:22px; text-align:center; color:#fff6e6; box-shadow:0 12px 45px #461d3555; }
.claim-card h2 { font-size:22px; margin:8px 0; }.claim-card p { overflow-wrap:anywhere; line-height:1.6; }.claim-card strong { color:#f5d78b; font-size:13px; }
.claim-card > span { display:inline-grid; width:36px; height:36px; place-items:center; border-radius:50%; background:var(--blue); color:#fff; }.claim-toast.owner1 .claim-card > span { background:var(--purple); }
.claim-flash .spaces { box-shadow:0 0 15px #ffdf7dc9; border-radius:8px; animation:claim-glow 1.3s ease-out; }
@keyframes claim-glow { from { filter:brightness(1.8); } to { filter:brightness(1); } }
.score-row { border-radius:10px; padding:6px; margin:5px 0; background:#f0e9dc; overflow-wrap:anywhere; }
#result-dialog { isolation:isolate; }.victory-sparks { position:absolute; top:140px; left:50%; pointer-events:none; z-index:-1; }
.victory-sparks i { position:absolute; width:6px; height:9px; border-radius:2px; background:#d9ac4e; opacity:0; }
.victory-enter .victory-sparks i { animation:spark-flight 2.4s ease-out both; }
.victory-enter .result-symbol { animation:trophy-rise 2.5s ease-out both; }
@keyframes spark-flight { 0% { opacity:0; transform:rotate(calc(var(--i)*30deg)) translateY(-15px); } 20% { opacity:.85; } 100% { opacity:0; transform:rotate(calc(var(--i)*30deg + 35deg)) translateY(-130px); } }
@keyframes trophy-rise { 0% { transform:translateY(12px) scale(.8); text-shadow:0 0 0 #edc66700; } 35% { transform:translateY(0) scale(1.08); text-shadow:0 0 30px #edc667aa; } 100% { transform:none; text-shadow:0 0 12px #edc66755; } }
@media(prefers-reduced-motion:reduce) { .claim-flash .spaces,.victory-enter .result-symbol,.victory-enter .victory-sparks i { animation:none; } }
.piece.p0,.piece.p1 { height:3px; width:72%; border-radius:2px; left:14%; right:auto; z-index:2; box-shadow:0 0 0 1px #fff8; transform:none; }
.piece.p0.shared { width:36%; left:14%; border-radius:2px 0 0 2px; }
.piece.p1.shared { width:36%; left:50%; border-radius:0 2px 2px 0; }
.piece.temp { border-radius:50%; transform:none; background:radial-gradient(circle at 30% 25%,#fff2b7,#e5b43c 50%,#a86f18); }
.legend { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
.legend > .legend-item { width:auto; height:auto; border-radius:0; margin:0; display:flex; align-items:center; gap:6px; }
.legend i { display:inline-block; width:16px; flex-shrink:0; }
.saved-blue,.saved-purple { height:3px; border-radius:2px; background:var(--blue); }.saved-purple { background:var(--purple); }
.temporary-key { height:10px; width:10px!important; border-radius:50%; background:#e5b43c; }.preview-key { height:10px; width:10px!important; border:2px solid #3cbfae; border-radius:50%; }
button:focus-visible { outline:3px solid #40bfb2; outline-offset:3px; }
button:not(:disabled):hover { filter:brightness(1.07); }button:not(:disabled):active { filter:brightness(.93); }
button:disabled { cursor:not-allowed; opacity:.45; }
#join,#copy-invite,.rules-button,#return,#stop { border:1px solid #b09a75; border-radius:11px; background:#f4e5c5; color:#654532; min-height:44px; }
#leave,#end-match { background:transparent; color:#9b3541; border:1px solid #b7747c; border-radius:10px; padding:8px 12px; min-height:44px; }
.piece.p0,.piece.p1 { height:4px; width:84%; left:8%; box-shadow:0 0 0 1px #fff9,0 1px 2px #27142670; }
.piece.p0.shared { width:42%; left:8%; }.piece.p1.shared { width:42%; left:50%; }
.turnbar { gap:8px; flex-wrap:wrap; }.turnbar strong,.turnbar span { overflow-wrap:anywhere; }
.waiting-panel strong { color:#783c31; }.waiting-panel p,#away-countdown { font-variant-numeric:tabular-nums; }
#away-dialog p { overflow-wrap:anywhere; }#end-away { color:#9b3541; border:1px solid #b7747c; border-radius:10px; padding:9px; }
#desktop-options[hidden],#create-room[hidden] { display:none; }
