:root{font-family:Pretendard,"Apple SD Gothic Neo","Noto Sans KR",system-ui,sans-serif;color:#f6ebd0;background:#122733;font-synthesis:none}
*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;background:radial-gradient(ellipse at 50% -10%,#25485b 0,#142d3b 38%,#102632 75%);min-height:100vh}button,input,select{font:inherit}button{cursor:pointer}button:disabled{cursor:default}a{color:inherit}button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #ffe08d;outline-offset:3px}
[hidden]{display:none!important}.site-header{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:12px;min-height:67px;max-width:1250px;margin:auto;padding:10px 25px;border-bottom:1px solid #52717b52}.back-link{font-weight:700;color:#e6dec9;text-decoration:none;font-size:13px;min-height:44px;display:flex;align-items:center}.header-title{font-size:15px;letter-spacing:-.03em}.sound-button{justify-self:end;min-width:74px;border:1px solid #67828b;background:#1b3b4a;border-radius:20px;color:#faeac2;padding:10px 13px;font-weight:750}
.page{max-width:1080px;margin:0 auto;padding:30px 20px 70px}.intro{display:flex;gap:24px;align-items:center;justify-content:space-between;padding:13px 20px 32px}.intro-copy{max-width:650px}.intro-eyebrow,.eyebrow{display:block;color:#edc77e;font-size:12px;font-weight:800}.intro h1{margin:10px 0 8px;font-size:clamp(30px,5vw,54px);letter-spacing:-.055em;line-height:1.22}.intro p{color:#cbd9d6;line-height:1.8;font-size:14px;margin:0}.intro p strong{color:#fff3d4}.intro-tags{display:flex;gap:8px;flex-wrap:wrap;margin-top:22px}.intro-tags span{padding:7px 11px;border:1px solid #436878;border-radius:100px;font-size:11px;color:#dce8de}.intro-coin{width:136px;height:136px;flex-shrink:0;display:flex;align-items:center;justify-content:center;flex-direction:column;border-radius:50%;border:7px double #ab823e;box-shadow:0 0 0 7px #304f5f,0 16px 32px #071c2699,inset 0 2px 14px #ffdf8b99;background:radial-gradient(circle at 25% 20%,#d7ad64,#9f6b29 80%);transform:rotate(13deg);color:#3b2e24}.intro-coin span{font-size:52px}.intro-coin small{font-size:8px;font-weight:900;letter-spacing:.04em}
.panel{border:1px solid #476878;border-radius:18px;background:linear-gradient(145deg,#1b3a49,#16313e);box-shadow:0 20px 45px #09192455}.setup{padding:25px}.panel-heading,.game-heading{display:flex;justify-content:space-between;gap:25px;align-items:center}.panel-heading h2,.game-heading h2,.howto h2{margin:9px 0 7px;font-size:clamp(21px,3vw,27px);letter-spacing:-.04em}.panel-heading p,.game-heading p,.setup-footer p{color:#bcd0d0;font-size:12px;line-height:1.8;margin:0}.count-field{display:flex;gap:12px;align-items:center;flex-shrink:0;font-size:12px;color:#d5e5de}.count-field select{min-width:100px;border-radius:9px;background:#244755;border:1px solid #74919a;padding:11px;color:#fff7db}.players{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:11px;margin-top:24px}.player-field{display:flex;flex-direction:column;gap:7px;font-size:12px;color:#d7e1d8}.player-field span{display:flex;align-items:center;gap:7px}.player-mark{width:10px;height:10px;border-radius:50%;display:inline-block;background:var(--player-color)}.player-field input{width:100%;min-width:0;border-radius:10px;border:1px solid #597987;background:#11303e;color:#fff4d7;padding:13px}.player-field input::placeholder{color:#95b0b7}.setup-footer{display:flex;justify-content:space-between;align-items:center;gap:16px;border-top:1px solid #456474;padding-top:19px;margin-top:23px}.primary{min-height:48px;border:0;border-radius:11px;background:linear-gradient(135deg,#edc66e,#d7934d);color:#28313a;font-weight:900;padding:13px 23px;box-shadow:0 4px 0 #9a5e33}.primary:hover{filter:brightness(1.08)}.primary:active{transform:translateY(2px);box-shadow:0 2px 0 #9a5e33}
.game{margin-top:24px}.game-heading{padding:15px 4px 21px}.game-heading h2 span{color:#ffdf8a}.round-status{text-align:right;border:1px solid #53727f;border-radius:14px;padding:12px 16px;min-width:160px}.round-status>span,.round-status small{display:block;color:#bfcfce;font-size:11px}.round-status strong{display:block;font-size:31px;color:#ffe4a0;font-variant-numeric:tabular-nums;line-height:1.2}.game-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(255px,.85fr);gap:17px}.stage{position:relative;isolation:isolate;min-height:560px;overflow:hidden;display:flex;align-items:center;justify-content:flex-end;flex-direction:column;padding:22px 14px 72px;border:1px solid #497080;border-radius:20px;background:radial-gradient(ellipse at 50% 40%,#416879aa 0%,#254857 38%,#163544 75%),linear-gradient(#1f4555,#102b37)}.stage::after{content:"";position:absolute;bottom:47px;left:15%;width:70%;height:35px;background:#041f2a70;filter:blur(15px);z-index:-1}.star{position:absolute;top:19%;left:13%;font-size:42px;color:#e9ba66;opacity:.7}.star-two{top:30%;left:auto;right:10%;font-size:28px}.stage-backlight{position:absolute;bottom:90px;width:390px;max-width:85%;height:350px;border-radius:50%;background:radial-gradient(circle,#c3a26e44,transparent 70%);z-index:-1}.barrel{position:relative;width:min(100%,420px);height:352px;filter:drop-shadow(0 15px 10px #061720aa)}.barrel-mouth{position:absolute;z-index:3;top:-13px;left:8%;width:84%;height:55px;background:radial-gradient(ellipse at center,#0c1d25 0 54%,#9e5d2f 55% 67%,#dfaf6f 71%,#734624 83%);border-radius:50%;border:6px solid #6e3f22;box-shadow:0 2px 0 #e0b678,inset 0 5px 8px #030b12}.barrel-body{position:absolute;inset:12px 2% 8px;z-index:4;border-radius:26% 26% 19% 19%/11% 11% 13% 13%;border:8px solid #4c2921;background:repeating-linear-gradient(90deg,#743f24 0,#af6937 9%,#c38348 17%,#a75c30 24%,#784022 29%);box-shadow:inset 25px 0 28px #4c241f88,inset -26px 0 30px #49211b9c,0 7px 0 #522920;overflow:hidden;display:flex;justify-content:center;align-items:center;padding:60px 14px 75px}.wood-grain{position:absolute;inset:0;pointer-events:none;background:repeating-linear-gradient(180deg,transparent 0 27px,#39201716 28px 29px),linear-gradient(90deg,transparent 33%,#41201930 34% 35%,transparent 36% 63%,#49231d33 64% 65%,transparent 66%);opacity:.65}.metal-band{position:absolute;z-index:2;left:-3px;right:-3px;height:23px;background:linear-gradient(#9aa6a1,#526b73 36%,#354a54 60%,#8c9692);box-shadow:0 4px 3px #2c161683}.top-band{top:31px}.bottom-band{bottom:35px}.slot-grid{position:relative;z-index:5;width:100%;display:grid;grid-template-columns:repeat(var(--slot-columns,4),minmax(0,1fr));grid-auto-rows:minmax(38px,1fr);justify-items:center;align-items:center;gap:6px 3px}.slot{position:relative;display:grid;place-items:center;width:clamp(30px,8vw,43px);height:clamp(30px,8vw,43px);padding:0;border:2px solid #5a3020;border-radius:50%;color:#e7c68c;background:radial-gradient(circle at 47% 45%,#241b1b 30%,#52301f 55%,#dba063 64%,#54311f 75%);box-shadow:inset 0 2px 8px #090b0caa,0 2px 2px #d5985655;transition:filter .15s,transform .15s}.slot:not(:disabled):hover{filter:brightness(1.35);transform:scale(1.12)}.slot:not(:disabled):active{transform:scale(.94)}.slot::after{content:"+";font-weight:750;font-size:14px;opacity:.7}.slot:disabled:not(.inserted){opacity:.45}.slot.inserted{background:radial-gradient(circle,#27343d 18%,#5a3020 54%,#bc8958 68%);transform:rotate(var(--blade-turn,0deg));box-shadow:inset 0 2px 5px #090b0c99}.slot.inserted::after{display:none}.sword{position:absolute;width:27px;height:55px;left:50%;top:50%;transform:translate(-50%,-63%) rotate(-34deg);display:none;filter:drop-shadow(1px 4px 2px #0008)}.inserted .sword{display:block;animation:stab .22s cubic-bezier(.25,1.35,.5,1) both}.sword::before{content:"";position:absolute;left:11px;top:0;width:8px;height:40px;clip-path:polygon(50% 100%,0 16%,20% 0,80% 0,100% 16%);background:linear-gradient(90deg,#98bac6 0%,#f8ffff 46%,#769baa 100%)}.sword::after{content:"";position:absolute;left:5px;top:8px;width:21px;height:7px;border-radius:4px;background:linear-gradient(#e3c67f,#8f663c);box-shadow:0 -12px 0 -2px #5a3024}.barrel-badge{position:absolute;bottom:53px;left:50%;transform:translateX(-50%);border-radius:50%;width:47px;height:47px;display:grid;place-items:center;font-size:24px;color:#3c2d24;background:radial-gradient(#eed394,#a37b37);border:4px solid #674121;box-shadow:0 3px 4px #39201c88}.barrel-base{position:absolute;bottom:-9px;left:8%;height:28px;width:84%;border-radius:50%;background:linear-gradient(#744727,#41291e);border:4px solid #392216}.pirate-figure{position:absolute;z-index:2;bottom:319px;width:235px;height:235px;transform:translateY(200px) scale(.8) rotate(-5deg);transform-origin:50% 100%;opacity:0;pointer-events:none}.pirate-figure svg{display:block;width:100%;height:100%;filter:drop-shadow(0 12px 14px #0b1a24bb)}.stage.popped .pirate-figure{animation:pirate-pop 1.05s cubic-bezier(.13,1.25,.38,1) forwards}.stage.popped{animation:stage-jolt .43s ease-in-out}.stage.popped .barrel-mouth{animation:lid-shiver .55s both}.pop-burst{position:absolute;z-index:10;top:22px;color:#ffe7a4;font-size:27px;opacity:0;pointer-events:none}.pop-burst span{font-weight:1000;color:#ffde88;font-size:60px;text-shadow:0 5px 1px #a24d28,0 7px 10px #0b1e29}.stage.popped .pop-burst{animation:burst .85s .23s both}.stage-caption{position:absolute;z-index:11;left:12px;right:12px;bottom:18px;text-align:center;font-size:14px;color:#ebead8;font-weight:750;line-height:1.6}.sidebar{padding:24px;display:flex;flex-direction:column;gap:16px}.side-heading h3{font-size:20px;letter-spacing:-.035em;margin:9px 0 0}.turn-list{list-style:none;margin:0;padding:0;display:grid;gap:9px}.turn-list li{display:flex;align-items:center;gap:11px;min-width:0;background:#193b4b;border:1px solid #406677;border-radius:11px;padding:11px 12px;font-size:13px}.turn-list li.active{background:#335264;border-color:#ebc079;box-shadow:inset 3px 0 0 #e5c270}.turn-list li.lost{background:#5a3b3c;border-color:#c2755f}.turn-list .player-index{width:26px;height:26px;border-radius:50%;background:var(--player-color);display:grid;place-items:center;font-weight:900;color:#18333f;flex-shrink:0}.turn-list .player-label{min-width:0;overflow-wrap:anywhere;flex:1;font-weight:700}.turn-list small{color:#dfd1b9;font-size:11px;white-space:nowrap}.chance-note{display:flex;gap:13px;background:#0b2938;border-radius:12px;padding:15px;margin-top:auto}.chance-icon{font-size:25px}.chance-note strong{font-size:13px}.chance-note p{font-size:11px;line-height:1.7;color:#adbdc2;margin:7px 0 0}.sidebar-actions{display:grid;gap:10px}.secondary,.subtle{width:100%;min-height:44px;border-radius:10px;font-weight:700}.secondary{background:#34576a;border:1px solid #648491;color:#f8eacc}.subtle{background:transparent;border:1px solid #527080;color:#c9d9d7}.result{display:flex;align-items:center;gap:20px;margin-top:18px;padding:22px;background:linear-gradient(130deg,#485240,#1f4750);border-color:#b7a46f}.result-symbol{font-size:44px}.result div{flex:1}.result div span{display:block;font-size:12px;color:#e0d9af}.result strong{display:block;font-size:30px;color:#ffe4a0;overflow-wrap:anywhere}.result p{margin:6px 0 0;font-size:12px;color:#e4ddd1}.howto{margin-top:25px;padding:25px}.howto-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:14px;margin-top:18px}.howto-grid>div{border-top:1px solid #5c7983;padding-top:13px}.howto-grid b{font-size:13px;color:#ffdb94}.howto-grid p,.fair-note,.credits{font-size:12px;color:#b7cbcb;line-height:1.8}.fair-note{margin:20px 8px}.credits{margin:15px 8px}.credits summary{cursor:pointer;color:#e5d8ae}.credits a{color:#f2d285}
@keyframes stab{from{transform:translate(-50%,-135%) rotate(-34deg);opacity:0}to{transform:translate(-50%,-63%) rotate(-34deg);opacity:1}}@keyframes pirate-pop{0%{transform:translateY(200px) scale(.8) rotate(-5deg);opacity:0}34%{transform:translateY(-31px) scale(1.1) rotate(9deg);opacity:1}56%{transform:translateY(5px) scale(.98) rotate(-7deg);opacity:1}75%{transform:translateY(-13px) scale(1.04) rotate(3deg);opacity:1}100%{transform:translateY(0) scale(1) rotate(0);opacity:1}}@keyframes burst{0%{transform:translateY(40px) scale(.3);opacity:0}45%{transform:translateY(-7px) scale(1.08);opacity:1}100%{transform:translateY(4px) scale(1);opacity:1}}@keyframes stage-jolt{0%,100%{filter:none}25%,70%{filter:brightness(1.3)}}@keyframes lid-shiver{0%,100%{transform:none}40%{transform:translateY(5px) rotate(1deg)}}
@media(max-width:750px){.intro{padding:6px 0 25px}.intro-coin{width:85px;height:85px;border-width:5px}.intro-coin span{font-size:35px}.intro-coin small{font-size:5px}.game-grid{grid-template-columns:1fr}.stage{min-height:500px}.sidebar{padding:20px}.turn-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.howto-grid{grid-template-columns:1fr}.howto-grid>div+div{border-top:1px solid #5c7983}.players{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(max-width:440px){.site-header{padding:8px 12px;gap:5px}.header-title{font-size:13px}.back-link{font-size:11px}.sound-button{min-width:57px;font-size:11px;padding:10px 5px}.page{padding:17px 10px 40px}.intro{padding:7px 5px 23px}.intro h1{font-size:30px}.intro p{font-size:12px}.intro-coin{display:none}.panel-heading{align-items:flex-start;flex-direction:column;gap:12px}.setup{padding:17px}.setup-footer{align-items:stretch;flex-direction:column}.game-heading{gap:8px}.game-heading h2{font-size:19px}.round-status{min-width:115px;padding:10px 7px}.round-status small{font-size:9px}.stage{min-height:465px;padding:10px 6px 65px}.barrel{width:min(100%,335px);height:308px}.barrel-body{padding:58px 9px 69px}.slot{width:clamp(29px,9vw,39px);height:clamp(29px,9vw,39px)}.slot-grid{gap:4px 1px;grid-auto-rows:minmax(35px,1fr)}.pirate-figure{bottom:283px;width:205px;height:205px}.pop-burst span{font-size:48px}.result{gap:10px;padding:15px;flex-wrap:wrap}.result button{width:100%}.turn-list li{padding:9px 8px;gap:6px}.turn-list small{font-size:9px}}
@media(prefers-reduced-motion:reduce){html{scroll-behavior:auto}.slot,.primary{transition:none}.stage.popped,.stage.popped .barrel-mouth{animation:none}.stage.popped .pirate-figure{animation:none;opacity:1;transform:none}.stage.popped .pop-burst{animation:none;opacity:1}.inserted .sword{animation:none}}

/* Toy-box redesign: a brass-trimmed pirate arcade with a curved barrel face.
   The puzzle is still four hidden holes per participant; only presentation changes. */
:root{--pirate-navy:#162837;--pirate-deep:#0e202e;--pirate-gold:#f4c97d;--pirate-parchment:#fff4db;--pirate-teal:#3d7382}
body{
  background:
    radial-gradient(ellipse at 50% -24%,#385d68 0,transparent 58%),
    repeating-linear-gradient(90deg,#142c38 0 4px,#162e3c 4px 8px);
}
.site-header{border-bottom-color:#c4a87036;background:#132733aa;max-width:1250px}
.header-title{font-weight:850;color:#fff0c9;font-size:16px}
.sound-button{border-color:#bda37277;background:#244552;color:#fff0cc;min-height:43px}
.page{max-width:1180px;padding-top:22px}
.intro{padding:15px 15px 29px;gap:22px}
.intro-eyebrow{font-size:12px;color:#f3c981}
.intro h1{font-size:clamp(37px,5vw,60px);letter-spacing:-.06em;color:#fff6db;text-shadow:0 3px 1px #101c2d80}
.intro p{color:#c4d6d9;max-width:610px}
.intro-tags span{background:#f6d7a612;border:1px solid #ebc28455;color:#f5e8d3}
.intro-coin{width:119px;height:119px;border:7px double #e0b777;box-shadow:0 0 0 5px #d0a86221,0 14px 24px #081725aa,inset 0 2px 16px #ffe6a5c7;background:radial-gradient(circle at 28% 25%,#f2d8a1,#c58a44 67%,#70462b)}
.panel{border-color:#bca17945;box-shadow:0 14px 35px #0618244f}
.setup{background:linear-gradient(145deg,#fff5dc,#e8dcc3);color:#233e40;border:2px solid #d7b878}
.setup .eyebrow,.setup .panel-heading h2{color:#284549}
.setup .panel-heading p{color:#5c6f67}
.count-field{color:#345558;font-weight:850}
.count-field select{background:#fffdf2;border-color:#c1a97a;color:#304a4a}
.player-field{color:#315257;font-weight:750}
.player-field input{background:#fffdf2;border:1px solid #c7b28e;color:#253d44}
.player-field input::placeholder{color:#789090}
.setup-footer{border-top-color:#cbb995}
.setup-footer p{color:#617479}
.setup .primary{box-shadow:0 4px 0 #93602c,0 8px 16px #98774938}
.game{margin-top:12px}
.game-heading{background:#f5e8cf;border:2px solid #d7b778;border-radius:19px;padding:15px 19px;margin-bottom:13px;box-shadow:0 9px 20px #0b182b47;gap:12px}
.turn-identity{display:flex;align-items:center;gap:15px;min-width:0}
.turn-identity>div{min-width:0}
.turn-pip{flex:0 0 52px;width:52px;height:52px;display:grid;place-items:center;border-radius:17px;background:var(--player-color,#eab86e);border:3px solid #fff6dd;box-shadow:0 3px 0 #af976a,0 5px 14px #281a1d2c;color:#1e3442;font-weight:950;font-size:24px}
.game-heading .eyebrow{font-size:11px;color:#74613f}
.game-heading h2{font-size:clamp(18px,2.9vw,25px);color:#273e46;line-height:1.34;overflow-wrap:anywhere}
.game-heading h2 span:first-child{color:#a04d35}
.game-heading p{color:#617378;line-height:1.5}
.round-status{background:#244354;border:1px solid #244554;border-radius:14px;min-width:155px;box-shadow:inset 0 1px #ffffff2b}
.round-status>span{color:#e7d9bf;font-weight:800}
.round-status strong{color:#ffdc8f;font-size:34px;line-height:1.18}
.round-status small{color:#d4d5ca;white-space:nowrap}
.game-grid{grid-template-columns:minmax(0,1.52fr) minmax(265px,.83fr);gap:13px;align-items:stretch}
.stage{
  min-height:590px;
  justify-content:flex-end;
  border:2px solid #d5aa6c;
  border-radius:25px;
  padding:36px 17px 70px;
  background:
    radial-gradient(ellipse at 50% 56%,#64889490 0%,#2c566a70 34%,transparent 72%),
    repeating-linear-gradient(135deg,transparent 0 26px,#e8c18708 26px 27px),
    linear-gradient(140deg,#244c61,#142f42 67%,#102a3b);
  box-shadow:inset 0 0 0 7px #081c2c78,inset 0 0 0 9px #f4c98224,0 16px 28px #051b2d87;
}
.stage::before{content:'';position:absolute;pointer-events:none;inset:17px;border:1px solid #f4d29d32;border-radius:15px}
.stage::after{bottom:55px;filter:blur(16px);height:38px;background:#021825a3}
.stage-marquee{position:absolute;top:28px;left:50%;transform:translateX(-50%);z-index:6;white-space:nowrap;border:1px solid #e9be788c;border-radius:100px;background:#0c293bb8;box-shadow:0 3px 0 #07172499;padding:8px 23px;color:#f7ddb0;font-size:13px;font-weight:950;letter-spacing:.02em}
.stage-marquee span{color:#f8cd77;font-size:13px;padding:0 8px}
.star{top:17%;left:12%;color:#ffd38c;text-shadow:0 0 16px #ffe1a57f}
.star-two{top:25%;right:9%;left:auto}
.stage-backlight{bottom:91px;width:420px;height:360px;opacity:1;background:radial-gradient(ellipse at center,#ffe0a438 0,#a3cae016 46%,transparent 74%)}
.barrel{width:min(100%,422px);height:360px;z-index:4;filter:drop-shadow(0 19px 12px #031321b3)}
.barrel-body{
  inset:11px 2% 8px;
  border:8px solid #5c3227;
  border-radius:29% 29% 18% 18% / 14% 14% 17% 17%;
  background:
    repeating-linear-gradient(90deg,transparent 0 18%,#2a130b2c 18.2% 18.7%,transparent 19% 39%,#2a130b37 39.3% 39.7%,transparent 40% 59%,#2a130b40 59.3% 59.7%,transparent 60% 80%,#2a130b2c 80.3% 80.7%,transparent 81% 100%),
    linear-gradient(90deg,#743a29 0%,#a85d35 13%,#d99c58 28%,#e2ab6b 45%,#cd8a49 64%,#a35c35 81%,#6d3929 100%);
  box-shadow:inset 28px 0 24px #3d1e17a1,inset -29px 0 26px #3e1c18ba,inset 0 10px 20px #ffdc9a26,0 8px 0 #41291f;
  padding:65px 21px 79px;
}
.wood-grain{background:repeating-linear-gradient(178deg,transparent 0 18px,#46241c10 19px 20px,transparent 21px 45px),linear-gradient(90deg,#2b160d23 0 2%,transparent 16% 84%,#2b160d32 98% 100%);opacity:1}
.barrel-mouth{border-color:#8f5d36;top:-19px;height:59px;background:radial-gradient(ellipse at center,#142532 0 50%,#45291f 51% 58%,#a56e42 59% 70%,#f6c784 74%,#825031 85%);box-shadow:inset 0 5px 8px #010e18a9,0 4px 0 #673920}
.metal-band{height:22px;left:-4px;right:-4px;background:linear-gradient(#f9daa1 0,#c7a068 12%,#7a705d 45%,#56545b 55%,#bda474 92%,#f7cb85);border-top:2px solid #ffebba92;border-bottom:2px solid #413b39a6;box-shadow:0 4px 7px #361c1690}
.top-band{top:30px}.bottom-band{bottom:37px}
.barrel-badge{bottom:45px;width:41px;height:41px;font-size:22px;border-color:#6e452d;background:radial-gradient(#fff1ba,#c8964b);box-shadow:0 2px 0 #422216a6}
.barrel-base{bottom:-14px;height:34px;border-color:#4c3228;background:linear-gradient(#9b6438,#492d25)}
.slot-grid{
  position:relative;z-index:6;
  display:grid;
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:repeat(var(--slot-rows,4),minmax(0,1fr));
  align-content:center;justify-items:stretch;
  row-gap:4px;
  width:100%;height:100%;
  padding:1px 2px;
}
.slot-row{display:grid;grid-template-columns:repeat(var(--row-count),minmax(0,44px));justify-content:center;align-items:center;gap:clamp(2px,.65vw,7px);min-width:0;width:100%;padding:0 1px}
.slot{
  position:relative;
  width:100%;height:auto;aspect-ratio:1;
  min-width:0;min-height:29px;
  padding:0;
  border:2px solid #72422e;border-radius:50%;
  background:radial-gradient(circle at 50% 47%,#0a1c27 0 37%,#293241 50%,#ab7445 61%,#e8b980 70%,#69472e 82%);
  box-shadow:inset 0 3px 8px #000b,inset 0 -2px 3px #020f11ab,0 2px 0 #f3c48670,0 3px 4px #38201766;
  transform:translateY(var(--arc-y,0px)) rotate(var(--hole-tilt,0deg));
  transition:filter .16s,transform .16s,box-shadow .16s;
  -webkit-tap-highlight-color:transparent;
  touch-action:manipulation;
}
.slot::before{content:'';position:absolute;inset:7px;border-radius:50%;border:1px solid #fff1c821;pointer-events:none}
.slot::after{content:none}
.slot-number{position:relative;z-index:1;color:#ffe4bbdb;font-size:clamp(8px,1.2vw,11px);font-weight:850;font-variant-numeric:tabular-nums;text-shadow:0 1px 2px #000b;line-height:1;pointer-events:none}
.slot:not(:disabled):hover{filter:brightness(1.19);transform:translateY(calc(var(--arc-y,0px) - 2px)) rotate(var(--hole-tilt,0deg)) scale(1.09);box-shadow:inset 0 2px 6px #0009,0 0 0 3px #ffe19c55,0 3px 7px #241d1e8c}
.slot:not(:disabled):active{transform:translateY(calc(var(--arc-y,0px) + 2px)) scale(.96)}
.slot:focus-visible{outline:3px solid #ffdf8b;outline-offset:3px;z-index:9}
.slot.inserted{transform:translateY(var(--arc-y,0px)) rotate(var(--hole-tilt,0deg));border-color:var(--knife-color,#d3a86b);background:radial-gradient(circle,#1d2b34 0 41%,#513b31 52%,#b48a63 69%,#52311e 87%);box-shadow:inset 0 3px 9px #000a,0 2px 2px #d29d6c80;z-index:7}
.slot.inserted .slot-number{opacity:0}
.sword{width:29px;height:62px;transform:translate(-50%,-63%) rotate(calc(-33deg + var(--blade-turn,0deg)));transform-origin:50% 76%;filter:drop-shadow(2px 4px 3px #040b1399)}
/* The participant's palette colors the visible blade and the hilt, not just the hole ring. */
.sword::before{left:11px;top:8px;width:9px;height:42px;clip-path:polygon(0% 0%,100% 0,83% 77%,50% 100%,17% 77%);background:linear-gradient(90deg,#2035439e 0%,#ffffff85 42%,#ffffff18 62%,#193543a1 100%),var(--knife-color,#eab86e);box-shadow:inset 1px 1px #ffffff9e}
.sword .knife-grip{position:absolute;left:10px;top:-16px;width:12px;height:23px;border:1px solid #1c36446b;border-radius:5px 5px 2px 2px;background:linear-gradient(90deg,#152b396e,#ffffff4d 38%,#152b396b),var(--knife-color,#eab86e);box-shadow:inset 0 1px #ffffff86,0 -3px 0 -1px #d7b677;pointer-events:none}
.sword::after{left:3px;top:6px;width:26px;height:8px;border-radius:6px;background:linear-gradient(#fff1bb,#c0965e);box-shadow:0 1px 2px #2a1e16ba}
.inserted .sword{animation:arcade-knife-in .32s cubic-bezier(.16,.9,.25,1.23) both}
@keyframes arcade-knife-in{0%{opacity:0;transform:translate(-50%,-116%) rotate(calc(-42deg + var(--blade-turn,0deg))) scale(.9)}65%{opacity:1;transform:translate(-50%,-55%) rotate(calc(-28deg + var(--blade-turn,0deg)))}100%{transform:translate(-50%,-63%) rotate(calc(-33deg + var(--blade-turn,0deg)))}}
.pirate-figure{z-index:3;bottom:331px;width:240px;height:240px;opacity:1;transform:translateY(87px) scale(.87) rotate(-5deg);filter:drop-shadow(0 12px 16px #09223591)}
.stage.popped .pirate-figure{z-index:6;animation:pirate-pop .95s cubic-bezier(.13,1.25,.38,1) forwards}
.stage.popped{animation:stage-jolt .42s ease-in-out}
.stage-caption{left:21px;right:21px;bottom:20px;padding:11px 13px;border:1px solid #eed9ad47;border-radius:10px;background:#081f31b7;font-size:13px;line-height:1.5;box-shadow:inset 0 1px #fff3cd13}
.pop-burst{z-index:11;top:85px;font-size:21px;filter:drop-shadow(0 6px 8px #051927)}
.pop-burst span{font-size:clamp(44px,6vw,65px)}
.stage.is-safe .barrel{animation:arcade-barrel-tap .33s ease-out}
@keyframes arcade-barrel-tap{0%,100%{transform:rotate(0)}25%{transform:rotate(-.8deg)}65%{transform:rotate(.9deg)}}
.sidebar{padding:21px 20px;background:linear-gradient(150deg,#fff0d0,#e7dbc0);border:2px solid #d8b674;color:#273f46;gap:14px}
.sidebar .eyebrow{color:#8f7147}
.side-heading h3{color:#273f46;margin:4px 0 4px}
.side-subtitle{font-size:12px;line-height:1.6;color:#667875;margin:0}
.score-micro{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.score-micro>span{display:flex;align-items:center;justify-content:space-between;border:1px solid #d8c49f;background:#fdf5e6;border-radius:9px;padding:10px;min-width:0;color:#577173;font-size:11px;font-weight:750}
.score-micro strong{color:#a0683e;font-size:20px;font-variant-numeric:tabular-nums}
.turn-list{gap:7px}
.turn-list li{min-height:51px;background:#fff9ed;border:1px solid #d0bea2;color:#394d4f;border-radius:11px;box-shadow:0 2px 0 #ae9b8028}
.turn-list li.active{background:#fff0c8;border-color:#d4a456;box-shadow:inset 4px 0 0 #c88945,0 2px 0 #bf9d5c62}
.turn-list li.lost{background:#ffe4d4;border-color:#cf947f;color:#883e2e}
.turn-list .player-index{color:#203b46;border:2px solid #ffffffc0;box-shadow:0 1px 3px #0002;width:30px;height:30px}
.turn-list .player-label{font-size:12px}
.turn-list small{color:#65716c}
.turn-list li.lost small{color:#a65740;font-weight:900}
.chance-note{background:#e3d3b2;border:1px solid #c9b38d;color:#384744;padding:13px}
.chance-icon{display:grid;place-items:center;border-radius:9px;width:39px;height:39px;background:#fff0cc;color:#755732;flex-shrink:0}
.chance-note p{color:#697873;margin-top:4px}
.sidebar-actions{gap:9px}
.secondary{color:#ffeed0;background:#294c57;border-color:#294c57}
.subtle{color:#345760;border-color:#b19b7b;background:#fff9ea}
.secondary:hover:not(:disabled){background:#376474}
.subtle:hover:not(:disabled){background:#f1e3cb}
.result{background:linear-gradient(120deg,#fff0d3,#ebc992);border:2px solid #ebbf68;color:#3e3430;box-shadow:0 10px 24px #010e1c5c}
.result div span,.result p{color:#785d45}
.result strong{color:#9c4f34}
.howto{background:linear-gradient(140deg,#1f4050,#1a3543)}
.howto-grid>div{border-top-color:#bd9c666c}
@media(max-width:850px){
  .game-grid{grid-template-columns:minmax(0,1fr)}
  .stage{min-height:550px}
  .sidebar{gap:13px}
  .turn-list{grid-template-columns:repeat(2,minmax(0,1fr))}
  .slot-row{gap:4px}
}
@media(max-width:500px){
  .page{padding:13px 10px 38px}
  .intro{padding:9px 5px 20px}
  .intro h1{font-size:35px}
  .intro-coin{display:none}
  .game-heading{padding:12px;align-items:center;gap:8px}
  .turn-identity{gap:8px}
  .turn-pip{flex-basis:39px;width:39px;height:39px;border-radius:12px;font-size:18px}
  .game-heading h2{font-size:17px}
  .game-heading .eyebrow{font-size:10px}
  .game-heading p{font-size:10px;line-height:1.45}
  .round-status{min-width:108px;padding:8px 7px}
  .round-status strong{font-size:29px}
  .round-status small{font-size:9px;white-space:normal}
  .stage{min-height:483px;padding:26px 7px 65px;border-radius:19px}
  .stage::before{inset:10px}
  .stage-marquee{top:19px;padding:6px 14px;font-size:11px}
  .barrel{width:min(100%,340px);height:315px}
  .barrel-body{inset:9px 1.5% 7px;padding:57px 10px 67px;border-width:6px}
  .barrel-mouth{top:-12px;height:48px;border-width:5px}
  .metal-band{height:18px}
  .top-band{top:27px}.bottom-band{bottom:31px}
  .barrel-badge{bottom:40px;width:34px;height:34px;font-size:17px}
  .slot-grid{row-gap:0;padding:1px}
  .slot-row{gap:2px;padding:0}
  .slot{min-height:27px;border-width:1.5px}
  .slot-number{font-size:9px}
  .sword{width:25px;height:48px}
  .sword::before{width:7px;height:32px;left:10px}
  .sword::after{width:21px;left:4px}
  .pirate-figure{bottom:282px;width:209px;height:209px;transform:translateY(73px) scale(.85) rotate(-5deg)}
  .pop-burst{top:77px}
  .stage-caption{bottom:12px;left:10px;right:10px;font-size:11px;padding:9px}
  .sidebar{padding:16px}
  .score-micro strong{font-size:17px}
  .turn-list li{padding:8px 7px;gap:6px}
  .turn-list .player-index{width:25px;height:25px;font-size:12px}
}
@media(prefers-reduced-motion:reduce){
  .slot{transition:none}
  .inserted .sword,.stage.is-safe .barrel{animation:none!important}
  .stage.popped .pirate-figure{animation:none!important;transform:translateY(-26px) scale(1);opacity:1}
}

/* The character starts peeking above the rim, then springs up without sinking first. */
.stage.popped .pirate-figure { animation:arcade-pirate-leap 1050ms cubic-bezier(.19,.83,.23,1) forwards; }
@keyframes arcade-pirate-leap {
  0% {transform:translateY(87px) scale(.87) rotate(-5deg);opacity:1}
  32% {transform:translateY(-93px) scale(1.12) rotate(9deg);opacity:1}
  58% {transform:translateY(-42px) scale(.98) rotate(-7deg);opacity:1}
  78% {transform:translateY(-65px) scale(1.06) rotate(3deg);opacity:1}
  100% {transform:translateY(-55px) scale(1) rotate(0deg);opacity:1}
}
@media(prefers-reduced-motion:reduce){.stage.popped .pirate-figure{animation:none!important;transform:translateY(-55px) scale(1)}}

/* Winning rescue: launch, airborne tumble, glowing flight trail and soft landing.
   The arcade stage grows to contain the entire flight instead of clipping it. */
.stage {
  --flight-apex: -80px;
  --flight-side: 72px;
  min-height: 670px;
}
.stage.popped .pirate-figure {
  z-index: 9;
  animation: pirate-rescue-flight 1550ms cubic-bezier(.18,.5,.25,1) both;
  transform-origin: 50% 64%;
  will-change: transform;
}
@keyframes pirate-rescue-flight {
  0%   {transform:translate3d(0,87px,0) scale(.87) rotate(-5deg);opacity:1}
  9%   {transform:translate3d(0,95px,0) scale(.82) rotate(-12deg);opacity:1}
  23%  {transform:translate3d(-12px,-4px,0) scale(1.06) rotate(43deg);opacity:1}
  44%  {transform:translate3d(calc(var(--flight-side) * -1),calc(var(--flight-apex) * .74),0) scale(1.08) rotate(165deg);opacity:1}
  57%  {transform:translate3d(8px,var(--flight-apex),0) scale(1.1) rotate(254deg);opacity:1}
  73%  {transform:translate3d(var(--flight-side),calc(var(--flight-apex) * .66),0) scale(.99) rotate(339deg);opacity:1}
  85%  {transform:translate3d(32px,-16px,0) scale(.94) rotate(376deg);opacity:1}
  93%  {transform:translate3d(-12px,-38px,0) scale(1.06) rotate(355deg);opacity:1}
  100% {transform:translate3d(0,-30px,0) scale(1) rotate(360deg);opacity:1}
}
.flight-effects {
  position:absolute;
  z-index:7;
  left:50%;
  bottom:312px;
  width:min(92%,460px);
  height:260px;
  transform:translateX(-50%);
  opacity:0;
  pointer-events:none;
}
.flight-arc{width:100%;height:100%;overflow:visible;filter:drop-shadow(0 0 6px #ffe1a47b)}
.flight-arc path {
  fill:none;
  stroke:#ffdf96;
  stroke-width:5;
  stroke-linecap:round;
  stroke-dasharray:9 14;
  stroke-dashoffset:600;
  opacity:0;
}
.stage.popped .flight-effects{opacity:1;animation:flight-trail-vanish 1550ms ease-out both}
.stage.popped .flight-arc path{animation:flight-trail-draw 1350ms .13s ease-out both}
@keyframes flight-trail-draw {
  0% {stroke-dashoffset:600;opacity:0}
  20%{opacity:.94}
  73%{opacity:.92}
  100%{stroke-dashoffset:0;opacity:0}
}
@keyframes flight-trail-vanish{0%{opacity:0}14%{opacity:1}83%{opacity:1}100%{opacity:0}}
.flight-spark{
  position:absolute;
  z-index:1;
  left:50%;
  top:73%;
  width:9px;
  height:9px;
  background:#ffedb3;
  border-radius:2px;
  box-shadow:0 0 12px #ffe19ab0;
  transform:translate(-50%,-50%) rotate(45deg) scale(0);
  opacity:0;
}
.flight-spark::after{content:'';position:absolute;left:50%;top:-75%;width:1px;height:250%;background:#fff6d0c7}
.flight-spark-one  {--dx:-118px;--dy:-100px;--spin:95deg;animation-delay:0ms}
.flight-spark-two  {--dx:94px;--dy:-116px;--spin:185deg;animation-delay:70ms}
.flight-spark-three{--dx:-143px;--dy:20px;--spin:230deg;animation-delay:95ms}
.flight-spark-four {--dx:145px;--dy:-30px;--spin:115deg;animation-delay:145ms}
.flight-spark-five {--dx:-33px;--dy:-160px;--spin:285deg;animation-delay:180ms}
.flight-spark-six  {--dx:50px;--dy:58px;--spin:330deg;animation-delay:220ms}
.stage.popped .flight-spark {animation:flight-spark-burst .74s cubic-bezier(.11,.63,.26,1) both}
@keyframes flight-spark-burst {
  0% {opacity:0;transform:translate(-50%,-50%) rotate(45deg) scale(.2)}
  18% {opacity:1}
  80% {opacity:.88}
  100% {opacity:0;transform:translate(calc(-50% + var(--dx)),calc(-50% + var(--dy))) rotate(var(--spin)) scale(.55)}
}
.launch-cloud{
  position:absolute;
  pointer-events:none;
  z-index:8;
  bottom:409px;
  left:50%;
  width:190px;
  height:68px;
  opacity:0;
  transform:translateX(-50%);
}
.launch-cloud i{
  display:block;
  position:absolute;
  bottom:5px;
  left:calc(50% - 17px);
  width:36px;
  height:30px;
  border-radius:50%;
  background:radial-gradient(circle at 38% 37%,#fff7dc,#c7e7dfc2 63%,#c7e7df00);
  filter:drop-shadow(0 0 5px #fff1c08c);
}
.launch-cloud i:nth-child(1){--cloud-x:-80px;--cloud-y:-4px}
.launch-cloud i:nth-child(2){--cloud-x:-44px;--cloud-y:-31px}
.launch-cloud i:nth-child(3){--cloud-x:1px;--cloud-y:-40px}
.launch-cloud i:nth-child(4){--cloud-x:43px;--cloud-y:-28px}
.launch-cloud i:nth-child(5){--cloud-x:82px;--cloud-y:-4px}
.stage.popped .launch-cloud{opacity:1;animation:launch-cloud-fade .8s ease-out both}
.stage.popped .launch-cloud i{animation:launch-puff .68s ease-out both}
@keyframes launch-cloud-fade{0%{opacity:0}18%{opacity:1}67%{opacity:1}100%{opacity:0}}
@keyframes launch-puff{
  0%{opacity:0;transform:translate(0,0) scale(.35)}
  20%{opacity:.96}
  100%{opacity:0;transform:translate(var(--cloud-x),var(--cloud-y)) scale(1.45)}
}
.stage.popped .barrel {animation:rescue-recoil .6s cubic-bezier(.2,.6,.28,1) both}
@keyframes rescue-recoil {
  0%,100%{transform:translateY(0) rotate(0)}
  13%{transform:translateY(9px) rotate(-1deg)}
  40%{transform:translateY(-6px) rotate(1deg)}
  65%{transform:translateY(3px) rotate(-.55deg)}
}
.stage.popped .pop-burst{top:78px;animation:rescue-shout .95s .24s cubic-bezier(.16,.7,.21,1) both}
@keyframes rescue-shout{
  0%{opacity:0;transform:translateY(45px) scale(.4) rotate(-7deg)}
  38%{opacity:1;transform:translateY(0) scale(1.25) rotate(7deg)}
  66%{opacity:1;transform:translateY(-14px) scale(1) rotate(-3deg)}
  100%{opacity:0;transform:translateY(-35px) scale(.84) rotate(0)}
}
@media(max-width:850px){
  .stage{min-height:635px}
}
@media(max-width:500px){
  .stage{min-height:565px;--flight-apex:-51px;--flight-side:42px}
  .stage.popped .pirate-figure{animation-name:pirate-rescue-flight-mobile}
  .flight-effects{width:min(94%,365px);height:200px;bottom:282px}
  .launch-cloud{bottom:361px;transform:translateX(-50%) scale(.8)}
  .stage.popped .pop-burst{top:66px}
}
@keyframes pirate-rescue-flight-mobile {
  0%   {transform:translate3d(0,73px,0) scale(.85) rotate(-5deg);opacity:1}
  9%   {transform:translate3d(0,78px,0) scale(.81) rotate(-12deg);opacity:1}
  23%  {transform:translate3d(-8px,9px,0) scale(.96) rotate(43deg);opacity:1}
  44%  {transform:translate3d(-42px,-38px,0) scale(1.02) rotate(165deg);opacity:1}
  57%  {transform:translate3d(5px,-51px,0) scale(1.06) rotate(254deg);opacity:1}
  73%  {transform:translate3d(42px,-34px,0) scale(.98) rotate(339deg);opacity:1}
  85%  {transform:translate3d(18px,-10px,0) scale(.94) rotate(376deg);opacity:1}
  93%  {transform:translate3d(-7px,-26px,0) scale(1.04) rotate(355deg);opacity:1}
  100% {transform:translate3d(0,-19px,0) scale(.98) rotate(360deg);opacity:1}
}
@media(prefers-reduced-motion:reduce){
  .stage.popped .pirate-figure{
    animation:none!important;will-change:auto;
    transform:translateY(-30px) scale(1)!important;opacity:1
  }
  .stage.popped .flight-effects,.stage.popped .launch-cloud,.stage.popped .barrel,.stage.popped .pop-burst {animation:none!important}
  .stage.popped .flight-effects,.stage.popped .launch-cloud,.stage.popped .pop-burst{display:none!important}
  .stage.popped .flight-spark,.stage.popped .flight-arc path{animation:none!important}
}

/* Keep the airborne arc within the stage at tablet breakpoints. */
@media (min-width:501px) and (max-width:850px) {
  .stage { --flight-apex:-52px; --flight-side:62px; }
}
.flight-spark-one{--spark-delay:0ms}
.flight-spark-two{--spark-delay:70ms}
.flight-spark-three{--spark-delay:95ms}
.flight-spark-four{--spark-delay:145ms}
.flight-spark-five{--spark-delay:180ms}
.flight-spark-six{--spark-delay:220ms}
.stage.popped .flight-spark{animation-delay:var(--spark-delay,0ms)}

/* Real WebGL toy. Keep the 2D board as a manual fallback on the same page. */
.pirate-3d-mount {
  position:absolute;inset:0;z-index:5;
  width:100%;height:100%;
  background:radial-gradient(ellipse at 50% 48%,#d8b0752e 0,transparent 65%);
}
.pirate-three-canvas{display:block;width:100%;height:100%;cursor:grab;touch-action:pan-y}
.pirate-three-canvas:active{cursor:grabbing}
.stage.is-3d .barrel,.stage.is-3d .pirate-figure,
.stage.is-3d .flight-effects,.stage.is-3d .launch-cloud,
.stage.is-3d .pop-burst,.stage.is-3d .stage-backlight{display:none!important}
.stage.is-3d .stage-marquee{z-index:8}
.stage.is-3d .stage-caption{z-index:9;pointer-events:none}
.view-toggle {
  position:absolute;right:26px;top:25px;z-index:12;
  min-height:39px;min-width:90px;border-radius:11px;
  border:1px solid #f5ce94a6;background:#0b2a3ba8;
  color:#ffdfaa;font-size:12px;font-weight:850;
  box-shadow:0 3px 10px #0004;
}
.view-toggle:hover{background:#22475ad9}
.view-toggle:focus-visible{outline:3px solid #ffe2a8}
.stage.is-3d{background:
  radial-gradient(ellipse at 52% 68%,#53788870 0,transparent 58%),
  linear-gradient(150deg,#23485d,#123145 72%,#0c2638)}
.stage.is-3d .star{opacity:.3}
.stage.is-3d .stage-marquee{left:38%;font-size:12px}
@media(max-width:500px){
  .stage.is-3d{min-height:575px}
  .stage.is-3d .stage-marquee{left:39%;top:18px;padding:6px 10px;font-size:10px}
  .view-toggle{right:18px;top:16px;min-width:72px;min-height:34px;font-size:11px}
}

/* Distant voyage finale: the sea and tiny island establish depth behind both renderers. */
.pirate-horizon{
  position:absolute;inset:0;z-index:0;pointer-events:none;
  background:
    radial-gradient(ellipse at 78% 13%,#ffdfa63b 0,transparent 31%),
    linear-gradient(180deg,transparent 0 42%,#a3d4c415 43%,#18566f35 45%,#123c5d62 75%,#10324618 100%);
}
.pirate-horizon::after{
  content:'';position:absolute;top:44%;left:0;right:0;height:2px;
  background:linear-gradient(90deg,transparent,#d3ead986 40%,#f9e5b5b5 65%,transparent);
  box-shadow:0 8px 16px #c6ecdf29;
}
.horizon-cloud{position:absolute;top:17%;width:94px;height:16px;background:#e4f2e442;border-radius:100%;filter:blur(6px)}
.horizon-cloud::after{content:'';position:absolute;left:23px;bottom:0;width:48px;height:31px;border-radius:50%;background:#d0e5df50}
.cloud-a{left:9%;transform:scale(.8)}.cloud-b{right:9%;top:12%;transform:scale(.48);opacity:.65}
.pirate-island{
  position:absolute;z-index:4;right:6%;top:32%;width:clamp(110px,25%,164px);height:108px;
  pointer-events:none;filter:drop-shadow(0 10px 8px #071e3070);
}
.pirate-island .island-shadow{position:absolute;left:4%;right:2%;bottom:4px;height:24px;border-radius:50%;background:#071f31a3;filter:blur(5px)}
.pirate-island .island-beach{position:absolute;left:3%;right:3%;bottom:12px;height:31px;border-radius:52% 45% 53% 50%;background:linear-gradient(#f7dba2,#cf9d61 62%,#8a6446);transform:rotate(-5deg);box-shadow:inset 0 5px 2px #fff0c679}
.pirate-island .island-grass{position:absolute;left:22%;right:15%;bottom:31px;height:28px;border-radius:55% 50% 24% 28%;background:linear-gradient(#91c587,#477960 65%,#315d50);transform:rotate(-4deg)}
.pirate-island .island-palm{position:absolute;left:49%;bottom:43px;width:8px;height:52px;border-radius:5px;background:linear-gradient(90deg,#593c31,#b47b4a,#63452c);transform:rotate(18deg);transform-origin:bottom center;box-shadow:2px 1px 0 #142b3330}
.pirate-island .island-palm::before,.pirate-island .island-palm::after,.pirate-island .island-palm b::before,.pirate-island .island-palm b::after{content:'';position:absolute;bottom:42px;left:2px;width:55px;height:16px;border-radius:100% 4% 100% 4%;background:linear-gradient(135deg,#a5cc79,#41785e 82%);transform-origin:4px 12px;box-shadow:0 2px 1px #18362f44}
.pirate-island .island-palm::before{transform:rotate(-36deg)}
.pirate-island .island-palm::after{transform:rotate(20deg)}
.pirate-island .island-palm b::before{transform:rotate(113deg) scale(.85)}
.pirate-island .island-palm b::after{transform:rotate(181deg) scale(.85)}
.pirate-island .island-flag{position:absolute;left:76%;bottom:39px;width:2px;height:34px;background:#f4dcc0;transform:rotate(-6deg)}
.pirate-island .island-flag::after{content:'☠';position:absolute;left:2px;top:-2px;width:24px;height:17px;display:grid;place-items:center;font-size:12px;font-style:normal;background:#263641;color:#f8e6bd;clip-path:polygon(0 0,100% 0,82% 50%,100% 100%,0 100%)}
.pirate-island .island-impact{position:absolute;left:29%;bottom:38px;width:64px;height:27px;border-radius:50%;opacity:0;background:radial-gradient(ellipse,#ffe7adf5 0%,#e7c78c99 31%,transparent 73%);filter:blur(2px)}
.stage.popped.flight-island .pirate-island .island-impact{animation:pirate-island-impact 1.05s 2.08s ease-out both}
.stage.popped.flight-island .pirate-island .island-palm{animation:pirate-palm-jolt .53s 2.19s ease-out both}
@keyframes pirate-island-impact{0%{opacity:0;transform:scale(.3)}18%{opacity:1;transform:scale(1.25)}100%{opacity:0;transform:scale(2.4)}}
@keyframes pirate-palm-jolt{0%,100%{transform:rotate(18deg)}33%{transform:rotate(29deg)}65%{transform:rotate(9deg)}}

/* 2D is a genuine departure, not the old short hop back into the barrel. */
.stage .pirate-figure{left:50%;margin-left:-117.5px;transform-origin:50% 64%}
.stage.popped.flight-island .pirate-figure{
  z-index:9;animation:pirate-voyage-island 2750ms linear both;will-change:transform,opacity;
}
.stage.popped.flight-escape .pirate-figure{
  z-index:9;animation:pirate-voyage-escape 2750ms linear both;will-change:transform,opacity;
}
@keyframes pirate-voyage-island{
  0%{opacity:0;transform:translate3d(0,170px,0) scale(.72) rotate(-8deg)}
  10%{opacity:1;transform:translate3d(0,82px,0) scale(.92) rotate(0deg)}
  25%{opacity:1;transform:translate3d(-24px,-95px,0) scale(1.04) rotate(85deg)}
  45%{opacity:1;transform:translate3d(calc(var(--flight-island-x,130px) * .35),-164px,0) scale(.80) rotate(250deg)}
  68%{opacity:1;transform:translate3d(calc(var(--flight-island-x,130px) * .78),-104px,0) scale(.43) rotate(545deg)}
  84%{opacity:1;transform:translate3d(var(--flight-island-x,130px),-47px,0) scale(.23) rotate(690deg)}
  92%{opacity:1;transform:translate3d(var(--flight-island-x,130px),46px,0) scale(.18) rotate(710deg)}
  96%{opacity:.9;transform:translate3d(var(--flight-island-x,130px),54px,0) scale(.16) rotate(722deg)}
  100%{opacity:0;transform:translate3d(var(--flight-island-x,130px),57px,0) scale(.12) rotate(730deg)}
}
@keyframes pirate-voyage-escape{
  0%{opacity:0;transform:translate3d(0,170px,0) scale(.72) rotate(-8deg)}
  10%{opacity:1;transform:translate3d(0,82px,0) scale(.92) rotate(0deg)}
  27%{opacity:1;transform:translate3d(-55px,-110px,0) scale(1.06) rotate(110deg)}
  50%{opacity:1;transform:translate3d(calc(var(--flight-escape-x,620px) * .24),-215px,0) scale(.73) rotate(355deg)}
  75%{opacity:1;transform:translate3d(calc(var(--flight-escape-x,620px) * .65),-223px,0) scale(.40) rotate(650deg)}
  93%{opacity:.95;transform:translate3d(var(--flight-escape-x,620px),-190px,0) scale(.26) rotate(830deg)}
  100%{opacity:0;transform:translate3d(calc(var(--flight-escape-x,620px) * 1.17),-176px,0) scale(.19) rotate(885deg)}
}
.stage.popped.flight-island .flight-path-escape,.stage.popped.flight-escape .flight-path-island{display:none}
.stage.popped :is(.flight-path-island,.flight-path-escape){animation-duration:2450ms}
.stage.popped .flight-effects{animation-duration:2750ms}
.stage.popped .pop-burst{animation-duration:1050ms}
@media(max-width:500px){
  .stage .pirate-figure{margin-left:-102.5px}
  .pirate-island{right:3%;top:31%;width:110px;transform:scale(.86);transform-origin:top right}
  .stage.popped.flight-island .pirate-figure{animation-name:pirate-voyage-island-mobile}
  .stage.popped.flight-escape .pirate-figure{animation-name:pirate-voyage-escape-mobile}
}
@keyframes pirate-voyage-island-mobile{
  0%{opacity:0;transform:translate3d(0,150px,0) scale(.74) rotate(-8deg)}
  11%{opacity:1;transform:translate3d(0,75px,0) scale(.93) rotate(0)}
  28%{opacity:1;transform:translate3d(-20px,-76px,0) scale(.97) rotate(105deg)}
  51%{opacity:1;transform:translate3d(calc(var(--flight-island-x,76px) * .48),-100px,0) scale(.65) rotate(320deg)}
  79%{opacity:1;transform:translate3d(var(--flight-island-x,76px),-45px,0) scale(.29) rotate(620deg)}
  92%{opacity:1;transform:translate3d(var(--flight-island-x,76px),40px,0) scale(.18) rotate(710deg)}
  100%{opacity:0;transform:translate3d(var(--flight-island-x,76px),50px,0) scale(.12) rotate(735deg)}
}
@keyframes pirate-voyage-escape-mobile{
  0%{opacity:0;transform:translate3d(0,150px,0) scale(.74) rotate(-8deg)}
  11%{opacity:1;transform:translate3d(0,75px,0) scale(.93) rotate(0)}
  29%{opacity:1;transform:translate3d(-25px,-70px,0) scale(.98) rotate(115deg)}
  52%{opacity:1;transform:translate3d(calc(var(--flight-escape-x,480px) * .26),-143px,0) scale(.7) rotate(350deg)}
  76%{opacity:1;transform:translate3d(calc(var(--flight-escape-x,480px) * .64),-154px,0) scale(.40) rotate(650deg)}
  100%{opacity:0;transform:translate3d(var(--flight-escape-x,480px),-142px,0) scale(.17) rotate(880deg)}
}
@media(prefers-reduced-motion:reduce){
  .stage.popped.flight-island .pirate-figure{
    animation:none!important;opacity:1;
    transform:translate3d(var(--flight-island-x,130px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)!important;
  }
  .stage.popped.flight-island .pirate-island .island-impact,
  .stage.popped.flight-island .pirate-island .island-palm{animation:none!important}
}

/* Cannon launch: the pirate blasts almost straight upward first, arcs toward
   the actual sand target, lands at 79%, rebounds, and stays visibly on land. */
.pirate-island .island-impact{left:20%;width:62px}
.stage.popped.flight-island .pirate-island .island-impact{animation-delay:2.12s}
.stage.popped.flight-island .pirate-island .island-palm{animation-delay:2.2s}
@keyframes pirate-voyage-island{
  0%{opacity:0;transform:translate3d(0,150px,0) scale(.73) rotate(-8deg)}
  9%{opacity:1;transform:translate3d(0,70px,0) scale(.95) rotate(-12deg)}
  20%{opacity:1;transform:translate3d(-8px,-88px,0) scale(1.03) rotate(20deg)}
  36%{opacity:1;transform:translate3d(5px,var(--flight-launch-height,-150px),0) scale(.83) rotate(145deg)}
  54%{opacity:1;transform:translate3d(calc(var(--flight-island-x,130px) * .36),calc(var(--flight-launch-height,-150px) * .98),0) scale(.64) rotate(275deg)}
  69%{opacity:1;transform:translate3d(calc(var(--flight-island-x,130px) * .79),calc(var(--flight-island-y,0px) - 78px),0) scale(.40) rotate(342deg)}
  79%{opacity:1;transform:translate3d(var(--flight-island-x,130px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)}
  85%{opacity:1;transform:translate3d(var(--flight-island-x,130px),calc(var(--flight-island-y,0px) - 28px),0) scale(.35) rotate(372deg)}
  93%{opacity:1;transform:translate3d(var(--flight-island-x,130px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)}
  100%{opacity:1;transform:translate3d(var(--flight-island-x,130px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)}
}
@keyframes pirate-voyage-island-mobile{
  0%{opacity:0;transform:translate3d(0,138px,0) scale(.73) rotate(-8deg)}
  10%{opacity:1;transform:translate3d(0,62px,0) scale(.9) rotate(-12deg)}
  22%{opacity:1;transform:translate3d(-5px,-66px,0) scale(.91) rotate(20deg)}
  37%{opacity:1;transform:translate3d(4px,var(--flight-launch-height,-128px),0) scale(.72) rotate(145deg)}
  56%{opacity:1;transform:translate3d(calc(var(--flight-island-x,90px) * .43),calc(var(--flight-launch-height,-128px) * .95),0) scale(.57) rotate(280deg)}
  70%{opacity:1;transform:translate3d(calc(var(--flight-island-x,90px) * .8),calc(var(--flight-island-y,0px) - 60px),0) scale(.40) rotate(345deg)}
  79%{opacity:1;transform:translate3d(var(--flight-island-x,90px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)}
  85%{opacity:1;transform:translate3d(var(--flight-island-x,90px),calc(var(--flight-island-y,0px) - 20px),0) scale(.35) rotate(372deg)}
  93%,100%{opacity:1;transform:translate3d(var(--flight-island-x,90px),var(--flight-island-y,0px),0) scale(.33) rotate(360deg)}
}
/* 3D uses the same springy cannon smoke rather than silently launching. */
.stage.is-3d .launch-cloud{display:block!important;z-index:8;bottom:53%}
.stage.is-3d .pop-burst{display:block!important;z-index:10;pointer-events:none}
.stage.is-3d.popped.flight-island .pirate-island{z-index:4}
@media(prefers-reduced-motion:reduce){
  .stage.is-3d .launch-cloud,.stage.is-3d .pop-burst{display:none!important}
}


/* Stabilize the island's coordinate system when the results panel appears. */
.game-grid>.stage {height:670px;min-height:670px;align-self:start}
@media(max-width:850px){.game-grid>.stage {height:600px;min-height:600px}}
@media(max-width:500px){.game-grid>.stage {height:575px;min-height:575px}}

/* Winner celebration occupies an overlay, so it cannot resize the scene. */
.pirate-rescue-banner[hidden]{display:none!important}
.pirate-rescue-banner {
  position:absolute;z-index:15;left:50%;bottom:81px;
  transform:translateX(-50%);width:min(90%,420px);
  pointer-events:none;text-align:center;color:#2b3535;
  padding:13px 17px 15px;border:2px solid #fff0b6;border-radius:15px;
  background:linear-gradient(135deg,#ffedb2,#e8af62 70%,#d48a4e);
  box-shadow:0 5px 0 #865529,0 12px 32px #030d1b9c,inset 0 1px #fff9df;
  animation:pirate-rescue-ribbon .65s cubic-bezier(.2,1.3,.3,1) both;
}
.pirate-rescue-banner::before,.pirate-rescue-banner::after {
  content:'✦';position:absolute;top:-23px;font-size:34px;color:#ffe49c;
  text-shadow:0 0 13px #f7cb75;animation:pirate-rescue-spark 1s ease-out both;
}
.pirate-rescue-banner::before{left:12%}
.pirate-rescue-banner::after{right:12%;animation-delay:.1s}
.pirate-rescue-kicker{display:block;font-size:12px;font-weight:900;letter-spacing:.04em;color:#76501d}
.pirate-rescue-banner strong{display:block;margin-top:4px;font-size:clamp(14px,2vw,20px);line-height:1.35;overflow-wrap:anywhere}
.result .rescue-result-headline{color:#68421f;font-weight:900}
.result .rescue-result-headline strong{display:block;color:#77411e;font-size:clamp(16px,2.5vw,22px)}
@keyframes pirate-rescue-ribbon{0%{opacity:0;transform:translate(-50%,23px) scale(.78)}65%{opacity:1;transform:translate(-50%,-4px) scale(1.035)}100%{opacity:1;transform:translate(-50%,0) scale(1)}}
@keyframes pirate-rescue-spark{0%{opacity:0;transform:translateY(13px) scale(.5) rotate(-20deg)}55%{opacity:1}100%{opacity:.9;transform:translateY(-13px) scale(1) rotate(22deg)}}
@media(max-width:500px){.pirate-rescue-banner{bottom:72px;padding:11px 10px 12px;width:calc(100% - 30px)}}
@media(prefers-reduced-motion:reduce){.pirate-rescue-banner,.pirate-rescue-banner::before,.pirate-rescue-banner::after{animation:none}}

/* Shared rescue overlay: exactly the same stage-top placement in 2D and 3D. */
.stage.rescue-complete .pirate-rescue-banner{
  top:77px;bottom:auto;z-index:30;
  width:min(91%,460px);max-width:calc(100% - 22px);
  padding:17px 19px 18px;
  color:#1d3340;
  background:linear-gradient(135deg,#fff3c6 0%,#f3c87b 54%,#e7a55c 100%);
  border:2px solid #fff7dd;
  box-shadow:0 0 0 4px #714a2c77,0 14px 35px #041b2cbb,inset 0 2px #fffdf1;
  animation:pirate-rescue-3d-reveal .44s cubic-bezier(.18,1.16,.38,1) both;
}
.stage.rescue-complete .pirate-rescue-kicker{
  color:#6b401c;font-size:14px;letter-spacing:.02em;line-height:1.4;
}
.stage.rescue-complete .pirate-rescue-banner strong{
  color:#16394a;font-size:clamp(17px,2.5vw,24px);
  line-height:1.45;font-weight:950;text-shadow:0 1px #fff5df;
}
.stage.rescue-complete .pop-burst{display:none!important}
@keyframes pirate-rescue-3d-reveal{
  0%{opacity:.93;transform:translate(-50%,13px) scale(.94)}
  100%{opacity:1;transform:translate(-50%,0) scale(1)}
}
@media(max-width:500px){
  .stage.rescue-complete .pirate-rescue-banner{
    top:66px;width:calc(100% - 24px);padding:12px 9px 13px;
  }
  .stage.rescue-complete .pirate-rescue-kicker{font-size:12px}
  .stage.rescue-complete .pirate-rescue-banner strong{font-size:16px}
}
@media(prefers-reduced-motion:reduce){
  .stage.rescue-complete .pirate-rescue-banner{animation:none}
}


/* Modern Pirate Arcade Cabinet Polish (2026-10-31):
   Adds live Barrel Tension/Danger HUD, color-coded Crew Roster cards,
   shuffle button, live Voyage Action Log, and richer 2D/3D nautical trim. */
.intro {
  background:
    radial-gradient(ellipse at 85% 22%, #ffe39f24 0%, transparent 54%),
    linear-gradient(135deg, #1b3b4b 0%, #122a38 62%, #0e222f 100%);
  border: 1.5px solid #d6b06f59;
  border-radius: 22px;
  padding: 22px 26px 24px;
  margin-bottom: 18px;
  box-shadow: 0 16px 34px #06162166, inset 0 1px 0 #ffe9b829;
}
.intro-tags span {
  font-weight: 750;
  padding: 7px 13px;
  box-shadow: inset 0 1px 0 #ffffff1f;
}
.ug-dice-style-roster .ug-dice-style-row.ug-participant-row {
  border-left: 5px solid var(--player-color, #eab86e) !important;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.ug-dice-style-roster .ug-dice-style-row.ug-participant-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px #182c341a;
}
.ug-dice-style-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.ug-dice-style-controls .ug-dice-style-shuffle {
  min-height: 44px;
  padding: 9px 15px;
  border-radius: 10px;
  border: 1px solid #b89860;
  background: linear-gradient(145deg, #fff8e6, #ead7b3);
  color: #28464e;
  font-size: 13px;
  font-weight: 850;
  box-shadow: 0 2px 0 #ab8c5840;
  transition: filter .15s ease, transform .15s ease;
}
.ug-dice-style-controls .ug-dice-style-shuffle:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}
.ug-dice-style-controls .ug-dice-style-shuffle:active {
  transform: translateY(1px);
}

/* Live Barrel Tension & Danger Gauge HUD */
.pirate-tension-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px 13px;
  margin-bottom: 13px;
  border-radius: 16px;
  border: 1.5px solid #d5b476;
  background: linear-gradient(135deg, #fff6df 0%, #eadbc0 100%);
  box-shadow: 0 8px 18px #081a2826, inset 0 1px 0 #fffdf7;
}
.tension-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.tension-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -.01em;
  background: #e3f1e6;
  color: #1f593c;
  border: 1px solid #9ec7a8;
}
.pirate-tension-bar[data-tension="warm"] .tension-badge {
  background: #fff2cc;
  color: #7c5211;
  border-color: #dfbe73;
}
.pirate-tension-bar[data-tension="high"] .tension-badge {
  background: #ffe3c7;
  color: #8f3d16;
  border-color: #e29d67;
}
.pirate-tension-bar[data-tension="critical"] .tension-badge,
.pirate-tension-bar[data-tension="popped"] .tension-badge {
  background: #ffd8d2;
  color: #8f221b;
  border-color: #dc7c72;
  animation: tension-pulse 1.1s ease-in-out infinite;
}
.tension-detail {
  font-size: 12px;
  font-weight: 800;
  color: #39555b;
  font-variant-numeric: tabular-nums;
}
.tension-track {
  position: relative;
  height: 11px;
  border-radius: 999px;
  background: #223d4926;
  overflow: hidden;
  box-shadow: inset 0 1px 3px #0c202938;
}
.tension-fill {
  height: 100%;
  width: var(--tension-pct, 6.25%);
  border-radius: 999px;
  background: linear-gradient(90deg, #3ba776 0%, #e7b54c 52%, #e06d3b 80%, #d4382d 100%);
  box-shadow: inset 0 1px 0 #ffffff66;
  transition: width .28s cubic-bezier(.22, .9, .3, 1);
}
@keyframes tension-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

/* Enhanced 2D Barrel Brass Rivets & Island Treasure Glow */
.metal-band::after {
  content: '';
  position: absolute;
  inset: 5px 14px;
  background: radial-gradient(circle, #fff3c9 0 3px, #604328 3.5px 4.5px, transparent 5px) 0 50% / 36px 10px repeat-x;
  opacity: .85;
  pointer-events: none;
}
.pirate-island::before {
  content: '🪙';
  position: absolute;
  left: 34%;
  bottom: 26px;
  z-index: 2;
  font-size: 13px;
  filter: drop-shadow(0 2px 3px #0008);
}

/* Live Voyage Action Log in Sidebar */
.pirate-log-box {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid #cfb892;
  background: #fbf2df;
}
.pirate-log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 850;
  color: #355055;
}
.pirate-log-head small {
  font-size: 11px;
  font-weight: 750;
  color: #657978;
}
.pirate-log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
}
.pirate-log-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 11.5px;
  background: #fffaf0;
  border: 1px solid #dfd0b4;
  color: #2f494d;
}
.pirate-log-list li.log-empty {
  color: #647876;
  justify-content: center;
  padding: 8px;
  font-style: italic;
}
.pirate-log-list li.is-pop {
  background: #ffe5d8;
  border-color: #d48b75;
  color: #7d2d1e;
  font-weight: 800;
}
.pirate-log-list .log-slot {
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--player-color, #eab86e);
  color: #1d3540;
  font-weight: 900;
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}
.pirate-log-list .log-copy {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 750;
}
.pirate-log-list .log-outcome {
  font-size: 11px;
  font-weight: 850;
  color: #2f6b55;
  white-space: nowrap;
}
.pirate-log-list li.is-pop .log-outcome {
  color: #9e2f1d;
}
@media(max-width:500px){
  .intro{padding:15px 14px 18px;border-radius:17px}
  .pirate-tension-bar{padding:10px 12px}
  .tension-badge,.tension-detail{font-size:11px}
}
@media(prefers-reduced-motion:reduce){
  .pirate-tension-bar[data-tension="critical"] .tension-badge,
  .pirate-tension-bar[data-tension="popped"] .tension-badge,
  .tension-fill{animation:none!important;transition:none!important}
}


/* 2D/3D Classic Pop-up Pirate Upgrade (2026-10-31 v2):
   - Vertical keyhole sword slits & hover preview daggers in 2D
   - On-stage 360° barrel spin & random-stab control dock
   - Deeper 2D pirate-in-barrel positioning & barrel rim hands */
.stage .pirate-figure {
  bottom: 325px;
  transform: translateY(96px) scale(.89) rotate(-3deg);
  transition: transform .22s ease;
}
.stage.is-safe .pirate-figure {
  animation: pirate-safe-flinch .34s ease-out;
}
@keyframes pirate-safe-flinch {
  0%, 100% { transform: translateY(96px) scale(.89) rotate(-3deg); }
  35% { transform: translateY(83px) scale(.92) rotate(3deg); }
  70% { transform: translateY(99px) scale(.88) rotate(-5deg); }
}
.barrel {
  transform: translateX(var(--barrel-shift-x, 0px));
  transition: transform .24s cubic-bezier(.2, .85, .3, 1);
}
/* Vertical keyhole sword slit inside each 2D slot button */
.slot::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 6px;
  height: 54%;
  inset: auto;
  transform: translate(-50%, -50%);
  border-radius: 3px;
  background: linear-gradient(180deg, #050a0e, #1a0e0a);
  border: 1px solid #d9a86c66;
  box-shadow: inset 0 1px 3px #000, 0 0 4px #0009;
  pointer-events: none;
}
/* Hovering an empty 2D slot previews the active player's colored dagger poised to stab! */
.slot:not(:disabled):not(.inserted):hover .sword {
  display: block;
  opacity: .84;
   --knife-color: var(--active-knife-color, #eab86e);
  transform: translate(-50%, -108%) rotate(-33deg) scale(.92);
  animation: sword-hover-bob .75s ease-in-out infinite alternate;
}
@keyframes sword-hover-bob {
  from { transform: translate(-50%, -112%) rotate(-33deg) scale(.92); }
  to   { transform: translate(-50%, -98%) rotate(-31deg) scale(.96); }
}

/* On-Stage Barrel Spin & Quick Stab Control Dock */
.stage-controls {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 5px 8px;
  border-radius: 999px;
  background: #081e2dd9;
  border: 1px solid #e7be7978;
  box-shadow: 0 6px 16px #03111b80, inset 0 1px 0 #fff4d124;
  backdrop-filter: blur(6px);
}
.stage-ctrl-btn {
  min-height: 32px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid #c69f6166;
  background: #173849e6;
  color: #f9e8c6;
  font-size: 11.5px;
  font-weight: 850;
  letter-spacing: -.01em;
  transition: background .15s ease, transform .12s ease, filter .15s ease;
}
.stage-ctrl-btn:hover:not(:disabled) {
  background: #255268;
  transform: translateY(-1px);
}
.stage-ctrl-btn:active:not(:disabled) {
  transform: translateY(1px);
}
.stage-ctrl-btn.is-accent {
  background: linear-gradient(135deg, #f3ca74, #d68d42);
  color: #1f2f38;
  border-color: #ffe5a3;
  box-shadow: 0 2px 0 #844f21;
}
.stage-ctrl-btn:disabled {
  opacity: .45;
}
.stage-caption {
  bottom: 12px;
  padding: 8px 13px;
  font-size: 12.5px;
}
@media(max-width:500px){
  .stage-controls {
    bottom: 49px;
    gap: 4px;
    padding: 4px 6px;
  }
  .stage-ctrl-btn {
    min-height: 28px;
    padding: 4px 8px;
    font-size: 10.5px;
  }
  .stage-caption {
    bottom: 8px;
    padding: 6px 9px;
    font-size: 11px;
  }
}
@media(prefers-reduced-motion:reduce){
  .slot:not(:disabled):not(.inserted):hover .sword,
  .stage.is-safe .pirate-figure {
    animation: none !important;
  }
}


/* Prevent 2D<->3D view toggling from re-triggering the pirate launch or
   safe-stab recoil animations after the pirate has already landed. */
.stage.popped:is(.landed,.rescue-complete) .pirate-figure {
  animation: none !important;
  will-change: auto;
  opacity: 1 !important;
  transform: translate3d(var(--flight-island-x,130px), var(--flight-island-y,0px), 0) scale(.33) rotate(360deg) !important;
}
.stage.popped:is(.landed,.rescue-complete) :is(.flight-effects,.launch-cloud,.pop-burst) {
  animation: none !important;
  opacity: 0 !important;
  display: none !important;
}
.stage.popped:is(.landed,.rescue-complete) :is(.barrel,.barrel-mouth,.pirate-island .island-impact,.pirate-island .island-palm) {
  animation: none !important;
}
.stage.popped:is(.landed,.rescue-complete) {
  animation: none !important;
}


/* Fix 2D Pirate Visibility in Barrel Mouth (2026-10-31 v4):
   Ensure `.pirate-figure` renders above `.barrel`'s drop-shadow stacking context
   (`z-index: 5`) and sits visibly in the open barrel mouth (`translateY(-76px)`)
   during normal play, safe stabs, and launch start. */
.stage .pirate-figure {
  z-index: 5;
  bottom: 331px;
  opacity: 1;
  transform: translate3d(var(--barrel-shift-x, 0px), -76px, 0) scale(.86) rotate(-2deg);
  transition: transform .2s cubic-bezier(.2, .85, .3, 1);
}
.stage.is-inserting .pirate-figure,
.stage.is-safe .pirate-figure {
  animation: pirate-safe-flinch .38s cubic-bezier(.2, .9, .3, 1);
}
@keyframes pirate-safe-flinch {
  0%   { transform: translate3d(var(--barrel-shift-x, 0px), -76px, 0) scale(.86) rotate(-2deg); }
  30%  { transform: translate3d(var(--barrel-shift-x, 0px), -94px, 0) scale(.91) rotate(5deg); }
  65%  { transform: translate3d(var(--barrel-shift-x, 0px), -70px, 0) scale(.85) rotate(-4deg); }
  100% { transform: translate3d(var(--barrel-shift-x, 0px), -76px, 0) scale(.86) rotate(-2deg); }
}
@keyframes pirate-voyage-island {
  0%   { opacity: 1; transform: translate3d(0, -76px, 0) scale(.86) rotate(-2deg); }
  9%   { opacity: 1; transform: translate3d(0, -62px, 0) scale(.93) rotate(-10deg); }
  20%  { opacity: 1; transform: translate3d(-8px, -112px, 0) scale(1.03) rotate(20deg); }
  36%  { opacity: 1; transform: translate3d(5px, var(--flight-launch-height, -150px), 0) scale(.83) rotate(145deg); }
  54%  { opacity: 1; transform: translate3d(calc(var(--flight-island-x, 130px) * .36), calc(var(--flight-launch-height, -150px) * .98), 0) scale(.64) rotate(275deg); }
  69%  { opacity: 1; transform: translate3d(calc(var(--flight-island-x, 130px) * .79), calc(var(--flight-island-y, 0px) - 78px), 0) scale(.40) rotate(342deg); }
  79%  { opacity: 1; transform: translate3d(var(--flight-island-x, 130px), var(--flight-island-y, 0px), 0) scale(.33) rotate(360deg); }
  85%  { opacity: 1; transform: translate3d(var(--flight-island-x, 130px), calc(var(--flight-island-y, 0px) - 28px), 0) scale(.35) rotate(372deg); }
  93%  { opacity: 1; transform: translate3d(var(--flight-island-x, 130px), var(--flight-island-y, 0px), 0) scale(.33) rotate(360deg); }
  100% { opacity: 1; transform: translate3d(var(--flight-island-x, 130px), var(--flight-island-y, 0px), 0) scale(.33) rotate(360deg); }
}
@keyframes pirate-voyage-island-mobile {
  0%   { opacity: 1; transform: translate3d(0, -64px, 0) scale(.84) rotate(-2deg); }
  10%  { opacity: 1; transform: translate3d(0, -52px, 0) scale(.90) rotate(-10deg); }
  22%  { opacity: 1; transform: translate3d(-5px, -88px, 0) scale(.91) rotate(20deg); }
  37%  { opacity: 1; transform: translate3d(4px, var(--flight-launch-height, -128px), 0) scale(.72) rotate(145deg); }
  56%  { opacity: 1; transform: translate3d(calc(var(--flight-island-x, 90px) * .43), calc(var(--flight-launch-height, -128px) * .95), 0) scale(.57) rotate(280deg); }
  70%  { opacity: 1; transform: translate3d(calc(var(--flight-island-x, 90px) * .8), calc(var(--flight-island-y, 0px) - 60px), 0) scale(.40) rotate(345deg); }
  79%  { opacity: 1; transform: translate3d(var(--flight-island-x, 90px), var(--flight-island-y, 0px), 0) scale(.33) rotate(360deg); }
  85%  { opacity: 1; transform: translate3d(var(--flight-island-x, 90px), calc(var(--flight-island-y, 0px) - 20px), 0) scale(.35) rotate(372deg); }
  93%, 100% { opacity: 1; transform: translate3d(var(--flight-island-x, 90px), var(--flight-island-y, 0px), 0) scale(.33) rotate(360deg); }
}
@media(max-width:500px){
  .stage .pirate-figure {
    bottom: 282px;
    transform: translate3d(var(--barrel-shift-x, 0px), -64px, 0) scale(.84) rotate(-2deg);
  }
}
@media(prefers-reduced-motion:reduce){
  .stage.is-inserting .pirate-figure,
  .stage.is-safe .pirate-figure {
    animation: none !important;
  }
}


/* Excitement & Arcade Spectacle Upgrade (2026-10-31 v5):
   - Animated Tension Gauge with shimmer, tick markers, and streak badge
   - Interactive Pirate Speech Bubble (#pirate-speech) with mood states
   - Near-Miss shockwave, 2D pirate sweat drops, barrel steam puffs & continuous danger tremble */
.tension-badges {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}
.streak-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 900;
  background: #fff2d6;
  color: #8c4c19;
  border: 1px solid #e0b873;
  font-variant-numeric: tabular-nums;
}
.tension-track {
  position: relative;
  height: 13px;
  border-radius: 999px;
  background: #1c354033;
  overflow: hidden;
  box-shadow: inset 0 1px 4px #091b2447;
}
.tension-fill {
  position: relative;
  height: 100%;
  width: var(--tension-pct, 6.25%);
  border-radius: 999px;
  background:
    repeating-linear-gradient(-45deg, #ffffff29 0 8px, transparent 8px 16px),
    linear-gradient(90deg, #35a875 0%, #eab543 48%, #e46936 78%, #d63028 100%);
  background-size: 24px 24px, 100% 100%;
  animation: tension-stripes 1.1s linear infinite;
  box-shadow: inset 0 1px 0 #ffffff80, 0 0 10px #e4783855;
  transition: width .32s cubic-bezier(.22, .9, .3, 1);
}
@keyframes tension-stripes {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 24px 0, 0 0; }
}
.tension-ticks {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: space-evenly;
  align-items: stretch;
  pointer-events: none;
}
.tension-ticks i {
  width: 1px;
  background: #ffffff66;
}
.pirate-tension-bar[data-tension="near-miss"] .tension-badge {
  background: #ffe0c2;
  color: #963212;
  border-color: #e48654;
}

/* Comic Pirate Speech Bubble on Stage */
.pirate-speech {
  position: absolute;
  z-index: 11;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 28px);
  padding: 7px 14px;
  border-radius: 999px;
  background: #fff9e8f2;
  color: #213a43;
  border: 2px solid #d7a656;
  box-shadow: 0 6px 16px #04152166, inset 0 1px 0 #ffffff;
  font-size: 12.5px;
  line-height: 1.35;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.2, 1.2, .3, 1), border-color .2s, background .2s;
}
.pirate-speech::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  width: 11px;
  height: 11px;
  background: inherit;
  border-right: 2px solid #d7a656;
  border-bottom: 2px solid #d7a656;
  transform: translateX(-50%) rotate(45deg);
}
.pirate-speech .speech-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: #224656;
  color: #ffe7b3;
  font-size: 10.5px;
  font-weight: 900;
  white-space: nowrap;
}
.pirate-speech strong {
  font-weight: 850;
  color: #1f3942;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pirate-speech[data-mood="near-miss"],
.pirate-speech[data-mood="critical"] {
  background: #fff0e6f5;
  border-color: #df6946;
  animation: speech-jolt .42s cubic-bezier(.2, 1.3, .3, 1);
}
.pirate-speech[data-mood="near-miss"]::after,
.pirate-speech[data-mood="critical"]::after {
  border-color: #df6946;
}
.pirate-speech[data-mood="near-miss"] .speech-tag,
.pirate-speech[data-mood="critical"] .speech-tag {
  background: #b83322;
  color: #fff3df;
}
.stage.rescue-complete .pirate-speech {
  opacity: 0;
  pointer-events: none;
}
@keyframes speech-jolt {
  0%   { transform: translateX(-50%) scale(.88); }
  45%  { transform: translateX(-50%) scale(1.07) rotate(-1.5deg); }
  100% { transform: translateX(-50%) scale(1) rotate(0); }
}

/* 2D Pirate Reactive Sweat Drops, Idle Bobbing & Tension Tremble */
.pirate-figure .pirate-sweat {
  opacity: 0;
  transition: opacity .2s ease;
}
.stage[data-danger="high"] .pirate-figure .pirate-sweat,
.stage[data-danger="critical"] .pirate-figure .pirate-sweat,
.stage[data-danger="near-miss"] .pirate-figure .pirate-sweat,
.stage.is-near-miss .pirate-figure .pirate-sweat {
  opacity: 1;
  animation: sweat-drip .85s ease-in-out infinite alternate;
}
@keyframes sweat-drip {
  from { transform: translateY(-2px); }
  to   { transform: translateY(4px); }
}
.stage[data-danger="high"]:not(.popped) .pirate-figure .pirate-eye-pupil,
.stage[data-danger="critical"]:not(.popped) .pirate-figure .pirate-eye-pupil,
.stage.is-near-miss:not(.popped) .pirate-figure .pirate-eye-pupil {
  transform: scale(.72);
  transform-origin: 149px 108px;
}
.stage[data-danger="critical"]:not(.popped) .barrel {
  animation: barrel-critical-rumble .28s ease-in-out infinite alternate;
}
@keyframes barrel-critical-rumble {
  from { transform: translateX(calc(var(--barrel-shift-x, 0px) - 1.5px)) rotate(-.4deg); }
  to   { transform: translateX(calc(var(--barrel-shift-x, 0px) + 1.5px)) rotate(.4deg); }
}
.stage.is-near-miss:not(.popped) .pirate-figure {
  animation: pirate-near-miss-jump .48s cubic-bezier(.18, 1.25, .32, 1);
}
@keyframes pirate-near-miss-jump {
  0%   { transform: translate3d(var(--barrel-shift-x, 0px), -76px, 0) scale(.86) rotate(-2deg); }
  32%  { transform: translate3d(var(--barrel-shift-x, 0px), -114px, 0) scale(.96) rotate(8deg); }
  68%  { transform: translate3d(var(--barrel-shift-x, 0px), -68px, 0) scale(.84) rotate(-6deg); }
  100% { transform: translate3d(var(--barrel-shift-x, 0px), -76px, 0) scale(.86) rotate(-2deg); }
}

/* Barrel Steam Puffs on High / Critical Danger */
.barrel-steam {
  position: absolute;
  z-index: 6;
  top: -28px;
  left: 50%;
  width: 170px;
  height: 45px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
}
.barrel-steam i {
  position: absolute;
  bottom: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8e6cc 0%, #ffd29944 65%, transparent 100%);
  animation: barrel-steam-rise 1.2s ease-out infinite;
}
.barrel-steam i:nth-child(1) { left: 12%; animation-delay: 0s; }
.barrel-steam i:nth-child(2) { left: 46%; animation-delay: .38s; }
.barrel-steam i:nth-child(3) { right: 12%; animation-delay: .72s; }
.stage[data-danger="high"]:not(.popped) .barrel-steam,
.stage[data-danger="critical"]:not(.popped) .barrel-steam,
.stage.is-near-miss:not(.popped) .barrel-steam {
  opacity: 1;
}
@keyframes barrel-steam-rise {
  0%   { opacity: 0; transform: translateY(6px) scale(.45); }
  35%  { opacity: .88; }
  100% { opacity: 0; transform: translateY(-28px) scale(1.35); }
}

/* 2D Slot Near-Miss Ring Glow & Sidebar Log Near-Miss Highlight */
.slot.inserted.near-miss {
  box-shadow: 0 0 0 3px #ff784780, inset 0 3px 9px #000a;
}
.pirate-log-list li.is-near {
  background: #fff1df;
  border-color: #df9458;
  color: #7c3516;
}
.pirate-log-list li.is-near .log-outcome {
  color: #b84218;
  font-weight: 900;
}
@media(max-width:500px){
  .pirate-speech {
    top: 56px;
    padding: 5px 10px;
    font-size: 11px;
    gap: 6px;
  }
  .pirate-speech .speech-tag {
    font-size: 9.5px;
    padding: 2px 6px;
  }
}
@media(prefers-reduced-motion:reduce){
  .tension-fill,
  .barrel-steam i,
  .stage[data-danger="critical"]:not(.popped) .barrel,
  .stage.is-near-miss:not(.popped) .pirate-figure,
  .pirate-speech[data-mood="near-miss"],
  .pirate-speech[data-mood="critical"] {
    animation: none !important;
  }
}
