/* UI v2 — flat, screen-filling in-game layout. Wins over style.css/focus.css by loading last. */
:root{--ui-bg:#0e1a2b;--ui-glass:rgba(14,26,43,.82);--ui-line:rgba(255,255,255,.12);--ui-gold:#ffd45b;--ui-txt:#eef4ff;--ui-dim:#9fb3cc}
body.ingame{background:#0a1220}
body.ingame header{display:none!important}
body.ingame main{padding:6px max(8px,env(safe-area-inset-right)) max(6px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left))!important}
body.ingame #game{gap:6px!important}

/* HUD: one flat bar */
body.ingame .hud{background:var(--ui-glass)!important;border:1px solid var(--ui-line)!important;border-radius:14px!important;box-shadow:none!important;padding:4px 8px!important;min-height:0!important;backdrop-filter:blur(6px);display:flex!important;align-items:center;gap:6px}
body.ingame .hud .stat{border:0!important;padding:0 8px!important;gap:6px!important;flex:0 1 auto!important}
body.ingame .hud .stat img{width:22px!important;height:22px!important;filter:none!important}
body.ingame .hud small{display:none!important}
body.ingame .hud b{font-size:18px!important;color:var(--ui-txt)!important;text-shadow:none!important;font-variant-numeric:tabular-nums}
body.ingame .hud .stat.time b{color:var(--ui-gold)!important}
body.ingame .hudbtns{margin-left:auto!important;display:flex!important;gap:6px!important}
body.ingame .hudbtns .small{background:rgba(255,255,255,.07)!important;border:1px solid var(--ui-line)!important;box-shadow:none!important;border-radius:10px!important;color:var(--ui-txt)!important;min-height:34px;height:34px;padding:0 10px!important;font-size:13px!important}
body.ingame .hudbtns .small .ic{width:18px;height:18px}
body.ingame #optPop{background:#12233a!important;border:1px solid var(--ui-line)!important;border-radius:12px!important;box-shadow:0 12px 30px #000a!important}

/* Map */
body.ingame canvas{border:2px solid rgba(255,212,91,.55)!important;border-radius:12px!important;box-shadow:0 8px 30px #0009!important}

/* Side panel: slim flat cards */
body.ingame aside{background:var(--ui-glass)!important;border:1px solid var(--ui-line)!important;border-radius:14px!important;box-shadow:none!important;padding:8px!important;gap:6px}
body.ingame aside h3{font-size:12px!important;letter-spacing:.04em;color:var(--ui-dim)!important;margin:6px 2px 2px!important;text-transform:none}
body.ingame aside .mission,body.ingame aside .eventpanel{background:rgba(255,255,255,.05)!important;border:0!important;border-radius:12px!important;box-shadow:none!important;padding:8px 10px!important;margin:0 0 6px!important;font-size:13px}
body.ingame aside .teamrank li{background:none!important;border:0!important;padding:4px 6px!important;font-size:13px}
body.ingame aside .teamrank li.mine{background:rgba(255,212,91,.14)!important;border-radius:8px}
body.ingame aside .teamrank img.tflag{width:16px;height:auto}

/* Controls: float over the map on landscape / desktop, no wooden frame */
body.ingame .controls{background:none!important;border:0!important;box-shadow:none!important;padding:0!important;backdrop-filter:none!important}
body.ingame .action,body.ingame .dpad button{background:rgba(20,34,54,.78)!important;border:1px solid rgba(255,255,255,.18)!important;box-shadow:0 3px 10px #0007!important;border-radius:16px!important;color:var(--ui-txt)!important;backdrop-filter:blur(4px)}
body.ingame .action.dig{background:linear-gradient(180deg,#ffd45b,#f2992e)!important;border-color:#fff3b0!important;color:#3a2400!important}
body.ingame .action span{font-size:11px!important;font-weight:800}
body.ingame .dpad button{width:58px;height:58px;font-size:20px}
@media(min-width:900px) and (min-height:600px){
  body.ingame .controls{position:fixed!important;left:max(12px,env(safe-area-inset-left));right:max(12px,env(safe-area-inset-right));bottom:max(12px,env(safe-area-inset-bottom));z-index:20;pointer-events:none;display:flex!important;justify-content:space-between!important;align-items:flex-end!important;width:auto!important;gap:0!important}
  body.ingame .controls>*{pointer-events:auto}
  body.ingame .actions{display:flex!important;gap:8px!important;flex-direction:row-reverse;align-items:flex-end}
  body.ingame .action{min-width:60px!important;min-height:60px!important}
  body.ingame .action.dig{min-width:78px!important;min-height:78px!important;border-radius:50%!important}
}
@media(orientation:landscape) and (max-height:599px){
  body.ingame .controls{display:contents!important}
  body.ingame .actions{display:grid!important;grid-template-columns:repeat(2,minmax(52px,1fr))!important;gap:6px!important;align-self:end}
  body.ingame .dpad{align-self:end}
  body.ingame .dpad button{width:clamp(44px,11vh,54px);height:clamp(42px,10.5vh,52px)}
  body.ingame .action{min-width:0!important;min-height:clamp(42px,12vh,54px)!important}
  body.ingame .action.dig{border-radius:16px!important}
}
@media(min-width:900px) and (min-height:600px){
  body.ingame .controls{right:calc(clamp(260px,24vw,330px) + 26px)!important;left:auto!important;justify-content:flex-end!important}
}
/* mouse + keyboard: the on-screen d-pad is not needed */
@media(hover:hover) and (pointer:fine){body.ingame .dpad{display:none!important}}
@media(orientation:portrait),(max-width:700px) and (min-height:521px){
  body.ingame .controls{position:static!important;display:flex!important;justify-content:space-between;align-items:center;padding:2px 4px!important}
  body.ingame .actions{display:grid!important;grid-template-columns:repeat(3,64px);gap:8px;flex:0 0 auto}
  body.ingame .action{min-width:0!important;min-height:58px!important}
  body.ingame .action.dig{grid-column:span 1;border-radius:16px!important}
}

/* Upgrade pop-up: flat */
.uppick{background:var(--ui-glass)!important;border:1px solid var(--ui-gold)!important;border-radius:14px!important;backdrop-filter:blur(8px);box-shadow:0 10px 30px #000b!important}
.upcard{background:rgba(255,255,255,.08)!important;border:1px solid var(--ui-line)!important;border-radius:12px!important}
.upcard:active{background:rgba(255,212,91,.25)!important}

body.ingame .dpad,body.ingame .actions{background:none!important;border:0!important;box-shadow:none!important;padding:0!important}
body.ingame .hudbtns .small{white-space:nowrap}
@media(max-width:700px),(max-height:520px){
  body.ingame .hudbtns .small{font-size:0!important;width:36px;padding:0!important;display:flex!important;align-items:center;justify-content:center}
  body.ingame .hudbtns .small .ic{margin:0!important}
}
@media(max-width:400px){body.ingame .hudbtns .small{width:30px;height:30px;min-height:30px}}
@media(orientation:portrait),(max-width:700px) and (min-height:521px){
  body.ingame .dpad button{width:50px;height:50px}
  body.ingame .actions{grid-template-columns:repeat(3,58px)!important;gap:6px!important}
  body.ingame .action{min-height:54px!important}
}
/* pop-up sits at the top of the map on overlay layouts so it never covers the action buttons */
@media(min-width:900px) and (min-height:600px){
  .uppick{bottom:auto!important;top:10px}
}
@media(min-width:900px) and (min-height:600px) and (pointer:coarse){
  body.ingame .controls{left:max(12px,env(safe-area-inset-left))!important;justify-content:space-between!important}
}
@media(min-width:900px) and (min-height:600px){body.ingame .controls{justify-self:stretch!important;align-self:auto!important;max-width:none!important}}

/* ===== Entry / lobby / results: fit the screen ===== */
.authfold{margin:8px 0}
.authfold summary{cursor:pointer;color:var(--ui-dim);font-size:13px;padding:6px 2px}
.authfold .authbox{margin-top:6px}
@media(max-height:760px){
  #entry .titlehero img{max-height:120px;object-fit:cover;width:100%}
  #entry h1{font-size:22px;margin:6px 0 0}#entry>p{display:none}
  #entry .skinselect{margin:6px 0}
}
@media(max-width:700px){
  #lobby .themecards{display:grid;grid-template-columns:1fr 1fr;gap:6px}
  #lobby .themecards .tc{min-height:64px}
  #lobby .teacher-settings select{min-height:42px}
}
@media(max-width:380px) and (orientation:portrait){
  body.ingame .dpad button{width:44px;height:44px}
  body.ingame .actions{grid-template-columns:repeat(3,50px)!important;gap:5px!important}
  body.ingame .action{min-height:50px!important}
}

/* ===== Quiz: docked card, never a blocking modal ===== */
body.ingame #quizBox{position:fixed!important;left:50%!important;top:64px!important;transform:translateX(-50%)!important;width:min(94vw,560px)!important;max-height:none!important;padding:10px 12px!important;margin:0!important;background:var(--ui-glass)!important;backdrop-filter:blur(8px);border:1px solid var(--ui-gold)!important;border-radius:14px!important;box-shadow:0 10px 30px #000b!important;filter:none!important;overflow:visible!important;animation:none!important;z-index:25}
body.ingame #quizBox h2{font-size:13px!important;margin:0 0 4px!important;display:flex;align-items:center;gap:6px}
body.ingame #quizBox .quizhost{width:22px;height:22px}
body.ingame #quizBox #quizQuestion{font-size:15px!important;margin:0 0 8px!important;line-height:1.3}
body.ingame #quizBox .quizoptions{display:grid!important;grid-template-columns:1fr 1fr;gap:6px}
body.ingame #quizBox .quizoptions button{padding:8px 10px!important;font-size:14px!important;min-height:40px;border-radius:10px!important;background:rgba(255,255,255,.09)!important;border:1px solid var(--ui-line)!important;color:var(--ui-txt)!important;box-shadow:none!important;text-align:left}
body.ingame #quizBox .quizoptions button:active{background:rgba(255,212,91,.28)!important}
body.ingame #quizBox .quizclock{display:block;margin-top:6px;font-size:11px;color:var(--ui-dim)!important}
@media(max-height:460px){body.ingame #quizBox{top:56px!important;width:min(58vw,470px)!important;padding:6px 10px!important}body.ingame #quizBox .quizclock{margin-top:3px}body.ingame #quizBox h2{margin:0 0 2px!important}body.ingame #quizBox #quizQuestion{font-size:13px!important;margin-bottom:5px!important}body.ingame #quizBox .quizoptions button{min-height:32px;padding:4px 8px!important;font-size:12px!important}}
@media(max-height:460px){body.ingame #quizBox h2{display:none!important}body.ingame #quizBox .quizoptions button{min-height:30px!important;padding:3px 8px!important}body.ingame #quizBox #quizQuestion{margin-bottom:4px!important}}

.teacherlink{display:block;text-align:center;margin:8px 0;padding:8px;border-radius:10px;color:var(--ui-dim);font-size:13px;text-decoration:none;border:1px dashed var(--ui-line)}
.teacherlink:hover{color:#fff}

/* Spectator teacher: watches and controls the room, no character and no player controls */
body.spectator .controls,body.spectator #trickMenu,body.spectator #digBtn,body.spectator #buffBar{display:none!important}
body.spectator #entryClassSlot,body.spectator #classPicker,body.spectator #classDetails{display:none!important}
.teacher-plays{font-size:13px;color:var(--ui-dim);margin:6px 0}
