:root{
  color-scheme: dark;
  --bg:#141A36;
  --bg2:#1B2348;
  --panel:#FFF8EC;
  --ink:#F3EEE0;
  --muted:#A9AFCE;
  --line:#E6DAC0;
  --frame:#0E1430;
  --btn:#262E59;
  --btn-ink:#F3EEE0;
  --primary:#F4B82E;
  --primary-ink:#271D06;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
html{scroll-padding-top:env(safe-area-inset-top,0px)}
*,*::before,*::after{box-sizing:border-box}
[hidden]{display:none !important}
body{
  margin:0; color:var(--ink);
  background:
    radial-gradient(520px 420px at -5% -8%, rgba(229,72,61,.5), transparent 62%),
    radial-gradient(520px 420px at 105% -8%, rgba(46,166,92,.45), transparent 62%),
    radial-gradient(460px 360px at 105% 60%, rgba(244,184,46,.16), transparent 60%),
    radial-gradient(460px 360px at -5% 70%, rgba(47,115,217,.22), transparent 60%),
    linear-gradient(180deg, var(--bg), var(--bg2));
  background-attachment:fixed;
  font-family:'Baloo 2','Trebuchet MS',system-ui,sans-serif; font-weight:500; font-size:17px; line-height:1.4;
  -webkit-tap-highlight-color:transparent;
}
.app{max-width:1400px; margin:0 auto; padding:14px 16px 28px}
/* the page backdrop is the hero art itself (blurred, set from script.js), so
   nothing of any other colour ever shows around or behind the picture */
:root{--hero-bg:url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA4KCw0LCQ4NDA0QDw4RFiQXFhQUFiwgIRokNC43NjMuMjI6QVNGOj1OPjIySGJJTlZYXV5dOEVmbWVabFNbXVn/2wBDAQ8QEBYTFioXFypZOzI7WVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVn/wAARCAAwAFQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBka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oulSVRPqvxt/mKU44qteUenfs/kQnSY5SI2mlQuipzCo4HQfpXlF1EYbuaIjlHZfyNevrKrLbMXjJfcCcnOR0x6V5h4kh8jXrpezNvH4issDW5puL7f5f5lVKEaavH+tzRsbjT3j/0yYuC25AEbK569Meg4o+12TNulglZu7CQpk+vQ4oSRTbzM7XKyk7UCdAB6D6VIrxR3kapcyGB0JJmYgA47Ec16dOpNTtbf9B/VlJXTvYS41OzuJQ88csmPWc5HOfSsO+ZZGUI24DP4ZPSupLW67s3dseBjNw/vntWFqBNxPyQ20sqsDkMM8c960qSko67E+wUdUZHlUV0tppML26NNII2bnB9KK8t4yKdjdYd2Me3nNhmRVSUSLgjcQVIOe3Srn/CT3XOVc5OTmduTWCHPrSbq7nZvQ5Eu50lt4suLYyMtpBI0hDMZvnJI9zVg+Ob75cW1uu0YG0Yx+VcnuozUTpwqK09fmXGTjsdV/wm99gD7PDgdOTxWHqmoyaneNcyoqMVC4X2qjmjNRToUqcuaK1HKpKSsywtxKAB5smB0+Y8U4XMvA81/b5jVXNLurf3exGvctiaVjzK5/4Ea1NMNt56veOzKOwbJP51gq5FO849gBWVWPOrLQuEmndnQ32rBrlvLRQg4UegornGkJOc0VzrDQSsautI/9k=")}
@media (max-width:720px), (min-width:721px) and (max-width:1100px) and (orientation:portrait), (max-width:840px) and (max-height:520px), (orientation:landscape) and (max-height:520px) and (pointer:coarse){ :root{--hero-bg:url("data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAA4KCw0LCQ4NDA0QDw4RFiQXFhQUFiwgIRokNC43NjMuMjI6QVNGOj1OPjIySGJJTlZYXV5dOEVmbWVabFNbXVn/2wBDAQ8QEBYTFioXFypZOzI7WVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVlZWVn/wAARCABUADADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwI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akvlxqYySFHTj1HFakTG1h02O4G0rAUYMSPauTE0oUqd4b3W7fkXTcq0lGb0120JYZ5IZIna4upom6bwuG4OcYPNeUavEIdUukAwBISPoea9KSXEdvu8jKucgN2/pXAeJk26s7Do6g1z4OrJz5ZPdf5HRVpRhD3SHRbVLmdxLNJEgAB2dT1P9P5VpJa2UmDDc3pUnA3bQfywayNKuY7aZmkx0BXIyM+/wCta95rkU1x5sVtZjpjf2/AEd69OKhze+jlmpuPuuw67V7C2kNvfXsUoIJQtjP6CnJDeXS/8fV5OY03OTMAM+i5BrNu9SNzC6yJa7m/iQHd+eadp93AsxFw6CJ1wSSQV/L6Y/GlUp05fCrG2Hur+0dy/JZSYMsct29upAZvOXPPoMdqytZt0gmQxzyTIwIBc5Ix/wDrrWlvNMS2kEUsMjnOFzIPp144/WufuZA4RQ4cjOSOlPkpK7j309DSo04uxARikq1PA0ZwwI781VYYrScXFnJGSkgBozTc0dazuVYf1qSOPdTY1yRWrZ2jSH5BmsK1VRRpCF2GpII5nRegY9frWTIME0UV6OI+I4sP8KITQOtFFcbOst24BIrrvDdvHczrHIPl68daKK8rHu0GdVDc/9k=")} }
body::before{
  content:""; position:fixed; inset:0; z-index:-1; pointer-events:none;
  background:var(--hero-bg) center/cover no-repeat;
  filter:blur(70px) brightness(.8) saturate(1.1); transform:scale(1.25);
}
.herohome{
  position:relative; margin:2px auto 14px; border-radius:0; overflow:hidden;
  aspect-ratio:1344/768;
  -webkit-mask-image:linear-gradient(to right,transparent,#000 6%,#000 94%,transparent),linear-gradient(to bottom,transparent,#000 8%,#000 90%,transparent);
  -webkit-mask-composite:source-in;
  mask-image:linear-gradient(to right,transparent,#000 6%,#000 94%,transparent),linear-gradient(to bottom,transparent,#000 8%,#000 90%,transparent);
  mask-composite:intersect;
}
@media (max-width:720px){
  /* full-bleed: the hero image stretches edge-to-edge on phone screens
     (cancelling .app's own left/right padding). */
  .herowrap{position:relative}
  .herohome{
    aspect-ratio:768/1344; margin:0 -10px; border-radius:0; box-shadow:none; border:none;
    /* bottom edge dissolves into the page background, so phones taller or
       shorter than the image ratio never show a colour seam */
    -webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 7%,#000 84%,transparent 100%);
    mask-image:linear-gradient(to bottom,transparent 0,#000 7%,#000 84%,transparent 100%);
  }
}
@media (max-width:600px){
  .herohome{margin:0 -6px}
}
.herohome picture, .herohome img{display:block; width:100%; height:100%; object-fit:cover}
.hov{position:absolute; inset:0}
.hov-port{display:none}
@media (max-width:720px){
  .hov-land{display:none}
  .hov-port{display:block}
}
.hovbtn{
  position:absolute; background:transparent; border:0; margin:0; padding:0; cursor:pointer;
  border-radius:14px;
}
.hovbtn:focus-visible{outline:3px solid #fff; outline-offset:2px}
.herohome{container-type:inline-size}
.hovbtn-howto{
  background:linear-gradient(180deg,#46d36f,#17913f); border:2px solid #F4B82E; border-radius:999px;
  color:#fff; font-family:inherit; font-weight:800; letter-spacing:.05em; text-transform:uppercase;
  font-size:1.45cqw; line-height:1; text-shadow:0 2px 0 rgba(0,0,0,.35);
  box-shadow:0 4px 0 #0b5a26, 0 8px 14px rgba(0,0,0,.45), inset 0 2px 0 rgba(255,255,255,.35);
}
.hovbtn-howto:active{transform:translateY(2px)}
@media (max-width:720px){ .hovbtn-howto{font-size:3.6cqw} }
.top{position:relative; margin-bottom:12px; padding:2px 46px 0}
@media (max-width:720px){
  /* the title is absolutely positioned over the image's own top edge
     (not pulled up by a guessed pixel amount), so it stays correctly
     placed regardless of font load timing or rendered text height */
  .top{position:absolute; top:0; left:0; right:0; margin-bottom:0; z-index:3}
  h1, .tag{text-shadow:0 2px 6px rgba(0,0,0,.65), 0 1px 2px rgba(0,0,0,.5)}
  /* while playing there's no hero image for the title to float over (.herowrap
     would collapse to 0 height under an absolute-only child), so put the
     header back in normal flow, sitting right above the board like a title bar */
  body.ingame .top{position:relative; margin-bottom:12px}
  body.ingame h1, body.ingame .tag{text-shadow:none}
}
.brand{display:flex; flex-direction:column; align-items:center; text-align:center; gap:1px}
.brandtext{display:flex; flex-direction:column; align-items:center; gap:1px}
h1{margin:0; font-size:1.85rem; font-weight:800; letter-spacing:.01em; line-height:1}
.tag{color:var(--muted); font-size:.92rem}
.topbtns{position:absolute; top:0; right:0; display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end}
h2{margin:0 0 4px; font-size:1.5rem; font-weight:800}
.muted{color:var(--muted)}
button{font:inherit; color:inherit; cursor:pointer}
button:focus-visible{outline:3px solid var(--primary); outline-offset:2px}
.piece{outline:none}
.btn{
  white-space:nowrap;
  border:0; border-radius:12px; padding:9px 16px; background:var(--btn); color:var(--btn-ink); font-weight:700;
}
.btn:hover{filter:brightness(1.08)}
.btn.primary{background:var(--primary); color:var(--primary-ink); padding:12px 22px; font-size:1.1rem; box-shadow:0 3px 0 rgba(0,0,0,.2)}
.btn:disabled{opacity:.45; cursor:not-allowed}
.btn.iconbtn{
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; padding:0; font-size:1.2rem; line-height:1;
}
.iostip{
  position:fixed; z-index:60; max-width:220px; background:#1B2348; color:#F3EEE0;
  font-size:.82rem; font-weight:600; line-height:1.35; padding:10px 12px; border-radius:12px;
  border:1px solid rgba(244,184,46,.4); box-shadow:0 10px 24px rgba(6,9,25,.5);
}
.iostip-share{display:inline-block}
.btn.iconbtn.armed{background:var(--primary); color:var(--primary-ink); animation:armedPulse 1s ease-in-out infinite}
@keyframes armedPulse{0%,100%{transform:scale(1)}50%{transform:scale(1.1)}}

/* setup */
.card{
  --ink:#271F35; --muted:#746B58; --btn:#F1E7CF; --btn-ink:#271F35; --line:#E6DAC0;
  background:var(--panel); border:1px solid var(--line); border-radius:22px; padding:24px;
  max-width:640px; margin:18px auto; color:var(--ink);
  box-shadow:0 18px 40px rgba(6,9,25,.35);
}
.card h2{color:var(--ink)}
.presets{display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin:16px 0 8px}
.presettile{
  display:flex; flex-direction:column; align-items:center; gap:6px; padding:14px 6px 12px;
  background:var(--btn); border-radius:14px; font-weight:700; font-size:.82rem; line-height:1.15; white-space:normal;
}
.presettile .picon{font-size:1.5rem; line-height:1}
.presettile .dots4{display:grid; grid-template-columns:1fr 1fr; gap:3px; width:20px; height:20px}
.presettile .dots4 i{display:block; border-radius:3px}
.presettile .dots4 i:nth-child(1){background:#E5483D}
.presettile .dots4 i:nth-child(2){background:#2EA65C}
.presettile .dots4 i:nth-child(3){background:#2F73D9}
.presettile .dots4 i:nth-child(4){background:#F4B82E}
.avatarrow{flex-basis:100%; display:flex; flex-wrap:wrap; gap:6px; margin-top:2px}
.avbtn{width:36px; height:36px; border-radius:10px; border:2px solid transparent; background:var(--btn); font-size:19px; line-height:1; display:flex; align-items:center; justify-content:center; padding:0}
.avbtn[aria-pressed="true"]{border-color:var(--primary); background:var(--panel)}
.avbtn.none{font-size:12px; font-weight:700; color:var(--muted)}
.srow{display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; padding:10px 0; border-top:1px solid var(--line)}
.nameinput{flex:1 1 100%; min-width:0; font:inherit; color:var(--ink); background:var(--btn); border:2px solid transparent; border-radius:10px; padding:7px 12px}
.nameinput:focus{outline:none; border-color:var(--primary)}
.nameinput::placeholder{color:var(--muted)}
.tname,.pname{overflow-wrap:anywhere}
.srow:first-of-type{margin-top:10px}
.dot{width:22px; height:22px; border-radius:50%; flex:none; box-shadow:inset 0 -3px 0 rgba(0,0,0,.22); display:flex; align-items:center; justify-content:center; font-size:14px; line-height:1; overflow:hidden}
.dot.big{font-size:22px}
.ranklist .dot{font-size:11px}
.dot.big{width:34px; height:34px}
.sname{font-weight:700; min-width:64px}
.seg{margin-left:auto; display:inline-flex; background:var(--btn); border-radius:12px; padding:3px; gap:2px}
.seg button{border:0; background:transparent; padding:6px 13px; border-radius:9px; font-weight:700; color:var(--muted)}
.seg button[aria-pressed="true"]{background:var(--primary); color:var(--primary-ink)}
.err{color:#C23B32; min-height:1.4em; margin:8px 0 10px; font-weight:700}
.startrow{display:flex; justify-content:flex-end}
.cslink{margin-top:14px; text-align:center; color:var(--muted); font-size:.9rem}
.cslink a{color:#B2791A; font-weight:700; text-decoration:none}
.cslink a:hover{text-decoration:underline}

/* game */
.game{display:grid; grid-template-columns:minmax(0,min(820px,calc(100svh - 120px))) 330px; gap:22px; align-items:start; justify-content:center}
.boardwrap{width:100%; margin-inline:auto}
.sidecol{display:grid; gap:14px; align-content:start}
#board{width:100%; height:auto; display:block; touch-action:manipulation; user-select:none; -webkit-user-select:none}
#board .frame{fill:var(--frame)}
.panel{
  --turn:#888;
  background:linear-gradient(180deg, rgba(31,39,78,.96), rgba(19,24,50,.96));
  border:1px solid rgba(244,184,46,.35); border-radius:20px; padding:14px; display:grid; gap:10px;
  color:var(--ink); box-shadow:0 18px 40px rgba(6,9,25,.45), 0 0 0 1px rgba(244,184,46,.12);
}
.turnhead{display:flex; align-items:center; gap:12px}
.turnhead .dot{background:var(--turn)}
.tname{font-size:1.35rem; font-weight:800; line-height:1.1}
.dice3{cursor:default; transform-box:fill-box; transform-origin:center; outline:none}
.dice3.ready{cursor:pointer; animation:dnudge 1.5s ease-in-out infinite}
.dice3.rolling{animation:dshake .45s linear infinite}
.dface{fill:#FFFFFF; stroke-width:0.16}
.dfocus{fill:none; stroke:var(--primary); stroke-width:0.1; opacity:0}
.dpip{fill:transparent}
.dpip.on{fill:#1B2033}
.dice3.kbd-focus .dfocus{opacity:1}
@keyframes dnudge{0%,100%{transform:translateY(0)}50%{transform:translateY(-0.07px)}}
@keyframes dshake{0%{transform:rotate(-9deg)}50%{transform:rotate(9deg) translateY(-0.05px)}100%{transform:rotate(-9deg)}}
.msg{margin:0; min-height:.6em; font-weight:700}
.rulesList{text-align:left; margin:14px 0 0; padding-left:20px; color:var(--muted); font-size:.95rem; max-height:50vh; overflow:auto}
.rulesList li{margin:5px 0}

/* pieces */
.pieces.ready .piece{transition:transform .16s ease-out}
.piece .ring{opacity:0; transform-box:fill-box; transform-origin:center}
.piece.movable{cursor:pointer}
.piece.movable .ring{opacity:1; animation:ringPulse 1s ease-in-out infinite}
.piece.kbd-focus .ring{opacity:1}
@keyframes ringPulse{0%,100%{transform:scale(.94)}50%{transform:scale(1.16)}}
.yard-ring{opacity:0}
.yard-ring.on{opacity:1}

.overlay{position:fixed; inset:0; display:grid; place-items:center; background:rgba(10,14,25,.62); padding:20px; z-index:10}
.win{
  --ink:#271F35; --muted:#746B58; --btn:#F1E7CF; --btn-ink:#271F35; --line:#E6DAC0;
  background:var(--panel); border-radius:22px; padding:28px; text-align:center; max-width:380px; width:100%;
  border:1px solid var(--line); color:var(--ink); box-shadow:0 18px 40px rgba(6,9,25,.35);
}
.win > .dot{width:56px; height:56px; margin:0 auto 10px}
.ranklist{list-style:none; margin:16px 0 0; padding:0; display:grid; gap:6px; text-align:left}
.ranklist li{display:flex; align-items:center; gap:10px; padding:7px 12px; border-radius:10px; background:var(--btn)}
.ranklist .rk{font-weight:800; min-width:2.4em}
.ranklist .dot{width:16px; height:16px}
.win h2{font-size:1.9rem}
.win .row{display:flex; gap:10px; justify-content:center; flex-wrap:wrap; margin-top:18px}

/* ---------- navy+gold ornate frame (profile / stats / daily modals) ---------- */
.win.framed{
  position:relative;
  --ink:#F3EEE0; --muted:#A9A3C9; --btn:#232a52; --btn-ink:#F3EEE0; --line:rgba(244,184,46,.35);
  background:#141A36; border-radius:16px;
  border:2px solid #F4B82E;
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.4), 0 18px 40px rgba(6,9,25,.5), 0 0 26px rgba(244,184,46,.18);
}
.win.framed .frame-corner{
  position:absolute; width:54px; height:54px; pointer-events:none;
  background-image:url('img/profile-corner.png'); background-size:cover; background-repeat:no-repeat; z-index:1;
}
.win.framed .frame-corner.tl{top:-2px; left:-2px}
.win.framed .frame-corner.tr{top:-2px; right:-2px; transform:scaleX(-1)}
.win.framed .frame-corner.bl{bottom:-2px; left:-2px; transform:scaleY(-1)}
.win.framed .frame-corner.br{bottom:-2px; right:-2px; transform:scale(-1,-1)}
.win.framed .avatarrow button{border-color:rgba(244,184,46,.22)}
.win.framed .avatarrow button.sel{border-color:#F4B82E; background:rgba(244,184,46,.25)}
.win.framed .btn.primary{
  background:url('img/btn-gold.png') center/100% 100% no-repeat; color:#2A1800;
  border:0; box-shadow:none; min-width:108px; min-height:46px;
}
.win.framed .btn.primary:hover{filter:brightness(1.06)}
.win.framed .btn:not(.primary){
  background:url('img/btn-navy.png') center/100% 100% no-repeat; color:#F3EEE0;
  border:0; box-shadow:none; min-width:108px; min-height:46px;
}
.win.framed .btn:not(.primary):hover{filter:brightness(1.1)}
.win.framed .statbox{
  background:linear-gradient(180deg,#2c3669,#1b2347); border:1.5px solid rgba(244,184,46,.3);
  border-radius:16px; padding:12px 4px 10px;
  box-shadow:0 3px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.06);
}
.win.framed .staticon{display:block; font-size:1.3rem; margin-bottom:3px}
.win.framed .statbox-win{border-color:rgba(46,166,92,.5)}
.win.framed .statbox-win .statnum{color:#7CE8A8}
.win.framed .statbox-loss{border-color:rgba(229,72,61,.45)}
.win.framed .statbox-loss .statnum{color:#F4968B}
.win.framed .muted{color:var(--muted)}
.friendspick{position:relative; width:100%; max-width:360px; aspect-ratio:798/932; border-radius:22px; overflow:hidden; box-shadow:0 18px 40px rgba(6,9,25,.45)}
.friendspick-img{display:block; width:100%; height:100%; object-fit:cover; -webkit-user-drag:none; user-select:none}
.friendspick-btn{position:absolute; background:transparent; border:0; margin:0; padding:0; cursor:pointer; border-radius:14px}
.friendspick-btn:hover{background:rgba(255,255,255,.08)}
.friendspick-btn:focus-visible{outline:3px solid #fff; outline-offset:2px}
.friendsnamescard{position:relative; width:100%; max-width:360px; border-radius:22px; overflow:hidden; box-shadow:0 18px 40px rgba(6,9,25,.45)}
.friendsnamescard.fn1{aspect-ratio:1024/737}
.friendsnamescard.fn2{aspect-ratio:1024/891}
.friendsnamescard.fn3{aspect-ratio:1024/1024}
.friendsnames-img{display:block; width:100%; height:100%; object-fit:cover; -webkit-user-drag:none; user-select:none}
.fnameinput{
  position:absolute; background:transparent; border:0; outline:0; margin:0;
  font-family:'Baloo 2','Trebuchet MS',system-ui,sans-serif; font-weight:700;
  font-size:clamp(13px,4vw,18px); color:#271F35; padding:0 4%;
}
.fnameinput::placeholder{color:#B8AE92}
.fnameinput:focus{background:rgba(244,184,46,.14); border-radius:999px}

@media (max-width:1200px){
  .app{padding:10px 10px 24px}
}
@media (max-width:480px){
  .presets{grid-template-columns:1fr 1fr}
}
@media (max-width:600px){
  .app{padding:8px 6px 20px}
  .top{padding:2px 40px 0; margin-bottom:6px}
  h1{font-size:1.15rem}
  .tag{font-size:.72rem}
  .topbtns .btn.iconbtn{width:34px; height:34px; font-size:1.05rem}
  .tname{font-size:1.1rem}
  .panel{padding:8px; gap:6px; border-radius:16px}
  .turnhead{gap:8px}
  .turnhead .dot.big{width:26px; height:26px}
  .msg{min-height:0; font-size:.92rem}
  .btn.watchvideo{padding:7px 10px; margin-top:0; gap:8px}
  .wv-icon{width:24px; height:24px; font-size:.68rem}
  .wv-text{font-size:.82rem}
  .wv-text small{font-size:.66rem}
}
@media (max-width:900px) and (min-height:521px){
  .game{grid-template-columns:1fr; gap:12px}
  .boardwrap{width:min(100%,760px,calc(100svh - 230px))}
}
@media (max-width:840px) and (max-height:520px), (orientation:landscape) and (max-height:520px) and (pointer:coarse){
  /* phone rotated to landscape: lock the page to portrait by rotating it back to fill the screen */
  html{
    transform:rotate(-90deg); transform-origin:left top;
    width:100vh; height:100vw;
    overflow-x:hidden; overflow-y:auto;
    position:absolute; top:100%; left:0;
  }
  .herohome{
    aspect-ratio:768/1344; margin:0 -10px; border-radius:0; box-shadow:none; border:none;
    -webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 7%,#000 84%,transparent 100%);
    mask-image:linear-gradient(to bottom,transparent 0,#000 7%,#000 84%,transparent 100%);
  }
  .hov-land{display:none}
  .hov-port{display:block}
  .game{grid-template-columns:1fr; gap:12px}
  .boardwrap{width:min(100%,760px)}
}
@media (prefers-reduced-motion:reduce){
  .dice3.ready, .dice3.rolling, .piece.movable .ring{animation:none}
  .pieces.ready .piece{transition:none}
}

/* ---------- SEO / marketing content below the game ---------- */
.seo{max-width:820px; margin:40px auto 0; padding:0 4px; text-shadow:0 1px 3px rgba(0,0,0,.6)}
.seo h2{font-size:1.5rem; font-weight:800; margin:36px 0 10px}
.seo h2:first-child{margin-top:0}
.seo h3{font-size:1.05rem; font-weight:700; margin:18px 0 6px}
.seo p{color:var(--muted); line-height:1.6; margin:0 0 12px}
.seo ul, .seo ol{color:var(--muted); line-height:1.6; margin:0 0 12px; padding-left:22px}
.seo li{margin:4px 0}
.seo strong{color:var(--ink)}
.faq{display:grid; gap:10px; margin:14px 0 8px}
.faq details{--ink:#271F35; --muted:#746B58; background:var(--panel); border:1px solid var(--line); border-radius:14px; padding:14px 16px; color:var(--muted)}
.faq summary{cursor:pointer; font-weight:700; color:var(--ink); font-size:1rem}
.faq summary::-webkit-details-marker{display:none}
.faq p{margin:10px 0 0; color:var(--muted)}
.chiplist{display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 16px}
.chiplist span{background:var(--btn); color:var(--btn-ink); border-radius:999px; padding:6px 13px; font-size:.85rem; font-weight:700}
footer.sitefoot{max-width:820px; margin:36px auto 0; padding:18px 4px 4px; border-top:1px solid var(--line); color:var(--muted); font-size:.85rem; text-align:center}

.socialwrap{max-width:820px; margin:30px auto 0; padding:0 4px; text-align:center}
.socialrow{display:flex; justify-content:center; align-items:center; gap:12px; flex-wrap:wrap}
.social-icon{
  display:inline-flex; align-items:center; justify-content:center;
  width:38px; height:38px; border-radius:50%; flex:none;
  background:var(--btn); box-shadow:0 2px 0 rgba(0,0,0,.25), 0 0 0 1px rgba(244,184,46,.25);
  transition:transform .15s ease, filter .15s ease;
}
.social-icon svg{width:19px; height:19px}
.social-icon:hover{transform:translateY(-2px); filter:brightness(1.12)}
.social-icon:focus-visible{outline:3px solid var(--primary); outline-offset:2px}
.cslinkrow{margin-top:14px; color:var(--muted); font-size:.88rem}
.cslinkrow a{color:#B2791A; font-weight:700; text-decoration:none; display:inline-flex; align-items:center; gap:5px}
.cslinkrow a:hover{text-decoration:underline}
.cslinkrow svg{width:15px; height:15px; flex:none}

/* ---------- watch-video free-piece button ---------- */
.btn.watchvideo{
  display:flex; align-items:center; justify-content:center; gap:11px;
  width:100%; margin-top:0; padding:10px 16px;
  background:linear-gradient(180deg,#FFD873,#F4B82E 55%,#DD9A10);
  color:#2A1800; border-radius:14px;
  border:1px solid rgba(255,255,255,.5);
  box-shadow:0 4px 0 #9C6A08, 0 10px 20px rgba(217,140,10,.35), inset 0 1px 0 rgba(255,255,255,.55);
  position:relative; overflow:hidden;
  animation:wvGlow 2.2s ease-in-out infinite;
}
.btn.watchvideo::after{
  content:''; position:absolute; inset:0; pointer-events:none;
  background:linear-gradient(115deg, transparent 0%, transparent 38%, rgba(255,255,255,.55) 50%, transparent 62%, transparent 100%);
  background-size:220% 100%; background-position:120% 0;
  animation:wvShine 3.4s ease-in-out infinite;
}
.wv-icon{
  flex:none; width:30px; height:30px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  background:#2A1800; color:#F9C94B; font-size:.8rem;
  box-shadow:0 2px 0 rgba(0,0,0,.3), 0 0 0 2px rgba(255,255,255,.35);
}
.wv-text{font-weight:800; font-size:.98rem; line-height:1.18; text-align:left}
.wv-text small{display:block; font-weight:700; font-size:.74rem; opacity:.75; letter-spacing:.2px}
.btn.watchvideo:hover{filter:brightness(1.04)}
.btn.watchvideo:active{transform:translateY(2px); box-shadow:0 2px 0 #9C6A08, 0 6px 14px rgba(217,140,10,.3), inset 0 1px 0 rgba(255,255,255,.5)}
.btn.watchvideo:disabled{opacity:.55; filter:grayscale(.35); animation:none}
.btn.watchvideo:disabled::after{display:none}
@keyframes wvGlow{0%,100%{box-shadow:0 4px 0 #9C6A08, 0 10px 20px rgba(217,140,10,.35), inset 0 1px 0 rgba(255,255,255,.55)} 50%{box-shadow:0 4px 0 #9C6A08, 0 10px 26px rgba(244,184,46,.6), inset 0 1px 0 rgba(255,255,255,.55)}}
@keyframes wvShine{0%,55%{background-position:120% 0} 100%{background-position:-40% 0}}

/* ---------- home extras: icon menu (profile / stats / daily / coins) ---------- */
.homeextras{margin:14px auto 0; max-width:420px}
@media (max-width:720px){
  /* the portrait hero image already includes blank starfield space below the
     buttons, so the icon row + social row are pulled up to sit directly on
     top of that same image — one continuous picture, no separate panel */
  .homeextras{position:relative; z-index:2; margin:-28% auto 6px; max-width:420px}
}
.iconmenu{display:grid; grid-template-columns:repeat(4,1fr); gap:6px}
.iconmenu-btn{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  background:transparent; border:0; padding:4px 2px; font-family:inherit;
}
.iconcircle{
  position:relative; width:44px; height:44px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:1.6rem; filter:drop-shadow(0 3px 0 rgba(0,0,0,.2));
  color:#F4B82E;
}
.iconcircle .iconimg{width:100%; height:100%; display:block; -webkit-user-drag:none; user-select:none}
.iconcircle .profileemoji{
  position:absolute; inset:0; border-radius:50%; background:#262E59;
  display:flex; align-items:center; justify-content:center; font-size:1.7rem;
  box-shadow:0 0 0 2px #F4B82E inset;
}
.iconmenu-btn:hover .iconcircle{filter:drop-shadow(0 3px 0 rgba(0,0,0,.2)) brightness(1.12)}
.iconmenu-btn:focus-visible .iconcircle{outline:3px solid var(--primary); outline-offset:2px; border-radius:50%}
.iconlabel{font-size:.74rem; font-weight:700; color:var(--muted); display:none}
.iconmenu-coin .iconlabel{color:#F4B82E; font-weight:800; display:block}
.badgedot{
  position:absolute; top:-3px; right:-3px; width:13px; height:13px; border-radius:50%;
  background:#ff4d4d; border:2px solid #141A36;
}
.statsrow{display:grid; grid-template-columns:repeat(3,1fr); gap:8px}
.statbox{
  background:#262E59; color:#F3EEE0; border-radius:14px; padding:9px 4px;
  text-align:center; border:1px solid rgba(255,255,255,.08);
}
.statnum{display:block; font-size:1.25rem; font-weight:800}
.statlabel{display:block; font-size:.72rem; color:#B9B6D6; margin-top:1px}
.avatarrow{display:grid; grid-template-columns:repeat(6,1fr); gap:6px}
.avatarrow button{
  font-size:1.4rem; padding:6px 0; border-radius:10px; border:2px solid transparent;
  background:rgba(0,0,0,.06); cursor:pointer;
}
.avatarrow button.sel{border-color:var(--primary); background:rgba(244,184,46,.18)}
.avatarrow button.avbtn-img{width:40px; height:40px; padding:2px; flex:none}
.avbtn.avbtn-img{padding:2px}
.avatarrow button.avbtn-img img, .avbtn.avbtn-img img{width:100%; height:100%; object-fit:cover; border-radius:8px; display:block}
.dot img{width:100%; height:100%; object-fit:cover; border-radius:50%; display:block}
.modalicon{font-size:2.1rem; display:block; margin-bottom:2px}
.modalicon-img{width:46px; height:46px; display:block; margin:0 auto 6px}
@media (max-width:600px){
  .iconcircle{width:40px; height:40px; font-size:1.35rem}
  .iconcircle .profileemoji{font-size:1.45rem}
  .iconlabel{font-size:.68rem}
  .statnum{font-size:1.1rem}
}

/* ---- game bottom: big dice ---- */
.bigdice{display:flex;flex-direction:column;align-items:center;gap:14px;width:100%;padding:10px 0 4px;border:0;background:none;color:#F3EEE0;font:inherit;cursor:pointer;-webkit-tap-highlight-color:transparent}
.bigdice[disabled]{cursor:default}
.bigdice[disabled] .bd-cube{filter:saturate(.6) brightness(.82)}
.bd-cube{width:96px;height:96px;border-radius:22px;background:linear-gradient(145deg,#ffffff 0%,#e9e4d4 60%,#cfc9b6 100%);box-shadow:0 8px 0 #9d9784,0 18px 26px rgba(0,0,0,.5),inset 0 2px 3px #fff,inset 0 -6px 10px rgba(0,0,0,.1);display:grid;grid-template:repeat(3,1fr)/repeat(3,1fr);place-items:center;padding:15px}
.bigdice:not([disabled]) .bd-cube{animation:bdfloat 1.6s ease-in-out infinite}
.bd-cube i{width:16px;height:16px;border-radius:50%;background:transparent}
.bd-cube i.on{background:radial-gradient(circle at 35% 30%,#4a527c,#141A36 70%)}
.bigdice.rolling .bd-cube{animation:bdshake .3s linear infinite}
.bd-label{font-weight:800;letter-spacing:.14em;text-transform:uppercase;font-size:.78rem;color:#F4B82E}
@keyframes bdfloat{50%{transform:translateY(-6px)}}
@keyframes bdshake{0%{transform:rotate(-8deg) translateY(0)}50%{transform:rotate(8deg) translateY(-5px)}100%{transform:rotate(-8deg) translateY(0)}}

/* ---- tablet in portrait: use the portrait art (same as phones), capped in width ---- */
@media (min-width:721px) and (max-width:1100px) and (orientation:portrait){
  /* full-bleed: fills the tablet screen edge to edge; the art is centred and cropped top/bottom,
     and the button layer is the same size as the whole art so hotspots stay on the buttons */
  .herohome{aspect-ratio:auto; width:100vw; margin:0 0 0 calc(50% - 50vw); height:min(100svh, 175vw);
    -webkit-mask-image:linear-gradient(to bottom,transparent 0,#000 5%,#000 90%,transparent 100%);
    mask-image:linear-gradient(to bottom,transparent 0,#000 5%,#000 90%,transparent 100%)}
  .herowrap{position:relative}
  .top{position:absolute; top:0; left:0; right:0; margin-bottom:0; z-index:3}
  body.ingame .top{position:relative; margin-bottom:12px}
  .hov-land{display:none}
  .herohome img{object-position:50% calc(-1 * min(36vw - 70px, 175vw - 100svh))}
  .hov-port{display:block; inset:auto; left:0; right:0; top:calc(-1 * min(36vw - 70px, 175vw - 100svh)); height:175cqw}
  .hovbtn-howto{font-size:3.6cqw}
  .homeextras{position:relative; z-index:2; margin:calc(148.9vw + 20px - min(36vw - 70px, 175vw - 100svh) - 100svh) auto 6px; max-width:420px}
}

@media (max-width:840px) and (max-height:520px), (orientation:landscape) and (max-height:520px) and (pointer:coarse){
  /* phone turned the other way round (top of the phone to the right): rotate the opposite direction so the game never shows upside down */
  html.rotcw{transform:rotate(90deg); top:0; left:100%}
}

@media (max-width:840px) and (max-height:520px), (orientation:landscape) and (max-height:520px) and (pointer:coarse){ .hovbtn-howto{font-size:3.6cqw} }
/* quick facts / rules tables */
.seo table.facts{width:100%; border-collapse:collapse; margin:10px 0 16px; font-size:.95rem; color:var(--muted); background:rgba(0,0,0,.25); border-radius:12px; overflow:hidden}
.seo table.facts th,.seo table.facts td{padding:9px 12px; text-align:left; border-bottom:1px solid rgba(255,255,255,.08); vertical-align:top; line-height:1.45}
.seo table.facts thead th{color:var(--ink); font-weight:800; background:rgba(255,255,255,.06)}
.seo table.facts tbody th{color:var(--ink); font-weight:700; white-space:nowrap}
.seo table.facts tr:last-child th,.seo table.facts tr:last-child td{border-bottom:0}
@media (max-width:520px){.seo table.facts{font-size:.85rem}.seo table.facts th,.seo table.facts td{padding:7px 8px}.seo table.facts tbody th{white-space:normal}}
/* CS button: fixed on the middle-right edge of the screen (hidden during a match) */
.csfloat{position:fixed; right:0; top:50%; transform:translateY(-50%); z-index:50;
  display:flex; flex-direction:column; align-items:center; gap:2px;
  padding:10px 8px 8px 10px; border-radius:16px 0 0 16px; text-decoration:none;
  background:radial-gradient(circle at 35% 30%, #FFE28A, #F4B82E 55%, #C98A12);
  box-shadow:0 4px 14px rgba(0,0,0,.45), inset 0 -3px 0 rgba(0,0,0,.18);
  color:#2A1800; font-weight:800; font-size:.78rem; line-height:1; letter-spacing:.5px;
  animation:csPulse 2.4s ease-in-out infinite}
.csfloat:hover{filter:brightness(1.08)}
.csfloat:focus-visible{outline:3px solid #fff; outline-offset:2px}
#game:not([hidden]) ~ .csfloat{display:none}
@keyframes csPulse{0%,100%{box-shadow:0 4px 14px rgba(0,0,0,.45), inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 0 rgba(244,184,46,.6)}50%{box-shadow:0 4px 14px rgba(0,0,0,.45), inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 8px rgba(244,184,46,0)}}
@media (prefers-reduced-motion:reduce){.csfloat{animation:none}}
