:root{font-family:system-ui,-apple-system,"Segoe UI",sans-serif;color:#eaf2ff;background:#0d1728}
*{box-sizing:border-box}body{margin:0;min-height:100vh;background:radial-gradient(circle at 50% -10%,#284466,#0d1728 55%)}
header{height:58px;display:flex;align-items:center;justify-content:space-between;padding:0 18px;border-bottom:1px solid #31435b;background:#101c30}
.brand{font-weight:900;letter-spacing:1px}.brand b{color:#f6c453}.pill{font-size:12px;background:#25364d;border-radius:20px;padding:6px 10px;color:#c9d8eb}
main{max-width:1100px;margin:22px auto;padding:0 14px}.panel{max-width:520px;margin:28px auto;background:#17263b;border:1px solid #334963;border-radius:20px;padding:24px;box-shadow:0 18px 50px #0005;text-align:center}
.hero{font-size:54px}h1{margin:8px 0;color:#ffd66b}p{color:#b6c7dc}label{display:block;text-align:left;margin:14px 0 6px;color:#c9d8eb}
input{width:100%;padding:13px;border-radius:10px;border:1px solid #526982;background:#0e1a2b;color:white;font-size:16px;margin-bottom:10px}
button{border:1px solid #526982;background:#263c57;color:#fff;padding:12px 16px;border-radius:11px;font-weight:700;font-size:15px;cursor:pointer;touch-action:manipulation}
button:active{transform:scale(.97)}.primary{background:linear-gradient(135deg,#f7c64d,#e9952c);color:#1b2431;border:0;width:100%;margin:8px 0}
.or{margin:12px;color:#91a5bd}.error{color:#ff9292;min-height:22px;margin-top:8px}small{color:#9db0c8}footer{text-align:center;color:#60748e;padding:24px;font-size:12px}
.hidden{display:none!important}.roomline{display:flex;justify-content:space-between;align-items:center;background:#0f1c2e;padding:12px;border-radius:12px}.roomline strong{display:block;font-size:28px;letter-spacing:5px;color:#ffd66b}.small{padding:8px 10px;font-size:12px}.playerchips{display:flex;flex-wrap:wrap;gap:7px;justify-content:center;margin:15px 0}.chip{background:#253a54;padding:7px 10px;border-radius:18px;font-size:13px}
#game{width:100%}.hud{display:flex;gap:10px;align-items:center;justify-content:space-between;background:#17263b;padding:10px 14px;border-radius:14px;margin-bottom:12px}.hud div{display:flex;flex-direction:column}.hud b{font-size:20px;color:#ffd66b}.gamegrid{display:grid;grid-template-columns:minmax(0,1fr) 190px;gap:12px}.canvaswrap{position:relative;min-width:0;background:#152238;border:1px solid #3b526e;border-radius:14px;overflow:hidden}
canvas{display:block;width:100%;height:auto;image-rendering:pixelated;touch-action:none}aside{background:#17263b;border-radius:14px;padding:12px;min-width:0}aside h3{margin:3px 0 10px}ol{padding-left:25px;margin:0}li{padding:5px 0;color:#d7e5f6;font-size:13px}.legend{border-top:1px solid #344963;margin-top:12px;padding-top:10px;line-height:1.9;color:#a9bdd4;font-size:13px}
.controls{display:flex;justify-content:space-between;align-items:center;gap:15px;padding:12px;background:#17263b;border-radius:14px;margin-top:12px}.dpad{display:flex;flex-direction:column;align-items:center;gap:4px}.dpad>div{display:flex;gap:4px}.dpad button{width:48px;height:43px;padding:0;font-size:20px;background:#304968}.actions{display:flex;gap:7px;flex-wrap:wrap;justify-content:flex-end}.action{min-width:60px;display:flex;flex-direction:column;align-items:center;font-size:20px;padding:7px}.action span{font-size:10px;margin-top:3px}.dig{background:#b77724;border-color:#e8b14a}
#toast{position:absolute;top:10px;left:50%;transform:translateX(-50%);background:#07111edc;color:#ffdf85;padding:8px 14px;border-radius:20px;opacity:0;pointer-events:none;white-space:nowrap;transition:opacity .2s}
@media(max-width:700px){main{margin:10px auto;padding:0 8px}.panel{margin:12px auto;padding:19px}.gamegrid{grid-template-columns:1fr}aside{display:grid;grid-template-columns:1fr 1fr;gap:8px}aside h3{grid-column:1/-1}aside ol{max-height:110px;overflow:auto}.legend{margin:0;border:0;padding:0}.hud{gap:6px;padding:8px}.hud b{font-size:17px}.hud .small{padding:7px}.controls{align-items:center;padding:8px;gap:5px}.dpad button{width:39px;height:38px}.actions{gap:4px}.action{min-width:47px;padding:6px 4px;font-size:18px}.action span{font-size:9px}}
@media(orientation:portrait) and (max-width:700px){.canvaswrap{max-height:55vh;overflow:hidden}canvas{width:100%}}

.teacher-settings{margin:18px auto;padding:14px;text-align:left;background:#102036;border:1px solid #3b526e;border-radius:13px}.teacher-settings h3{margin:0 0 8px}.teacher-settings select{width:100%;padding:11px;border-radius:9px;background:#0e1a2b;color:#fff;border:1px solid #526982;font-size:15px;margin-bottom:7px}.teacher-settings button{width:100%;margin-top:8px}

.checkrow{display:flex;align-items:center;gap:8px;margin:12px 0;color:#d8e7f7}.checkrow input{width:auto;margin:0}.quizbox{position:fixed;z-index:20;left:50%;top:50%;transform:translate(-50%,-50%);width:min(92vw,480px);padding:22px;background:#17263b;border:2px solid #f6c453;border-radius:18px;box-shadow:0 20px 80px #000b;text-align:center}.quizbox h2{color:#ffd66b;margin-top:0}.quizbox p{font-size:19px;color:#fff;font-weight:700}.quizoptions{display:grid;grid-template-columns:1fr 1fr;gap:9px;margin:16px 0}.quizoptions button{min-height:52px}.quizoptions button:disabled{opacity:.55}
.teamboard{display:flex;flex-wrap:wrap;gap:7px;margin:8px 0 14px}.teamchip{border:1px solid var(--team);border-left:5px solid var(--team);border-radius:9px;padding:7px 10px;font-size:.9rem;background:#18283b}.teamrank{padding-left:25px}.teamrank li{margin:6px 0}.teamrank small{display:block;color:#9fb0c5;font-size:.75rem}.mission{margin:12px 0;padding:10px;border:1px solid #43546a;border-radius:10px;background:#17283b}.missionbar{height:9px;background:#34465b;border-radius:10px;margin:8px 0;overflow:hidden}.missionbar span{display:block;height:100%;background:#facc15;border-radius:10px;transition:width .2s}.chip{margin:3px}

.eventpanel{padding:9px;margin:0 0 10px;border:1px solid #455b75;border-radius:10px;background:#102036;color:#b9c9dc;font-size:12px;font-weight:700}.eventpanel.active{background:#3b2b16;border-color:#f6c453;color:#ffdf85}

#powerShop{display:grid;gap:7px}#powerShop button{width:100%;font-size:12px;padding:8px}#powerShop button:disabled{opacity:.45;cursor:not-allowed}

/* Phase 10: visual polish, motion feedback and responsive HUD */
:root{--gold:#ffd66b;--panel:#17263b;--panel-edge:#3b526e}
html{scroll-behavior:smooth}
button{transition:transform .12s ease,filter .15s ease,box-shadow .15s ease,border-color .15s ease}
button:hover{filter:brightness(1.12);box-shadow:0 5px 16px #0004}
button:focus-visible,input:focus-visible,select:focus-visible{outline:3px solid #7ce8ff;outline-offset:2px}
.panel,.hud,.canvaswrap,aside,.controls{box-shadow:0 10px 28px #0002}
.panel{animation:panel-enter .35s ease both}
.hero{display:inline-block;animation:hero-float 2.8s ease-in-out infinite}
.brand{font-size:15px}
.hud{position:relative;border:1px solid #344963}
.hud>div{min-width:0;padding:3px 8px;border-left:1px solid #344963}
.hud>div:first-child{border-left:0}
#myScore{transition:color .2s ease,transform .2s ease}
#timeLeft{font-variant-numeric:tabular-nums}
#myRank{color:#7ce8ff}
.eventpanel,.mission{transition:background .2s ease,border-color .2s ease,transform .2s ease}
.eventpanel.active{animation:event-glow 1.8s ease-in-out infinite}
.missionbar span{box-shadow:0 0 10px #facc1580}
.action{position:relative;overflow:hidden}
.action:active{transform:translateY(2px) scale(.95)}
.action:focus-visible{outline:2px solid #ffd66b;outline-offset:2px}
.dig{box-shadow:inset 0 -3px #0003}
#toast{z-index:5;max-width:calc(100% - 24px);overflow:hidden;text-overflow:ellipsis;box-shadow:0 5px 20px #0006}
#toast[style*="opacity: 1"]{animation:toast-pop .22s ease-out}
#quizBox{animation:quiz-enter .22s ease-out}
#leaderboard li:first-child,#teamLeaderboard li:first-child{color:#ffe08a;font-weight:800}
#leaderboard li,#teamLeaderboard li{border-bottom:1px solid #ffffff0b}
#powerShop{border-color:#806a35;background:linear-gradient(145deg,#26334a,#17283b)}
#crystalCount{color:#8deaff;font-weight:800}
.controls{border:1px solid #344963}
.canvaswrap{border-color:#526982}

@keyframes panel-enter{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@keyframes hero-float{0%,100%{transform:translateY(0)}50%{transform:translateY(-5px)}}
@keyframes event-glow{0%,100%{box-shadow:0 0 0 #f6c45300}50%{box-shadow:0 0 16px #f6c45335}}
@keyframes toast-pop{from{transform:translate(-50%,-7px);opacity:0}to{transform:translate(-50%,0);opacity:1}}
@keyframes quiz-enter{from{opacity:0;transform:translate(-50%,-46%)}to{opacity:1;transform:translate(-50%,-50%)}}

@media(max-width:700px){
  header{height:52px;padding:0 12px}
  main{margin:8px auto}
  .hud{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:4px}
  .hud>div{padding:3px 5px}
  .hud>button{min-height:34px}
  .gamegrid{gap:8px}
  aside{border:1px solid #344963;padding:9px}
  .controls{position:sticky;bottom:6px;z-index:8;box-shadow:0 8px 28px #0009}
  .actions{display:grid;grid-template-columns:repeat(4,minmax(42px,1fr));flex:1}
  .action{min-width:0;min-height:48px}
  .action span{white-space:nowrap}
  .dpad{flex-shrink:0}
}
@media(max-width:380px){
  .hud{grid-template-columns:repeat(3,minmax(0,1fr))}
  .hud b{font-size:15px}
  .hud .small{font-size:10px;padding:6px}
  .controls{align-items:flex-start}
  .actions{grid-template-columns:repeat(2,minmax(48px,1fr))}
  .dpad button{width:34px;height:34px}
}
@media(prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.01ms!important}
}
@keyframes score-pop{0%{transform:scale(1);color:#ffd66b}45%{transform:scale(1.22);color:#7ce8ff}100%{transform:scale(1);color:#ffd66b}}
#myScore.score-pop{animation:score-pop .32s ease-out}

.achievement-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;margin-top:8px}.achievement-badge{border:1px solid #64748b55;border-radius:10px;padding:7px;background:#17243a;font-size:.78rem}.achievement-badge .badge-icon{font-size:1.25rem;display:block}.achievement-badge.locked{opacity:.42;filter:grayscale(1)}.achievement-badge small{display:block;color:#aab8ca;font-size:.68rem}

/* Phase 15 — Colorful Cartoon art direction */
:root{--gold:#ffe078;--panel:#203650;--panel-edge:#587a98}
body{background:radial-gradient(ellipse at 15% 0%,#355b78 0%,#1b3048 48%,#122338 100%);color:#f6fbff}
header{background:linear-gradient(90deg,#172b43,#254968 55%,#172b43);border-bottom:2px solid #f4c95d;box-shadow:0 5px 22px #07152588}
.brand{font-size:17px;text-shadow:0 2px 0 #102136}.brand b{color:#ffe078}
.panel,aside,.hud,.controls{background:linear-gradient(150deg,#294765,#1b3049);border:1px solid #6283a0;box-shadow:0 12px 28px #07152566,inset 0 1px #ffffff12}
.panel{border-radius:24px}.panel h1{color:#ffe078;text-shadow:0 2px 0 #80531e}.hero{filter:drop-shadow(0 6px 4px #07152577)}
button{background:linear-gradient(180deg,#426789,#2a4867);border:1px solid #789bb8;box-shadow:0 4px 0 #142a40,0 6px 12px #07152544}
button.primary{background:linear-gradient(180deg,#ffe27c,#f4a83c);border:1px solid #fff0ad;box-shadow:0 4px 0 #a75b21,0 7px 15px #07152555;color:#493016}
button.dig{background:linear-gradient(180deg,#ffc75a,#dc852b);border-color:#ffe19a;box-shadow:inset 0 -3px #9d541f,0 4px 0 #653b22}
input,.teacher-settings select{background:#12283d;border:1px solid #7895ad;box-shadow:inset 0 2px 5px #06162666}
.hud{border-radius:16px}.hud b{color:#ffe078;text-shadow:0 2px 0 #6e4a25}
.canvaswrap{border:2px solid #789bb8;border-radius:18px;background:#203a52;box-shadow:0 12px 25px #07152577}
canvas{image-rendering:auto}
aside{border-radius:18px}aside h3{color:#ffe49a;text-shadow:0 1px 0 #704b25}
.mission,.eventpanel{background:linear-gradient(145deg,#203d58,#172d45);border-color:#587b98;border-radius:13px}
.eventpanel.active{background:linear-gradient(135deg,#785222,#4e381e);border-color:#ffdc78;color:#fff0b8}
.achievement-badge{background:linear-gradient(145deg,#34526c,#20384f);border-color:#7695ad;border-radius:13px;box-shadow:inset 0 1px #ffffff12}
.achievement-badge.locked{filter:grayscale(.8);opacity:.5}
#powerShop{background:linear-gradient(145deg,#38536b,#263d55);border-color:#d3a94e}
#toast{background:linear-gradient(135deg,#203b54f2,#10243af2);border:1px solid #ffe078;color:#fff0b2;font-weight:800}
#quizBox{background:linear-gradient(145deg,#294966,#172d45);border:2px solid #ffe078}
#quizBox h2{color:#ffe078}
footer{color:#9eb8cf}
@media(max-width:700px){.canvaswrap{border-radius:13px}.controls{border-radius:14px}}


/* Phase 16 — responsive mining feedback and lightweight game feel */
.dig-swing{animation:dig-swing .22s ease-out!important}
@keyframes dig-swing{0%{transform:rotate(0) scale(1)}35%{transform:rotate(-8deg) scale(1.1)}70%{transform:rotate(5deg) scale(.96)}100%{transform:rotate(0) scale(1)}}
#soundBtn{white-space:nowrap;min-width:94px}
@media(prefers-reduced-motion:reduce){.dig-swing{animation:none!important}}

/* Phase 20 — compact colorful equipment upgrade panel */
.equipment-shop{border-color:#79a9c8;background:linear-gradient(145deg,#304f68,#20394f)}
.equipment-status{font-size:12px;font-weight:800;color:#f4d98a;line-height:1.6;padding:5px 7px;border-radius:8px;background:#152d42}
#equipmentShop button{width:100%;font-size:12px;padding:8px;text-align:left}
#equipmentShop button:disabled{opacity:.45;cursor:not-allowed}
#equipmentShop small{color:#d4e4ee;line-height:1.45}


/* Phase 21 — Mining companions */
.pet-shop{border-color:#b69be8;background:linear-gradient(145deg,#4b426d,#293b59)}
#petShop button{width:100%;font-size:12px;padding:8px;text-align:left}
#petShop button:disabled{opacity:.45;cursor:not-allowed}
#petShop small{color:#e1d9f5;line-height:1.45}

.authbox{display:grid;gap:8px;margin:6px 0 10px;padding:10px;border-radius:12px;background:#ffffff14}
.authbox small{opacity:.85}
.authrow{display:flex;gap:8px;flex-wrap:wrap}
#playerName[readonly]{opacity:.8}

/* ===== Phase 25 — Treasure Rush UI/UX: mine-cart wood & gold theme ===== */
:root{--wood:#5a3b22;--wood2:#3e2916;--gold2:#ffd35a;--stone:#223a52}
body{background:
  radial-gradient(ellipse at 50% -20%,#3d6f8f 0%,transparent 55%),
  radial-gradient(circle at 12% 100%,#1f6a55 0%,transparent 35%),
  radial-gradient(circle at 92% 90%,#6b3a63 0%,transparent 32%),
  linear-gradient(180deg,#183049,#0f1d2f);background-attachment:fixed}
/* header + logo */
header{height:62px;background:linear-gradient(180deg,#6a4627,#46301b 70%,#3b2715);border-bottom:3px solid #f4c95d;box-shadow:0 6px 0 #1d130a55,0 8px 24px #0008}
.brand{display:flex;align-items:center;gap:10px;font-size:22px;letter-spacing:1.5px;text-shadow:0 3px 0 #1c1209,0 0 14px #ffd35a55}
.brand b{color:var(--gold2)}.brand small{align-self:flex-end;font-size:10px;letter-spacing:3px;color:#e9c88a;margin-bottom:4px}
.logo-gem{width:34px;height:34px;filter:drop-shadow(0 0 8px #9fe9ff);animation:gem-spin 3.2s ease-in-out infinite}
@keyframes gem-spin{0%,100%{transform:rotate(-8deg) scale(1)}50%{transform:rotate(8deg) scale(1.1)}}
.pill{background:#241608;border:1px solid #8a6a3e;color:#ffe9b8}
/* panels: carved stone with gold trim */
.panel{background:linear-gradient(160deg,#2c4a66,#1a2f46);border:3px solid #c99a4a;border-radius:26px;box-shadow:0 0 0 4px #3b2715,0 22px 50px #000a,inset 0 2px #ffffff22}
.heroart{display:flex;justify-content:center;align-items:flex-end;gap:6px;animation:none;min-height:84px}
.heroart img{width:58px;height:58px;object-fit:contain;filter:drop-shadow(0 6px 4px #0008);animation:hero-float 2.8s ease-in-out infinite}
.heroart img.mid{width:86px;height:80px;animation-delay:.35s}.heroart img:last-child{animation-delay:.7s}
.panel h1{font-size:30px;-webkit-text-stroke:1px #6a3d12;text-shadow:0 3px 0 #6a3d12,0 0 18px #ffd35a55}
/* buttons: chunky wooden/gold */
button{border-radius:13px;font-weight:800;letter-spacing:.2px}
button:active{transform:translateY(3px);box-shadow:0 1px 0 #142a40}
button.primary{font-size:17px;padding:14px;background:linear-gradient(180deg,#ffe58a,#f2a638 55%,#d9821f)}
button.primary:hover{filter:brightness(1.08) saturate(1.1)}
button:disabled{filter:grayscale(.6);opacity:.55;cursor:not-allowed}
input,select{border-radius:12px!important;border:2px solid #6f8ca6!important}
input:focus,select:focus{border-color:var(--gold2)!important;box-shadow:0 0 0 3px #ffd35a33}
#roomCode{text-transform:uppercase;letter-spacing:4px;text-align:center;font-weight:800}
.howto{margin:14px 0 10px;text-align:left;background:#0f1f33aa;border:1px dashed #c99a4a88;border-radius:14px;padding:10px 14px}
.howto summary{cursor:pointer;font-weight:800;color:#ffe08a}.howto ul{margin:8px 0 2px;padding-left:4px;list-style:none}
.howto li{margin:7px 0;font-size:13px;color:#d9e8f7;line-height:1.5}.howto b{color:#ffe08a}
/* lobby */
.roomline{background:linear-gradient(180deg,#2a1a0c,#1a1008);border:2px solid #c99a4a;border-radius:16px}
.roomline strong{font-size:34px;color:var(--gold2);text-shadow:0 3px 0 #6a3d12,0 0 16px #ffd35a66}
.playerchips span,.playerchips .chip{border-radius:20px}
.themecards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:6px 0 10px}
.tc{display:flex;flex-direction:column;gap:2px;padding:12px 6px;text-align:center;border:2px solid #ffffff33;border-radius:14px;color:#fff;box-shadow:0 4px 0 #0007}
.tc small{color:#ffffffcc;font-size:11px}.tc b{font-size:15px}
.tc.emerald{background:linear-gradient(180deg,#2fa66a,#14583a)}.tc.ice{background:linear-gradient(180deg,#5fc7ef,#2563a8)}.tc.lava{background:linear-gradient(180deg,#f0642c,#8c1f12)}
.tc:not(.on){filter:saturate(.45) brightness(.75)}.tc.on{border-color:var(--gold2);box-shadow:0 0 0 3px #ffd35a66,0 4px 0 #0007,0 0 22px #ffd35a55;transform:translateY(-2px)}
/* HUD */
.hud{background:linear-gradient(180deg,#5a3b22,#3e2916);border:3px solid #c99a4a;border-radius:18px;box-shadow:0 5px 0 #1d130a,0 12px 26px #0007,inset 0 2px #ffffff22}
.hud .stat{flex-direction:row!important;align-items:center;gap:9px}.hud .stat>span{display:flex;flex-direction:column}
.hud .stat img{width:34px;height:34px;filter:drop-shadow(0 3px 2px #0007)}.hud .ico{font-style:normal;font-size:26px;filter:drop-shadow(0 3px 2px #0007)}
.hud small{color:#e9c88a;font-size:11px}.hud b{font-size:24px;color:var(--gold2);text-shadow:0 3px 0 #1d130a}
#myRank{color:#9fe9ff}
#timeLeft.low{color:#ff7a66;animation:time-low .7s ease-in-out infinite}
@keyframes time-low{50%{transform:scale(1.15)}}
.hud button{background:linear-gradient(180deg,#7a5330,#563821);border-color:#d3a45a;box-shadow:0 3px 0 #1d130a}
/* game frame + side panels */
.canvaswrap{border:4px solid #c99a4a;border-radius:20px;box-shadow:0 0 0 4px #3b2715,0 16px 34px #000a}
aside{background:linear-gradient(170deg,#2b4a66,#1a2e45);border:3px solid #c99a4a;border-radius:20px}
aside h3{font-size:16px}.mission,.eventpanel{border-width:2px;border-color:#6f8ca6}
.missionbar{height:12px;border-radius:8px;background:#0b1522;border:1px solid #6f8ca6}
.missionbar span{background:linear-gradient(90deg,#ffd35a,#ff9d2e);border-radius:8px}
/* controls */
.controls{background:linear-gradient(180deg,#5a3b22,#3e2916);border:3px solid #c99a4a;border-radius:20px;box-shadow:0 5px 0 #1d130a,0 12px 26px #0007}
.dpad button{width:54px;height:48px;font-size:18px;border-radius:12px;background:linear-gradient(180deg,#8a6038,#5d3d22);border-color:#e0b46a}
.action{border-radius:14px;background:linear-gradient(180deg,#4f7090,#2f4d69)}
.action span{font-size:11px;font-weight:800}
.action.dig{background:linear-gradient(180deg,#ffd35a,#e0842a)!important}
.action:disabled{filter:grayscale(.7);opacity:.5}
/* toast + quiz */
#toast{top:14px;border-radius:14px;padding:10px 18px;font-size:14px;background:linear-gradient(180deg,#5a3b22f5,#3e2916f5);border:2px solid var(--gold2);box-shadow:0 6px 0 #1d130a88,0 10px 24px #0009}
#quizBox{border:4px solid var(--gold2);border-radius:22px;box-shadow:0 0 0 5px #3b2715,0 0 0 9999px #050a14aa,0 24px 60px #000c}
#quizBox .quizoptions button,.quizoptions button{padding:14px;font-size:16px;text-align:left}
footer{color:#c9a96a}
@media(max-width:700px){
  header{height:54px}.brand{font-size:17px}.brand small{display:none}.logo-gem{width:28px;height:28px}
  .hud{display:flex;flex-wrap:wrap;gap:6px;padding:8px}
  .hud .stat{flex:1 1 28%;border-left:0;padding:2px 4px;gap:6px}.hud .stat img{width:26px;height:26px}.hud .ico{font-size:22px}.hud b{font-size:19px}
  .hud>button{flex:1 1 22%;min-width:0;padding:8px 4px;font-size:11px;min-height:36px}
  #soundBtn{min-width:0}
  .panel{border-width:2px;box-shadow:0 0 0 3px #3b2715,0 14px 30px #000a}.panel h1{font-size:24px}
  .controls{background:linear-gradient(180deg,#5a3b22f2,#3e2916f2);backdrop-filter:blur(3px)}
  .dpad button{width:48px;height:44px}
}
.gamegrid{align-items:start}.canvaswrap{align-self:start}

/* ===== Phase 26 — icon set, results podium, splash ===== */
.ic{width:1.35em;height:1.35em;vertical-align:-.32em;margin-right:2px;filter:drop-shadow(0 1px 1px #0006)}
.action .ic{display:block;width:30px;height:30px;margin:0 auto 1px}
.actions .action{display:flex;flex-direction:column;align-items:center;justify-content:center}
.mission .small .ic,.equipment-shop .small .ic,.pet-shop .small .ic{width:20px;height:20px}
.equipment-shop button,.pet-shop button,#powerShop button{display:flex;align-items:center;gap:6px}
.equipment-status{display:flex;flex-wrap:wrap;gap:5px;background:none;padding:0;margin-bottom:6px}
.lvchip{display:inline-flex;align-items:center;gap:3px;padding:4px 8px;border-radius:999px;font-size:11px;font-weight:800;border:2px solid;background:#152d42}
.lvchip .ic{width:16px;height:16px}
.lvchip.tier1{border-color:#a9682f;color:#f1c690}.lvchip.tier2{border-color:#b9c6d3;color:#e9eef5}.lvchip.tier3{border-color:#ffd35a;color:#fff0a8;box-shadow:0 0 10px #ffd35a66}
/* results */
.rbanner{display:flex;align-items:center;justify-content:center;gap:14px;padding:14px 18px;margin:0 0 10px;border-radius:18px;border:3px solid;text-align:left}
.rbanner .ic{width:64px;height:64px;margin:0;animation:hero-float 2.4s ease-in-out infinite}
.rbanner b{display:block;font-size:30px}.rbanner small{font-size:14px;color:#fff}
.rbanner.win{background:linear-gradient(180deg,#ffe58a,#f2a638);border-color:#fff0ad;color:#493016;box-shadow:0 0 28px #ffd35a88}
.rbanner.win small{color:#5a3b22}
.rbanner.lose{background:linear-gradient(180deg,#43607c,#2a4259);border-color:#8aa7c2;color:#fff}
.podium{display:flex;justify-content:center;align-items:flex-end;gap:8px;margin:16px 0 12px;min-height:150px}
.pod{flex:1;max-width:140px;display:flex;flex-direction:column;align-items:center}
.pname{font-weight:800;font-size:13px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pname .ic{display:block;margin:0 auto 2px;width:26px;height:26px}
.pscore{color:#ffe08a;font-weight:900;font-size:20px;text-shadow:0 2px 0 #6a3d12}
.pstep{width:100%;border:3px solid #c99a4a;border-radius:12px 12px 0 0;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:24px;background:linear-gradient(180deg,#7a5330,#4b301b);color:#ffe9b8}
.pstep span{font-size:20px;font-weight:900}
.p1 .pstep{height:110px;background:linear-gradient(180deg,#ffd35a,#c98a1f);color:#493016}.p2 .pstep{height:80px}.p3 .pstep{height:58px}
#finalBoard li.me{background:#ffd35a22;border-radius:8px;color:#ffe08a;font-weight:800}
#results.confetti::after{content:"";position:fixed;inset:0;pointer-events:none;background-image:radial-gradient(circle,#ffd35a 3px,transparent 4px),radial-gradient(circle,#ff6b6b 3px,transparent 4px),radial-gradient(circle,#6be8ff 3px,transparent 4px);background-size:90px 110px,130px 90px,70px 140px;background-position:0 0,40px 30px,20px 60px;animation:confetti 3.5s linear infinite;opacity:.8}
@keyframes confetti{to{background-position:0 600px,40px 630px,20px 660px}}
/* splash */
#splash{position:fixed;inset:0;z-index:99;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:14px;background:radial-gradient(circle at 50% 40%,#3d6f8f,#0f1d2f 70%);transition:opacity .45s}
#splash.out{opacity:0;pointer-events:none}
#splash img{width:96px;height:96px;filter:drop-shadow(0 0 22px #9fe9ff);animation:gem-spin 1.6s ease-in-out infinite}
.spl-title{font-size:34px;font-weight:900;letter-spacing:2px;color:#fff;text-shadow:0 4px 0 #1c1209}.spl-title b{color:#ffd35a}
.spl-bar{width:220px;height:12px;border-radius:8px;background:#0b1522;border:2px solid #c99a4a;overflow:hidden}
.spl-bar i{display:block;height:100%;width:100%;background:linear-gradient(90deg,#ffd35a,#ff9d2e);transform-origin:left;animation:spl 0.9s ease-out forwards}
@keyframes spl{from{transform:scaleX(0)}to{transform:scaleX(1)}}
#results.confetti::after{opacity:.3;z-index:0}
#results>*{position:relative;z-index:1}
@media(min-width:701px){aside{max-height:calc(100vh - 120px);overflow-y:auto;position:sticky;top:8px;scrollbar-width:thin;scrollbar-color:#c99a4a #1a2e45}}

.skinselect{text-align:center;margin:8px 0 14px}
.skinpick{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;margin:6px 0}
.skinbtn{width:52px;height:56px;padding:2px;border-radius:12px;border:2px solid rgba(255,214,102,.25);background:rgba(20,38,58,.7);cursor:pointer;transition:transform .12s,border-color .12s}
.skinbtn img{width:100%;height:100%;object-fit:contain;image-rendering:auto}
.skinbtn:hover{transform:translateY(-2px)}
.skinbtn.on{border-color:#ffd666;box-shadow:0 0 0 2px rgba(255,214,102,.35),0 0 14px rgba(255,214,102,.45);background:rgba(90,60,20,.75)}

.tc.forest{background:linear-gradient(180deg,#6fbf3a,#2d6a1f)}

/* ===== Phase 26: new screen art ===== */
.titlehero{margin:-6px -6px 6px;border-radius:20px 20px 14px 14px;overflow:hidden;border:3px solid #e8b04a;box-shadow:0 8px 22px #0007,inset 0 0 0 2px #fff3;line-height:0}
.titlehero img{width:100%;height:auto;display:block}
#splash{background:#0f1d2f}
.spl-art{position:absolute;inset:0;background:linear-gradient(180deg,#0f1d2f66,#0f1d2fcc),url(assets/ui_bg/splash.jpg) center/cover no-repeat;filter:saturate(1.05)}
#splash>*{position:relative;z-index:1}#splash>.spl-art{position:absolute}
.shopbanner{height:92px;margin:6px -4px 8px;border-radius:14px;border:3px solid #e8b04a;background:url(assets/ui_bg/shop_head.jpg) center bottom/cover no-repeat;position:relative;overflow:hidden;box-shadow:0 4px 10px #0006}
.shopbanner span{position:absolute;left:50%;bottom:11%;transform:translateX(-50%);width:50%;text-align:center;font-weight:900;font-size:15px;color:#5a3512;white-space:nowrap}
.rbanner.win,.rbanner.lose{position:relative;min-height:140px;background-size:cover;background-position:center;padding:0;justify-content:flex-start;align-items:flex-end;overflow:hidden}
.rbanner.win{background-image:url(assets/ui_bg/win.jpg);border-color:#ffe28a}.rbanner.lose{background-image:url(assets/ui_bg/lose.jpg);border-color:#8f7bd0}
.rbanner>.rtxt{width:100%;padding:34px 16px 10px;background:linear-gradient(0deg,#1a0f08e6,#1a0f0899 55%,transparent);color:#fff;text-align:center}
.rbanner>.rtxt b{font-size:30px;text-shadow:0 3px 0 #000a}.rbanner>.rtxt small{color:#ffe9b0}
.rbanner .ic{display:none}
.avatar{width:44px;height:44px;border-radius:50%;object-fit:contain;vertical-align:middle}
.pod .avatar{width:54px;height:54px;display:block;margin:0 auto 2px;filter:drop-shadow(0 3px 3px #0008)}
.tflag{width:22px;height:30px;object-fit:contain;vertical-align:-8px;margin-right:2px;filter:drop-shadow(0 1px 1px #0008)}
.badge-img{width:56px;height:56px;object-fit:contain;filter:drop-shadow(0 3px 3px #0007)}
.achievement-badge.locked .badge-img{filter:grayscale(1) brightness(.6) drop-shadow(0 2px 2px #0007);opacity:.7}
.stars{display:inline-flex;gap:2px;vertical-align:middle}.stars img{width:18px;height:18px}
.rbanner.win,.rbanner.lose{min-height:210px;background-position:center top}

.tc{position:relative;overflow:hidden;background-size:cover!important;background-position:center 35%!important;text-shadow:0 2px 3px #000c;color:#fff;min-height:84px;display:flex;flex-direction:column;justify-content:flex-end}
.tc::before{content:"";position:absolute;inset:0;background:linear-gradient(180deg,#0000 30%,#000b);z-index:0}.tc>*{position:relative;z-index:1}
.tc.emerald{background:url(assets/ui_bg/theme_emerald.jpg)}.tc.ice{background:url(assets/ui_bg/theme_ice.jpg)}.tc.lava{background:url(assets/ui_bg/theme_lava.jpg)}.tc.forest{background:url(assets/ui_bg/theme_forest.jpg)}
.tc.on{outline:3px solid #ffd666;box-shadow:0 0 16px #ffd66699}
.stat .ico .ic{width:28px;height:28px;margin:0;vertical-align:middle}
.howto .ic,.mission b .ic,.equipment-shop b .ic,h3 .ic,h2 .ic,.legend .ic{width:20px;height:20px;vertical-align:-4px}
.eventpanel .ic{width:18px;height:18px;vertical-align:-4px}
.teamrank .ic,.leaderboard .ic,#leaderboard .ic,#finalTeams .ic,#finalBoard .ic{width:18px;height:18px;vertical-align:-4px}

/* ---- Phase 26: ui_kit (opt-in classes; not yet applied to existing UI) ---- */
.kit-btn{border:0;background:center/100% 100% no-repeat;color:#fff;font-weight:800;text-shadow:0 2px 0 #0006;min-width:150px;aspect-ratio:355/139;cursor:pointer;padding:0 22px;transition:transform .12s,filter .12s}
.kit-btn:hover{transform:translateY(-1px);filter:brightness(1.1)}.kit-btn:active{transform:translateY(1px) scale(.98)}
.kit-btn.purple{background-image:url(assets/ui_kit/btn_purple.png)}.kit-btn.orange{background-image:url(assets/ui_kit/btn_orange.png)}
.kit-btn.green{background-image:url(assets/ui_kit/btn_green.png)}.kit-btn.blue{background-image:url(assets/ui_kit/btn_blue.png)}
.kit-panel{background:center/100% 100% no-repeat;padding:9% 8%;color:#fff}
.kit-panel.shop{background-image:url(assets/ui_kit/panel_shop.png)}.kit-panel.settings{background-image:url(assets/ui_kit/panel_settings.png)}
.kit-panel.pause{background-image:url(assets/ui_kit/panel_pause.png)}.kit-panel.result{background-image:url(assets/ui_kit/panel_result.png);padding:6% 6%}
.kit-nameplate{background:url(assets/ui_kit/nameplate.png) center/100% 100% no-repeat;padding:14px 38px;color:#fff;font-weight:800;text-align:center}
.kit-counter{display:inline-flex;align-items:center;justify-content:flex-end;min-width:130px;height:44px;padding:0 18px 0 56px;color:#fff;font-weight:800;background:center/100% 100% no-repeat}
.kit-counter.coin{background-image:url(assets/ui_kit/counter_coin.png)}.kit-counter.crystal{background-image:url(assets/ui_kit/counter_crystal.png)}
.kit-bar{position:relative;height:36px;background:url(assets/ui_kit/bar_loading.png) center/100% 100% no-repeat}
.kit-bar.energy{background-image:url(assets/ui_kit/bar_energy.png)}

/* ---- Phase 27: ui_kit applied ---- */
button.primary,#joinBtn,#saveSettingsBtn{background:center/100% 100% no-repeat;border:0;box-shadow:none;border-radius:0;color:#fff;text-shadow:0 2px 0 #0007;min-height:62px;padding:10px 26px;font-size:18px;filter:drop-shadow(0 4px 4px #0006)}
button.primary{background-image:url(assets/ui_kit/btn_orange.png)}
#joinBtn{background-image:url(assets/ui_kit/btn_blue.png);width:100%;margin:8px 0}
#saveSettingsBtn{background-image:url(assets/ui_kit/btn_green.png);width:100%;margin:8px 0}
button.primary:hover,#joinBtn:hover,#saveSettingsBtn:hover{filter:drop-shadow(0 4px 4px #0006) brightness(1.1)}
button.primary:active,#joinBtn:active,#saveSettingsBtn:active{transform:translateY(2px) scale(.98)}
.spl-bar{width:260px;height:30px;border:0;border-radius:0;background:url(assets/ui_kit/bar_loading.png) center/100% 100% no-repeat;padding:7px 14px;box-sizing:border-box;overflow:hidden}
.spl-bar i{border-radius:6px}
.quizbox{background:url(assets/ui_kit/panel_settings.png) center/100% 100% no-repeat!important;border:0!important;box-shadow:none!important;padding:58px 52px 44px!important;filter:drop-shadow(0 10px 20px #000a)}
.roomline strong{display:inline-block;background:url(assets/ui_kit/nameplate.png) center/100% 100% no-repeat;padding:12px 40px;color:#fff;letter-spacing:3px}
#crystalCount{display:flex;align-items:center;min-height:56px;padding:0 12px 0 96px;background:url(assets/ui_kit/counter_crystal.png) left center/100% 100% no-repeat;color:#fff;font-weight:800;font-size:12px}
.p1 .pstep{background:linear-gradient(180deg,#ffe27c,#d9921f);border-color:#fff0ad}
.p2 .pstep{background:linear-gradient(180deg,#8fc0f0,#3a6fb5);border-color:#d6e8fa;color:#fff}
.p3 .pstep{background:linear-gradient(180deg,#e08a52,#9a4a22);border-color:#f0b48a}

.shopbanner span{width:64%;left:50%;font-size:14px}

/* ===== Phase 28 — responsive play layout (phone / tablet / desktop, portrait + landscape) ===== */
html{-webkit-text-size-adjust:100%}
button,.action,.dpad button,.skinbtn,.tc{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.controls,.hud,#stick,canvas{user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
button:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #ffe27c;outline-offset:2px}
input,select{font-size:16px} /* stops iOS zoom-on-focus */
header{padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
#menuBtn,#fsBtn,.sheethead,#sheetShade{display:none}
#stick{position:absolute;width:96px;height:96px;margin:-48px 0 0 -48px;border-radius:50%;border:3px solid #ffe27caa;background:radial-gradient(circle,#ffffff22,#0b152255);pointer-events:none;opacity:0;transition:opacity .12s;z-index:5}
#stick.on{opacity:1}#stick.idle{opacity:.3}body.spectator #stick{display:none}#stick i{position:absolute;left:50%;top:50%;width:42px;height:42px;margin:-21px 0 0 -21px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#fff3b0,#f2a638 60%,#a75b21);box-shadow:0 3px 8px #0008}
#touchHint{position:absolute;left:50%;bottom:12px;transform:translateX(-50%);z-index:4;padding:8px 14px;border-radius:14px;background:#0b1522dd;border:2px solid #c99a4a;color:#ffe9b8;font-size:13px;font-weight:800;white-space:nowrap;pointer-events:none}
.action[data-key]{position:relative}
@media(hover:hover) and (pointer:fine){.action[data-key]::after{content:attr(data-key);position:absolute;top:3px;right:4px;font-size:9px;font-weight:900;line-height:1;padding:2px 4px;border-radius:5px;background:#0b1522aa;color:#ffe27c}}
@media(pointer:coarse){#digBtn::after{display:none}}

/* --- every in-game layout: lock to one screen, map scales to fit --- */
body.ingame{overflow:hidden;overscroll-behavior:none}
body.ingame #app{height:100vh;height:100dvh;display:flex;flex-direction:column}
body.ingame main{flex:1;min-height:0;max-width:none;width:100%;margin:0;padding:8px max(10px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(10px,env(safe-area-inset-left));box-sizing:border-box}
body.ingame footer{display:none}
body.ingame #game{height:100%;display:grid;gap:8px;min-height:0}
body.ingame .gamegrid{display:contents}
body.ingame .hud,body.ingame .controls{margin:0}
body.ingame .canvaswrap{grid-area:map;min-height:0;min-width:0;container-type:size;display:grid;place-items:center;background:none;border:0;box-shadow:none;border-radius:0;overflow:visible;max-height:none}
body.ingame canvas{width:min(100cqw,150cqh);height:auto;border:4px solid #c99a4a;border-radius:16px;box-shadow:0 0 0 3px #3b2715,0 12px 28px #000a;box-sizing:border-box;background:#152238}
body.ingame .hud{grid-area:hud}
body.ingame .controls{grid-area:ctl;position:static}

/* --- A: desktop & tablet landscape — side panel always visible --- */
@media(min-width:900px) and (min-height:600px){
 body.ingame #game{grid-template-columns:minmax(0,1fr) clamp(260px,24vw,330px);grid-template-rows:auto minmax(0,1fr) auto;grid-template-areas:"hud hud" "map side" "ctl side"}
 body.ingame aside{grid-area:side;max-height:none;position:static;overflow-y:auto;min-height:0}
 body.ingame .controls{justify-content:center;gap:28px;padding:10px 18px}
 body.ingame .action{min-width:72px;min-height:62px}
}

/* --- B + C shared: side panel becomes a sheet opened from the HUD --- */
@media (max-width:899px),(max-height:599px){
 body.ingame #menuBtn,body.ingame #fsBtn{display:flex}
 body.ingame aside{position:fixed;z-index:41;left:0;right:0;bottom:0;max-height:min(82dvh,640px);overflow-y:auto;overscroll-behavior:contain;border-radius:22px 22px 0 0;padding:0 12px max(14px,env(safe-area-inset-bottom));transform:translateY(105%);transition:transform .25s ease;display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:10px;align-content:start;visibility:hidden}
 body.ingame.sheet-open aside{transform:none;visibility:visible}
 body.ingame aside>*{grid-column:auto}body.ingame aside h3,body.ingame aside .sheethead,body.ingame aside .legend{grid-column:1/-1}
 body.ingame aside ol{max-height:none}
 body.ingame .sheethead{display:flex;position:sticky;top:0;z-index:2;align-items:center;justify-content:space-between;margin:0 -12px;padding:12px 14px;background:linear-gradient(180deg,#5a3b22,#3e2916);border-bottom:2px solid #c99a4a;color:#ffe9b8}
 body.ingame .sheethead button{width:40px;height:40px;padding:0;display:grid;place-items:center}
 body.ingame #sheetShade{display:block;position:fixed;inset:0;z-index:40;background:#050a14aa;opacity:0;pointer-events:none;transition:opacity .2s}
 body.ingame.sheet-open #sheetShade{opacity:1;pointer-events:auto}
 /* compact one-row HUD with icon buttons */
 body.ingame .hud{display:flex;flex-wrap:nowrap;align-items:center;gap:4px;padding:6px 8px}
 body.ingame .hud .stat{flex:1 1 0;min-width:0;gap:5px;padding:0 2px}
 body.ingame .hud .stat small{font-size:9px;white-space:nowrap}
 body.ingame .hud b{font-size:17px}
 body.ingame .hud .stat img,body.ingame .hud .ico{width:24px;height:24px;font-size:20px}
 body.ingame .hud>button{flex:0 0 auto;width:42px;height:42px;min-height:42px;padding:0;font-size:0;display:grid;place-items:center}
 body.ingame .hud>button.hidden{display:none}
 body.ingame .hud>button .ic{width:24px;height:24px;margin:0}
 body.ingame header{display:none}
}

/* --- C: portrait / narrow — map on top, thumb controls at the bottom --- */
@media (max-width:899px) and (orientation:portrait),(max-width:899px) and (min-height:600px),(orientation:portrait) and (max-height:599px){
 body.ingame #game{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr) auto;grid-template-areas:"hud" "map" "ctl"}
 body.ingame .controls{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:10px;border-radius:20px}
 body.ingame .dpad button{width:clamp(46px,14vw,64px);height:clamp(44px,13vw,60px);font-size:20px}
 body.ingame .actions{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;flex:1;max-width:400px}
 body.ingame .action{min-width:0;min-height:clamp(48px,13vw,64px);padding:4px 2px}
 body.ingame .action .ic{width:24px;height:24px}
 body.ingame .action span{font-size:10px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
}
@media (max-width:359px){body.ingame .actions{grid-template-columns:repeat(4,minmax(0,1fr))}body.ingame .action span{display:none}body.ingame .hud .stat small{display:none}}

/* --- B: phone landscape — d-pad left, map centre, actions right --- */
@media (orientation:landscape) and (max-height:599px){
 body.ingame main{padding-top:max(6px,env(safe-area-inset-top))}
 body.ingame #game{grid-template-columns:auto minmax(0,1fr) auto;grid-template-rows:auto minmax(0,1fr);grid-template-areas:"hud hud hud" "pad map act";gap:6px 10px}
 body.ingame .controls{display:contents}
 body.ingame .dpad{grid-area:pad;align-self:end;padding:8px;border-radius:20px;background:linear-gradient(180deg,#5a3b22e6,#3e2916e6);border:3px solid #c99a4a}
 body.ingame .dpad button{width:clamp(44px,11vh,58px);height:clamp(42px,10.5vh,54px)}
 body.ingame .actions{grid-area:act;align-self:end;display:grid;grid-template-columns:repeat(2,minmax(56px,1fr));gap:6px;padding:8px;border-radius:20px;background:linear-gradient(180deg,#5a3b22e6,#3e2916e6);border:3px solid #c99a4a;max-height:100%;overflow:auto}
 body.ingame .action{min-width:0;min-height:clamp(42px,12vh,58px);padding:3px}
 body.ingame .action span{font-size:9px}
 body.ingame .hud{padding:4px 8px}body.ingame .hud .stat small{display:none}
 body.ingame aside{left:auto;top:0;width:min(400px,88vw);max-height:none;border-radius:22px 0 0 22px;transform:translateX(105%);grid-template-columns:1fr}
 #quizBox{max-height:94dvh;overflow:auto}
}

/* entry / lobby / results usability on small screens */
@media(max-width:480px){
 .panel{padding:16px 14px;margin:10px auto}
 .themecards{grid-template-columns:repeat(2,minmax(0,1fr))!important}
 .authrow{display:grid;grid-template-columns:1fr 1fr;gap:6px}
 .roomline strong{font-size:22px;padding:10px 26px}
 .podium{gap:4px}.pscore{font-size:17px}
}
#quizBox{width:min(94vw,520px)}
.quizoptions button{min-height:48px}
/* Phase 28 fixes: map cell must stretch (older rule set align-self:start), flex children may shrink */
body.ingame main{display:flex;flex-direction:column}
body.ingame #game{flex:1;height:auto}
body.ingame .canvaswrap{align-self:stretch;justify-self:stretch}
body.ingame .actions{min-width:0}
@media (max-width:899px) and (orientation:portrait),(max-width:899px) and (min-height:600px),(orientation:portrait) and (max-height:599px){
 body.ingame .hud{flex-wrap:wrap;row-gap:6px}
 body.ingame .hud .stat{flex:1 1 30%}
 body.ingame .hud>button{flex:1 1 0;max-width:72px;width:auto}
 body.ingame .dpad button{width:clamp(44px,12.5vw,62px);height:clamp(42px,12vw,58px)}
}
@media (max-width:899px) and (orientation:portrait),(max-width:899px) and (min-height:600px),(orientation:portrait) and (max-height:599px){
 body.ingame .hud{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;padding:6px 8px}
 body.ingame .hud .stat{grid-column:span 2;flex:none}
 body.ingame .hud>button{grid-column:span 1;width:100%;max-width:none;height:42px;flex:none}
}
@media (max-width:899px),(max-height:599px){body.ingame .hud>button{display:flex;justify-content:center;align-items:center}body.ingame .hud>button.hidden{display:none}}

/* ===== Phase 29 — item cooldown overlay, play-again ===== */
.action.cooling{position:relative;filter:saturate(.35) brightness(.8)}
.action.cooling::before{content:attr(data-cd);position:absolute;inset:0;display:grid;place-items:center;border-radius:inherit;background:#0b1522aa;color:#fff;font-size:20px;font-weight:900;text-shadow:0 2px 0 #000;z-index:2}
#againHint{color:#ffe9b8;font-weight:700}
#backBtn{width:100%;margin-top:6px}

/* ===== Phase 30 — HUD, settings menu, guide, toasts, buffs, podium art ===== */
.hud{position:relative}
.hud .stat .ico-img{width:28px;height:28px;object-fit:contain;flex:0 0 auto}
.hud .stat.score,.hud .stat.crys{min-width:120px}
.hudbtns{display:flex;gap:8px;align-items:center;margin-left:auto;flex-wrap:wrap}
.hudbtns>button{position:relative;display:flex;align-items:center;gap:5px}
#menuBtn{display:none}
.dot{position:absolute;top:-4px;right:-4px;width:14px;height:14px;border-radius:50%;background:#ff4b3b;border:2px solid #fff;box-shadow:0 0 8px #ff4b3b;animation:dotpulse 1s ease-in-out infinite}
@keyframes dotpulse{50%{transform:scale(1.25)}}
.optpop{position:absolute;right:8px;top:calc(100% + 6px);z-index:45;display:grid;gap:6px;min-width:230px;padding:10px;border-radius:16px;background:linear-gradient(180deg,#5a3b22,#3e2916);border:3px solid #c99a4a;box-shadow:0 14px 30px #000a}
.optpop button{display:flex!important;align-items:center;gap:8px;width:100%;text-align:left;font-size:14px;padding:10px 12px;min-height:44px}
.optpop button .ic{width:22px;height:22px}
#optPop #fsBtn.hidden{display:none!important}
/* toasts */
#toast{display:none!important}
#toastStack{position:absolute;top:10px;left:50%;transform:translateX(-50%);z-index:6;display:flex;flex-direction:column;align-items:center;gap:6px;width:min(94%,560px);pointer-events:none}
.tst{display:flex;align-items:center;gap:8px;max-width:100%;padding:7px 14px 7px 8px;border-radius:14px;background:linear-gradient(180deg,#5a3b22f2,#3e2916f2);border:2px solid #f4c95d;color:#ffe9b8;font-size:14px;font-weight:700;box-shadow:0 6px 16px #0008;animation:tstin .25s ease both}
.tst img{width:28px;height:28px;object-fit:contain;flex:0 0 auto}
.tst.warn{border-color:#ff7a66;background:linear-gradient(180deg,#6a2620f2,#3e1612f2)}
.tst.out{opacity:0;transform:translateY(-6px);transition:.3s}
@keyframes tstin{from{opacity:0;transform:translateY(-8px)}}
/* buff timers */
#buffBar{position:absolute;left:10px;bottom:10px;z-index:5;display:flex;gap:6px;pointer-events:none}
.buff{display:flex;align-items:center;gap:3px;padding:3px 8px 3px 4px;border-radius:12px;background:#0b1522d9;border:2px solid #7ce8ff;color:#fff;font-size:13px}
.buff img{width:22px;height:22px}.buff small{color:#bcd;font-size:10px}
.buff.frozenUntil,.buff.slowedUntil,.buff.smokeUntil{border-color:#ff7a66}
/* pause */
.pauseov{position:absolute;inset:0;z-index:7;display:grid;place-items:center;background:#050a1499;border-radius:16px}
.pausecard{display:grid;justify-items:center;gap:4px;width:min(80%,420px);aspect-ratio:471/247;place-content:center;background:url(assets/ui_kit/panel_pause.png) center/100% 100% no-repeat;color:#fff;text-align:center}
.pausecard img{width:44px;height:44px}.pausecard b{font-size:22px;color:#ffe08a}.pausecard small{color:#d8e7f7}
/* guide */
.guide{position:fixed;inset:0;z-index:60;display:grid;place-items:center;padding:12px;background:#050a14cc}
.guide-card{position:relative;width:min(760px,100%);max-height:92dvh;overflow:auto;box-sizing:border-box;padding:34px 30px 24px;border:38px solid transparent;border-image:url(assets/ui_kit/frame9.png) 76 fill / 38px stretch;color:#fff;text-align:center}
.guide-card::before{content:"";position:absolute;top:-38px;left:50%;width:65px;height:30px;transform:translateX(-50%);background:url(assets/ui_kit/gem_top.png) center/contain no-repeat}
.guide-card h2{margin:0 0 12px;color:#ffe08a}
.guide-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:10px}
.guide-grid div{display:grid;justify-items:center;gap:3px;padding:10px 6px;border-radius:12px;background:#ffffff0d;border:1px solid #ffffff1a}
.guide-grid img{width:52px;height:52px;object-fit:contain}.guide-grid b{font-size:14px}.guide-grid small{font-size:12px;color:#bcd0e4}
.guide-keys{font-size:13px;color:#d8e7f7;line-height:1.7}
@media(max-width:620px){.guide-grid{grid-template-columns:repeat(2,1fr)}.guide-card{padding:14px 6px 10px;border-width:24px;border-image-width:24px}.guide-card::before{top:-24px;width:44px;height:20px}.guide-grid img{width:40px;height:40px}}
/* quiz */
.quizhost{width:46px;height:46px;vertical-align:middle}
.quizclock .ic{width:18px;height:18px;vertical-align:-4px}
/* side panel */
#leaderboard,#teamLeaderboard,#finalTeams,#finalBoard{list-style:none;padding-left:0}
#leaderboard li,#teamLeaderboard li{display:flex;align-items:center;gap:5px;flex-wrap:wrap}
#leaderboard li .nm{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
#leaderboard li.me,#teamLeaderboard li.mine{background:#ffd35a22;border-radius:8px;padding-left:4px}
#leaderboard li.gap{color:#8aa}
.ic.medal{width:20px;height:20px}.rankno{display:inline-grid;place-items:center;width:20px;height:20px;border-radius:50%;background:#ffffff1a;font-size:11px;font-weight:800}
.mascot{width:24px;height:24px;object-fit:contain;vertical-align:middle;border-radius:50%}
.chipav{width:24px;height:24px;object-fit:contain;vertical-align:middle;border-radius:50%;background:#ffffff14}
.chip{display:inline-flex;align-items:center;gap:6px}.chip.me{outline:2px solid #ffd35a}
.teamchip .mascot{width:28px;height:28px}
.petav{width:34px;height:34px;vertical-align:middle;object-fit:contain}
.badge-icon{position:relative}.badge-lock{position:absolute;right:-4px;bottom:-4px;width:18px;height:18px}
.missionbar{height:24px!important;border:0!important;border-radius:0!important;background:url(assets/ui_kit/bar_loading.png) center/100% 100% no-repeat!important;padding:6px 4.5%;box-sizing:border-box}
.missionbar span{display:block;height:100%;border-radius:6px!important}
.energybar{position:relative;height:34px;margin:4px 0;background:url(assets/ui_kit/bar_energy.png) center/100% 100% no-repeat}
.energybar i{position:absolute;right:3%;top:24%;bottom:24%;background:#0b1a2ad9;border-radius:0 8px 8px 0;transition:width .3s}
.afford{box-shadow:0 0 0 2px #7cff9a,0 0 14px #7cff9a88!important}
.action.notarget{opacity:.55}
/* results */
.ic.big{width:34px;height:34px;vertical-align:-6px}
.wincard{display:grid;place-content:center;gap:4px;aspect-ratio:931/307;max-width:520px;margin:6px auto 10px;padding:0 8%;background:url(assets/ui_kit/panel_result.png) center/100% 100% no-repeat;text-align:center}
.wincard h2{margin:0;color:#ffe08a;font-size:clamp(16px,4vw,22px)}.wincard small{color:#d8e7f7}
.podium.art{position:relative;display:block;max-width:460px;margin:60px auto 12px;min-height:0}
.podium.art .podbg{display:block;width:100%}
.podium.art .slot{position:absolute;bottom:0;width:31%;height:100%}
.podium.art .s1{left:34.5%}.podium.art .s2{left:3.5%}.podium.art .s3{left:65.5%}
.podium.art .who{position:absolute;left:0;right:0;display:grid;justify-items:center;text-align:center}
.podium.art .s1 .who{bottom:100%}.podium.art .s2 .who{bottom:76%}.podium.art .s3 .who{bottom:73%}
.podium.art .who .avatar{width:48px;height:48px;border-radius:50%;object-fit:contain;background:#ffffff1a}
.podium.art .who b{font-size:12px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.podium.art .who span{color:#ffe08a;font-weight:900;text-shadow:0 2px 0 #6a3d12}
.podium.art .crown{width:26px;height:26px;margin-bottom:-4px}
.podium.art em{position:absolute;left:0;right:0;top:45%;font-style:normal;font-size:28px;font-weight:900;color:#fff;text-shadow:0 3px 0 #0008;text-align:center}
.podium.art .s1 em{top:36%}
#againBtn{background-image:url(assets/ui_kit/btn_purple.png)!important;background-size:100% 100%!important;border:0;color:#fff;min-height:62px;width:100%;text-shadow:0 2px 0 #0007}
#finalBoard li,#finalTeams li{display:flex;align-items:center;gap:6px;justify-content:center;flex-wrap:wrap}
/* HUD on phones / narrow screens */
@media (max-width:899px),(max-height:599px){
 body.ingame #menuBtn{display:flex}
 body.ingame .hud{display:grid!important;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;padding:6px 8px}
 body.ingame .hud .stat{grid-column:auto!important;min-width:0;gap:4px}
 body.ingame .hud .stat small{display:block;font-size:9px}
 body.ingame .hud .stat .ico-img,body.ingame .hud .stat img{width:22px;height:22px}
 body.ingame .hud b{font-size:16px}
 body.ingame .hudbtns{grid-column:1/-1;margin:0;flex-wrap:nowrap}
 body.ingame .hudbtns>button{flex:1 1 0;justify-content:center;font-size:0;min-height:42px;padding:0}
 body.ingame .hudbtns>button.hidden{display:none}
 body.ingame .hudbtns>button .ic{width:24px;height:24px;margin:0}
}
@media (orientation:landscape) and (max-height:599px){
 body.ingame .hud{grid-template-columns:repeat(4,minmax(0,1fr)) auto!important}
 body.ingame .hudbtns{grid-column:auto}
 body.ingame .hudbtns>button{flex:0 0 42px}
 body.ingame .hud .stat small{display:none}
}
.hud .hudbtns{flex-direction:row}
.hud .optpop{display:grid}

.optpop .kit-menu-link{display:block;padding:9px 12px;color:#ffe4a2;text-align:left;text-decoration:underline}
.optpop .kit-menu-link:focus-visible{outline:2px solid #7ce8ff;outline-offset:-2px}
#resultMiner{width:65px;height:62px;margin:4px auto 12px;background-repeat:no-repeat;background-size:585px 558px;animation:result-miner-frames 1.26s steps(9) infinite}
#resultMiner[data-pose="victory"]{background-position-y:-372px}
#resultMiner[data-pose="defeat"]{background-position-y:-434px}
@keyframes result-miner-frames{from{background-position-x:0}to{background-position-x:-585px}}
@media(prefers-reduced-motion:reduce){#resultMiner{animation:none}}
