:root{
  --green-d:#1B5E20; --green:#2E7D32; --green-m:#43A047; --green-l:#66BB6A;
  --yellow:#FFD54F; --gold:#FFC107; --orange:#FF9800; --orange-dd:#EF6C00;
  --ink:#3E2723; --soft:0 8px 22px rgba(0,0,0,.18);
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent;margin:0;padding:0}
html,body{height:100%;overflow:hidden}
body{font-family:'Mali',system-ui,sans-serif;background:#0d2b14;color:var(--ink);
  display:flex;align-items:center;justify-content:center;
  -webkit-user-select:none;user-select:none;-webkit-touch-callout:none;
  overscroll-behavior:none;touch-action:manipulation}
h1,h2,h3,.title-font{font-family:'Baloo Thai 2','Mali',sans-serif}

#app{position:relative;width:100%;height:100%;max-width:460px;max-height:920px;aspect-ratio:9/19.5;
  overflow:hidden;box-shadow:0 0 60px rgba(0,0,0,.5);
  background:#A9DDF6 url('bg.webp') center/cover no-repeat}
@media(min-width:481px){ #app{border-radius:34px} }
@media(max-width:480px){ #app{max-width:none;max-height:none;width:100vw;height:100vh;height:100dvh;aspect-ratio:auto;border-radius:0} }
.screen,.overlay{position:absolute;inset:0;display:flex;flex-direction:column}
.overlay{z-index:60;align-items:center;justify-content:center;padding:24px}
.hidden{display:none !important}
@keyframes pulse{0%,100%{transform:scale(1);opacity:1}50%{transform:scale(1.08);opacity:.8}}

/* ---------- background ---------- */
#bg{position:absolute;inset:0;z-index:0;overflow:hidden;pointer-events:none}
.sun{position:absolute;top:5%;right:12%;width:64px;height:64px;border-radius:50%;
  background:radial-gradient(circle at 40% 40%,#FFF7C2,#FFD54F 60%,#FFB300);
  box-shadow:0 0 50px 14px rgba(255,213,79,.5);animation:sunPulse 4s ease-in-out infinite}
@keyframes sunPulse{50%{transform:scale(1.07)}}
.cloud{position:absolute;background:#fff;border-radius:50px;opacity:.9}
.cloud:before,.cloud:after{content:"";position:absolute;background:#fff;border-radius:50%}
.c1{width:84px;height:24px;top:8%;left:-110px;animation:drift 28s linear infinite}
.c1:before{width:40px;height:40px;top:-18px;left:14px}.c1:after{width:30px;height:30px;top:-12px;left:46px}
.c2{width:64px;height:18px;top:15%;left:-90px;animation:drift 36s linear infinite 6s;transform:scale(.85)}
.c2:before{width:30px;height:30px;top:-14px;left:10px}.c2:after{width:24px;height:24px;top:-9px;left:36px}
@keyframes drift{to{left:120%}}
.hill{position:absolute;left:-5%;width:110%;border-radius:50% 50% 0 0}
.hill1{bottom:30%;height:34%;background:linear-gradient(180deg,#7CC47F,#5FB86C)}
.hill2{bottom:24%;height:30%;background:linear-gradient(180deg,#6BBE74,#4FAA5C);left:-25%;width:90%}
.firefly{position:absolute;width:5px;height:5px;border-radius:50%;background:#FFF59D;
  box-shadow:0 0 8px 3px rgba(255,241,118,.8);animation:fly 9s ease-in-out infinite}
@keyframes fly{0%,100%{transform:translate(0,0);opacity:.2}50%{transform:translate(18px,-22px);opacity:.9}}
.leaf{position:absolute;top:-30px;width:22px;height:22px;animation:fall linear infinite;opacity:.85}
.leaf svg{width:100%;height:100%;display:block}
.gflower{position:absolute;transform:translate(-50%,-50%);z-index:0;animation:sway 3.5s ease-in-out infinite;filter:drop-shadow(0 2px 1px rgba(0,0,0,.12))}
.gflower svg{width:100%;height:100%;display:block}
@keyframes sway{50%{transform:translate(-50%,-50%) rotate(8deg)}}
.hill,.sun,.gflower{display:none}
@keyframes fall{0%{transform:translateY(-30px) rotate(0)}100%{transform:translateY(105vh) rotate(360deg)}}

/* ---------- buttons ---------- */
.btn{font-family:'Baloo Thai 2',sans-serif;font-weight:800;color:#fff;border:none;cursor:pointer;
  padding:15px 24px;font-size:21px;border-radius:20px;position:relative;
  transition:transform .08s,box-shadow .08s;text-shadow:0 2px 2px rgba(0,0,0,.18);
  display:inline-flex;align-items:center;justify-content:center;gap:3px;touch-action:manipulation}
.btn:active{transform:translateY(4px);box-shadow:0 2px 0 rgba(0,0,0,.2)!important}
.btn-green{background:linear-gradient(180deg,#66BB6A,#43A047);box-shadow:0 6px 0 #2E7D32,var(--soft)}
.btn-orange{background:linear-gradient(180deg,#FFB74D,#FB8C00);box-shadow:0 6px 0 #E65100,var(--soft)}
.btn-gold{background:linear-gradient(180deg,#FFE082,#FFB300);box-shadow:0 6px 0 #FF8F00,var(--soft);color:#5D4037;text-shadow:0 1px 1px rgba(255,255,255,.4)}
.btn-yellow{background:linear-gradient(180deg,#FFE45C,#FFC21E);box-shadow:0 6px 0 #E08E00,0 8px 20px rgba(0,0,0,.18),0 0 16px rgba(255,210,60,.55);color:#7A4A00;text-shadow:0 1px 0 rgba(255,255,255,.55)}
.btn:disabled{filter:grayscale(.4) brightness(.92);cursor:default}
.btn-big{font-size:23px;padding:17px 26px;width:100%;max-width:340px}
.bic{width:1.1em;height:1.1em;margin-right:.3em;flex:0 0 auto}
.btn2{display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.1}
.btn2 b{font-weight:800}
.btn2 small{font-size:.62em;font-weight:700;letter-spacing:.5px;opacity:.95;margin-top:1px}
.pulse{animation:btnPulse 1.3s ease-in-out infinite}
@keyframes btnPulse{50%{transform:scale(1.045)}}

/* ---------- menu ---------- */
#menu{align-items:center;justify-content:center;z-index:10;text-align:center;padding:30px}
.logo-wrap{position:relative;margin-bottom:6px;animation:floaty 3.4s ease-in-out infinite}
@keyframes floaty{50%{transform:translateY(-12px)}}
#menu h1{font-size:clamp(40px,12.5vw,62px);line-height:1.1;color:#FFE357;
  text-shadow:-2px 0 #1B5E20,2px 0 #1B5E20,0 -2px #1B5E20,0 2px #1B5E20,-2px -2px #1B5E20,2px -2px #1B5E20,-2px 2px #1B5E20,2px 2px #1B5E20,0 6px 0 #2E7D32,0 11px 14px rgba(0,0,0,.42)}
.title-dice{display:inline-block;width:.95em;height:.95em;vertical-align:middle;margin-bottom:4px;filter:drop-shadow(0 3px 4px rgba(0,0,0,.3));animation:diceRoll3d 3.2s ease-in-out infinite}
@keyframes diceRoll3d{0%{transform:perspective(340px) rotateZ(0deg) rotateX(0deg) rotateY(0deg)}30%{transform:perspective(340px) rotateZ(140deg) rotateX(30deg) rotateY(-22deg)}60%{transform:perspective(340px) rotateZ(290deg) rotateX(-24deg) rotateY(24deg)}85%{transform:perspective(340px) rotateZ(355deg) rotateX(8deg) rotateY(-6deg)}100%{transform:perspective(340px) rotateZ(360deg) rotateX(0deg) rotateY(0deg)}}
.title-dice svg{width:100%;height:100%}
#menu .sub{display:inline-block;margin-top:8px;background:rgba(255,255,255,.92);color:var(--green);
  font-weight:700;padding:7px 20px;border-radius:30px;font-size:15px;box-shadow:var(--soft)}
.menu-char{width:128px;height:152px;margin:6px auto;animation:bobMenu 1.6s ease-in-out infinite}
.menu-char svg{width:100%;height:100%;filter:drop-shadow(0 6px 6px rgba(0,0,0,.25))}
@keyframes bobMenu{50%{transform:translateY(-10px) rotate(-3deg)}}
.menu-deco{position:absolute;width:36px;height:36px;animation:floaty 3s ease-in-out infinite}
.menu-deco svg{width:100%;height:100%}
.start-hint{margin-top:18px;color:#fff;font-weight:600;font-size:14.5px;line-height:1.6;text-shadow:0 1px 3px rgba(0,0,0,.5)}

/* ---------- game header ---------- */
#game{z-index:10}
.hud{display:flex;align-items:center;justify-content:space-between;padding:calc(10px + env(safe-area-inset-top)) 12px 4px;gap:8px;z-index:20}
.coin-box{display:flex;align-items:center;gap:6px;background:rgba(255,255,255,.94);
  padding:6px 16px 6px 8px;border-radius:30px;box-shadow:var(--soft);min-width:120px}
.coin-box .cico{width:30px;height:30px;flex:0 0 auto}
.coin-val{font-family:'Baloo Thai 2';font-weight:800;font-size:26px;color:#EF6C00;line-height:1}
.coin-unit{font-size:13px;color:#A1660A;font-weight:700;align-self:flex-end;margin-bottom:3px}
.stage-box{background:rgba(27,94,32,.92);color:#fff;padding:5px 12px;border-radius:16px;text-align:center;box-shadow:var(--soft)}
.stage-box .lab{font-size:10px;opacity:.85}
.stage-box .num{font-family:'Baloo Thai 2';font-weight:800;font-size:18px;line-height:1}
.icon-btn{width:40px;height:40px;border-radius:50%;border:none;background:rgba(255,255,255,.9);
  font-size:19px;cursor:pointer;box-shadow:var(--soft);display:flex;align-items:center;justify-content:center}
.icon-btn:active{transform:scale(.92)}

/* ---------- board ---------- */
#board{position:relative;flex:1;margin:2px 4px 0;overflow:hidden}
#trail{position:absolute;inset:0;width:100%;height:100%;z-index:1}
.node{position:absolute;transform:translate(-50%,-50%);z-index:2;display:flex;flex-direction:column;align-items:center}
.tile{width:40px;height:40px;border-radius:12px;display:flex;align-items:center;justify-content:center;
  background:linear-gradient(180deg,#FFF3D6,#FFE3A8);
  box-shadow:0 4px 0 #C9A24B,0 5px 8px rgba(0,0,0,.22);border:3px solid #fff;transition:transform .2s}
.tile svg{width:66%;height:66%;display:block;filter:drop-shadow(0 1px 1px rgba(0,0,0,.18))}
.tile.bomb-tile{background:linear-gradient(180deg,#FFCDD2,#EF9A9A);box-shadow:0 4px 0 #C62828,0 5px 8px rgba(0,0,0,.22)}
.node.start .tile{background:linear-gradient(180deg,#BBDEFB,#64B5F6);box-shadow:0 4px 0 #1565C0,0 5px 8px rgba(0,0,0,.22)}
.node.jackpot .tile{background:linear-gradient(180deg,#FFE082,#FFB300);box-shadow:0 4px 0 #FF8F00,0 0 18px 4px rgba(255,193,7,.7);border-color:#FFF}
.node.reached .tile{filter:brightness(.94) saturate(.85)}
.node.current .tile{transform:scale(1.18);animation:tilePop 1.1s ease-in-out infinite;z-index:3}
@keyframes tilePop{50%{transform:scale(1.3)}}
.node .pr{margin-top:2px;background:rgba(27,94,32,.92);color:#FFE082;font-weight:800;font-size:11px;
  padding:0 7px;border-radius:11px;font-family:'Baloo Thai 2';white-space:nowrap;box-shadow:0 2px 0 rgba(0,0,0,.18);line-height:1.5}
.node.jackpot .pr{background:#EF6C00;color:#fff}
.node.start .pr{background:#1565C0;color:#fff;font-size:10px}

#charLayer{position:absolute;inset:0;z-index:4;pointer-events:none}
#explorer{position:absolute;width:38px;height:46px;transform:translate(-50%,-68%);
  transition:left .24s ease-in-out,top .24s ease-in-out;filter:drop-shadow(0 5px 4px rgba(0,0,0,.3))}
#explorer .ex-flip{transition:transform .12s}
#explorer.idle{animation:idleBob 2.4s ease-in-out infinite}
@keyframes idleBob{50%{transform:translate(-50%,-72%)}}
#explorer.running{animation:runBob .22s ease-in-out infinite}
@keyframes runBob{50%{transform:translate(-50%,-74%)}}
.leg,.arm{transform-box:fill-box;transform-origin:top center}
#explorer.running .leg-l{animation:stepA .22s infinite}
#explorer.running .leg-r{animation:stepB .22s infinite}
#explorer.running .arm-l{animation:stepB .22s infinite}
#explorer.running .arm-r{animation:stepA .22s infinite}
@keyframes stepA{0%,100%{transform:rotate(26deg)}50%{transform:rotate(-26deg)}}
@keyframes stepB{0%,100%{transform:rotate(-26deg)}50%{transform:rotate(26deg)}}
.dust{position:absolute;width:9px;height:9px;border-radius:50%;background:rgba(215,184,153,.9);z-index:3;animation:dustPop .6s ease-out forwards}
@keyframes dustPop{0%{transform:scale(.4);opacity:.9}100%{transform:scale(1.6) translateY(8px);opacity:0}}

#board.suspense{animation:shake .26s linear infinite}
@keyframes shake{0%,100%{transform:translate(0,0)}25%{transform:translate(-4px,2px)}50%{transform:translate(5px,-2px)}75%{transform:translate(-3px,3px)}}

/* ---------- footer ---------- */
.footer{padding:4px 14px calc(14px + env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:center;gap:8px;z-index:20}
.dice-stage{height:68px;display:flex;align-items:center;justify-content:center}
.die{width:58px;height:58px;background:linear-gradient(145deg,#fff,#F1F1F1);border-radius:15px;
  box-shadow:0 6px 0 #C9C9C9,0 10px 14px rgba(0,0,0,.25);position:relative;
  display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);padding:10px;gap:2px}
.die .pip{width:9px;height:9px;border-radius:50%;background:#37474F;align-self:center;justify-self:center;visibility:hidden;box-shadow:inset 0 -1px 1px rgba(0,0,0,.3)}
.die.rolling{animation:diceRoll .5s ease-in-out infinite}
@keyframes diceRoll{0%{transform:translateY(0) rotate(0)}25%{transform:translateY(-24px) rotate(160deg)}50%{transform:translateY(0) rotate(360deg)}75%{transform:translateY(-12px) rotate(520deg)}100%{transform:translateY(0) rotate(720deg)}}
.die.settle{animation:diceSettle .4s cubic-bezier(.34,1.56,.64,1)}
@keyframes diceSettle{0%{transform:scale(1.25)}60%{transform:scale(.9)}100%{transform:scale(1)}}
#actionRow{display:flex;gap:10px;width:100%;max-width:360px;justify-content:center}
#actionRow .btn-big{max-width:none;flex:1;font-size:21px;padding:16px 12px}

/* ---------- overlays ---------- */
.overlay{background:rgba(8,20,10,.55);backdrop-filter:blur(2px)}
.card{background:linear-gradient(180deg,#FFFDF5,#FFF1D6);border-radius:30px;padding:26px 22px;width:100%;max-width:340px;
  text-align:center;box-shadow:0 18px 50px rgba(0,0,0,.4);border:4px solid #fff;position:relative;animation:cardIn .45s cubic-bezier(.34,1.56,.64,1)}
@keyframes cardIn{0%{transform:scale(.5) translateY(40px);opacity:0}100%{transform:scale(1) translateY(0);opacity:1}}
.card .ribbon{position:absolute;top:-18px;left:50%;transform:translateX(-50%);background:linear-gradient(180deg,#66BB6A,#388E3C);
  color:#fff;font-family:'Baloo Thai 2';font-weight:800;padding:7px 22px;border-radius:30px;font-size:16px;box-shadow:0 5px 0 #1B5E20;white-space:nowrap}
.btn-row{display:flex;flex-direction:column;gap:11px;margin-top:16px}
.big-emoji{animation:revealPop .5s cubic-bezier(.34,1.8,.64,1)}
.big-emoji svg{width:104px;height:104px;display:inline-block;filter:drop-shadow(0 4px 5px rgba(0,0,0,.2))}
@keyframes revealPop{0%{transform:scale(0) rotate(-30deg)}70%{transform:scale(1.25) rotate(8deg)}100%{transform:scale(1) rotate(0)}}
.fail-card{background:linear-gradient(180deg,#FFF1F0,#FFE0DD)}
.fail-card .ribbon{background:linear-gradient(180deg,#EF5350,#C62828);box-shadow:0 5px 0 #8E1A14}
.fail-title{font-family:'Baloo Thai 2';font-weight:800;font-size:30px;color:#C62828;margin-top:6px}
.fail-sub{color:#8D6E63;font-size:15px;margin:8px 0 4px;line-height:1.5}
.fail-lost{font-family:'Baloo Thai 2';font-weight:800;font-size:34px;color:#B71C1C;margin:6px 0}
.win-card{background:linear-gradient(180deg,#FFFDF0,#FFF3CC)}
.win-card .ribbon{background:linear-gradient(180deg,#FFCA28,#FF8F00);color:#fff;box-shadow:0 5px 0 #E65100}
.win-title{font-family:'Baloo Thai 2';font-weight:800;font-size:28px;color:#EF6C00;margin-top:4px}
.win-amt{font-family:'Baloo Thai 2';font-weight:800;font-size:62px;color:#F57F17;margin:2px 0;line-height:1;text-shadow:0 4px 0 #FFD54F}
.win-amt small{font-size:26px;color:#FB8C00}
.total-line{font-size:15px;color:#5D4037;font-weight:600;margin-bottom:4px}
.total-line b{color:#EF6C00;font-family:'Baloo Thai 2'}
.glow{box-shadow:0 18px 50px rgba(0,0,0,.4),0 0 40px 6px rgba(255,193,7,.7)!important;border-color:#FFE082!important}
.cp-icon{margin:8px 0 0;animation:revealPop .4s cubic-bezier(.34,1.8,.64,1)}
.cp-icon svg{width:60px;height:60px;display:inline-block;filter:drop-shadow(0 3px 4px rgba(0,0,0,.18))}
.cp-amt{font-family:'Baloo Thai 2';font-weight:800;font-size:46px;color:#EF6C00;line-height:1;margin:6px 0 2px;text-shadow:0 3px 0 #FFD54F}
.cp-amt small{font-size:22px;color:#FB8C00}
.cp-hint{font-size:13px;color:#8D6E63;line-height:1.5;margin:8px 4px 0}
.close-x{position:absolute;top:-14px;right:-12px;width:38px;height:38px;border-radius:50%;border:3px solid #fff;background:#EF5350;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 0 #C62828;z-index:2}
.close-x svg{width:18px;height:18px}
.close-x:active{transform:translateY(3px);box-shadow:0 1px 0 #C62828}
.daily-note{margin-top:16px;font-family:'Baloo Thai 2';font-weight:800;font-size:17px;line-height:1.4}
.win-card .daily-note{color:#B26A00}
.fail-card .daily-note{color:#B71C1C}

#fx{position:absolute;inset:0;z-index:70;pointer-events:none;overflow:hidden}
.coin{position:absolute;width:24px;height:24px;border-radius:50%;
  background:radial-gradient(circle at 38% 32%,#FFF3B0,#FFC107 62%,#FF8F00);
  box-shadow:inset 0 -2px 3px rgba(0,0,0,.25),0 2px 4px rgba(0,0,0,.2)}
.coin:after{content:"";position:absolute;inset:30% 34%;border-radius:50%;background:rgba(255,255,255,.5)}
.confetti{position:absolute;width:11px;height:16px;border-radius:2px;top:-20px}
.spark{position:absolute;animation:sparkle 1s ease-out forwards}
.spark svg{width:18px;height:18px;display:block}
@keyframes sparkle{0%{transform:scale(0) rotate(0);opacity:1}100%{transform:scale(1.4) rotate(90deg);opacity:0}}
.gain{position:absolute;z-index:6;font-family:'Baloo Thai 2';font-weight:800;font-size:26px;
  color:#FFEB3B;text-shadow:0 2px 0 #E65100,0 3px 5px rgba(0,0,0,.4);pointer-events:none;animation:gainUp 1.1s ease-out forwards}
@keyframes gainUp{0%{transform:translate(-50%,0) scale(.5);opacity:0}25%{opacity:1;transform:translate(-50%,-22px) scale(1.15)}100%{transform:translate(-50%,-72px) scale(1);opacity:0}}
.boom{position:absolute;z-index:6;border-radius:50%;border:7px solid #FF7043;transform:translate(-50%,-50%);pointer-events:none;animation:boomRing .55s ease-out forwards}
@keyframes boomRing{0%{width:14px;height:14px;opacity:.95}100%{width:190px;height:190px;opacity:0}}

/* ---------- mobile: landscape rotate hint ---------- */
#rotate{display:none}
@media (orientation:landscape) and (max-height:500px){
  #rotate{display:flex;position:fixed;inset:0;z-index:999;background:linear-gradient(180deg,#43A047,#1B5E20);
    color:#fff;flex-direction:column;align-items:center;justify-content:center;text-align:center;gap:14px;padding:24px}
  #rotate .ph{width:72px;height:72px;animation:rotatePh 1.8s ease-in-out infinite}
  #rotate h2{font-family:'Baloo Thai 2';font-weight:800;font-size:23px}
  #rotate p{font-size:15px;opacity:.9}
}
@keyframes rotatePh{0%,15%{transform:rotate(0)}55%,100%{transform:rotate(-90deg)}}
