/* Räknejakten – sammanhållen layout för solo, duell, knappsats, tangentbord, turnering och topplista. */
:root{
  color-scheme:dark;
  --bg:#0b1428;
  --panel:#14233e;
  --ink:#f4f8ff;
  --muted:#b5c7e2;
  --cyan:#65e6ef;
  --lime:#baf477;
  --gold:#ffd86b;
  --red:#ffb0b9;
  --line:#334767;
  font-family:system-ui,-apple-system,'Segoe UI',sans-serif;
  font-weight:650;
}
*{box-sizing:border-box}
body{
  margin:0;
  min-height:100dvh;
  background:radial-gradient(ellipse at 10% 0,#1e3c62 0,transparent 55%),var(--bg);
  color:var(--ink);
}
button{
  font:inherit;
  cursor:pointer;
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
  color:inherit;
}
button:focus-visible,input:focus-visible{outline:3px solid var(--gold);outline-offset:2px}
button:disabled{cursor:default}
[hidden]{display:none!important}

.shell{
  max-width:1480px;
  margin:auto;
  padding:clamp(10px,1.6vw,24px);
  min-height:100dvh;
  display:flex;
  flex-direction:column;
  gap:12px;
}

header{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
.brand{display:flex;gap:11px;align-items:center}
.logo{
  display:grid;place-items:center;
  background:var(--cyan);color:#102139;
  border-radius:14px;width:46px;height:46px;
  font-size:34px;font-weight:900;
}
.brand h1{font-size:clamp(19px,2vw,32px);margin:0;letter-spacing:-.04em;line-height:1.05}
.sub{color:var(--muted);font-size:clamp(11px,1.1vw,15px);margin-top:4px}
.tools{display:flex;gap:7px;flex-wrap:wrap}
.tool{
  border:1px solid var(--line);
  background:#172944;
  border-radius:9px;
  padding:9px 12px;
  font-size:clamp(12px,1vw,16px);
  min-height:40px;
}
.tool:hover{background:#263e5d}

.statusbar{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.duel-status{grid-template-columns:repeat(2,minmax(0,1fr))}
.stat{
  border:1px solid var(--line);border-radius:13px;background:#14243d;
  padding:7px 13px;display:flex;justify-content:space-between;align-items:center;gap:8px;
}
.stat-label{color:var(--muted);font-size:clamp(11px,1.2vw,17px)}
.stat strong{font-size:clamp(20px,3vw,42px);line-height:1.1;font-variant-numeric:tabular-nums}
.time strong{color:var(--gold)}
.right strong{color:var(--lime)}
.progress{height:6px;background:#233452;border-radius:99px;overflow:hidden}
.progress div{height:100%;background:linear-gradient(90deg,var(--cyan),var(--lime));width:0}

/* Svarsruta 1–100 */
.board-wrap{min-width:0;min-height:0;display:flex;align-items:stretch;justify-content:stretch;flex:1}
.board{
  width:100%;height:100%;min-width:0;min-height:0;
  display:grid;
  grid-template-columns:repeat(10,minmax(0,1fr));
  grid-template-rows:repeat(10,minmax(0,1fr));
  gap:clamp(2px,.24vw,6px);
}
.cell{
  min-width:0;min-height:0;padding:0;
  display:grid;place-items:center;
  border:1px solid #41577a;
  background:#223958;
  border-radius:clamp(3px,.45vw,9px);
  font-size:clamp(15px,min(2.5vw,4.3vh),50px);
  font-weight:850;line-height:1;
  font-variant-numeric:tabular-nums;
}
.cell:nth-child(20n+11),.cell:nth-child(20n+12),.cell:nth-child(20n+13),.cell:nth-child(20n+14),.cell:nth-child(20n+15),
.cell:nth-child(20n+16),.cell:nth-child(20n+17),.cell:nth-child(20n+18),.cell:nth-child(20n+19),.cell:nth-child(20n+20){
  background:#1b2f4b;
}
.cell:nth-child(10n){border-color:#53708e;color:#d5f7ff}
.cell:not(:disabled):active{background:#44688a;transform:translateY(1px)}
.cell.correct{background:var(--lime)!important;color:#142a11!important;border-color:var(--lime);box-shadow:0 0 12px #a6f17a77}
.cell.wrong{background:#ff9aa7!important;color:#3a1020!important;border-color:#ff9aa7}
.cell:disabled{opacity:1}
@media(hover:hover){.cell:not(:disabled):hover{background:#395b7c;border-color:#88d7ec}}

/* Plus & minus 0–20 bräde (både solo och duell) */
.board.pm-board{
  grid-template-columns:repeat(20,minmax(0,1fr));
  grid-template-rows:minmax(0,.72fr) repeat(2,minmax(0,1fr));
  gap:clamp(3px,.3vw,7px);
}
.board.pm-board .cell{
  grid-column:span 2;
  font-size:clamp(19px,min(3vw,6.2vh),58px);
  border-radius:clamp(6px,.7vw,13px);
  font-weight:950;
  background:#223958;
  color:var(--ink);
  border-color:#41577a;
}
.board.pm-board .cell:first-child{
  grid-column:9/span 4;
  grid-row:1;
  font-size:clamp(24px,min(3.5vw,7vh),66px);
}
.board.pm-board .cell:nth-child(n+2):nth-child(-n+11){grid-row:2;background:#223958}
.board.pm-board .cell:nth-child(n+12){grid-row:3;background:#1b2f4b}
@media(hover:hover){
  .board.pm-board .cell:not(:disabled):not(.correct):not(.wrong):hover{background:#395b7c}
}

.game{display:flex;gap:12px;flex:1;min-height:0}
.side{
  border:1px solid var(--line);border-radius:18px;background:#1b3656;
  padding:18px;text-align:center;
  display:flex;flex-direction:column;justify-content:center;align-items:center;
  flex:0 0 30%;
}
.eyebrow{text-transform:uppercase;letter-spacing:.1em;color:var(--cyan);font-size:14px;margin:0}
.question{font-size:clamp(36px,6vw,90px);font-weight:950;margin:15px 0;white-space:nowrap}
.hint{color:var(--muted);font-size:16px}
.feedback{
  color:var(--muted);font-size:clamp(16px,1.7vw,25px);
  font-weight:850;min-height:20px;line-height:1.2;
}
.feedback small{display:block;font-size:.7em}
.feedback.good,.duel-feedback.good{color:var(--lime)}
.feedback.bad,.duel-feedback.bad{color:var(--red)}

/* Skärmknappsats & tangentbordsvy (Solo) */
.solo-pad-area{
  width:100%;height:100%;
  display:grid;place-items:center;
  padding:clamp(6px,1.5vh,20px);
}
.solo-pad-card{
  width:min(520px,100%);
  max-height:100%;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:clamp(8px,1.5vh,18px);
  background:#142540;
  border:1px solid #3c567d;
  border-radius:22px;
  padding:clamp(12px,2.2vh,28px) clamp(14px,2.5vw,32px);
  box-shadow:0 16px 50px #060d1b88;
}
.solo-pad-meta{
  font-size:clamp(12px,1.2vw,16px);
  color:var(--cyan);
  text-transform:uppercase;
  letter-spacing:.08em;
}
.solo-pad-equation{
  font-size:clamp(42px,min(8vw,10vh),88px);
  font-weight:1000;
  line-height:1;
  letter-spacing:-.04em;
  white-space:nowrap;
}
.answer-display{
  width:100%;
  min-height:clamp(58px,9vh,92px);
  border-radius:16px;
  border:2px solid #4d6b94;
  background:#0c192f;
  display:grid;place-items:center;
  font-size:clamp(34px,min(6vw,7.5vh),64px);
  font-weight:950;
  font-variant-numeric:tabular-nums;
  letter-spacing:.06em;
  transition:border-color .15s,background-color .15s;
}
.answer-display.has-value{border-color:var(--cyan)}
.answer-display.correct{background:#214228;border-color:var(--lime);color:var(--lime)}
.answer-display.wrong{background:#471d2f;border-color:#ff9aa7;color:#ffb8c2}
.answer-placeholder{opacity:.35;animation:blink 1.1s steps(1) infinite}
@keyframes blink{50%{opacity:.08}}

.keypad-grid{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:clamp(6px,1vh,11px);
}
.keypad-btn{
  min-height:clamp(50px,8vh,74px);
  border:1px solid #49658b;
  border-radius:14px;
  background:#223958;
  font-size:clamp(24px,min(3.5vw,4.5vh),38px);
  font-weight:900;
  font-variant-numeric:tabular-nums;
  display:grid;place-items:center;
  box-shadow:0 3px 0 #101d32;
}
.keypad-btn:not(:disabled):active{transform:translateY(2px);background:#3a5b82}
@media(hover:hover){.keypad-btn:not(:disabled):hover{background:#314f75;border-color:#88d7ec}}
.keypad-btn.key-back{background:#3a2739;border-color:#805173;color:#ffc4d2;font-size:clamp(20px,3vw,30px)}
.keypad-btn.key-back:not(:disabled):hover{background:#4f324d}
.keypad-btn.key-submit{background:var(--lime);color:#132b15;border-color:var(--lime);box-shadow:0 3px 0 #6eaa41}
.keypad-btn.key-submit:not(:disabled):hover{background:#d2ff9d}
.keypad-btn:disabled{opacity:.55}

.keyboard-helper{width:100%;text-align:center;display:flex;flex-direction:column;gap:12px;align-items:center}
.keyboard-tip{margin:0;color:var(--muted);font-size:clamp(13px,1.2vw,17px);line-height:1.45}
.keyboard-tip kbd{
  display:inline-block;padding:2px 7px;border-radius:6px;
  border:1px solid #587298;background:#1a2e4d;color:var(--ink);font-size:.9em;
}
.keyboard-actions{display:flex;gap:10px;justify-content:center;flex-wrap:wrap;width:100%}
.keypad-footnote{margin:0;color:var(--muted);font-size:clamp(11px,1vw,14px);text-align:center}

/* Duell-knappsats */
.duel-keypad-wrap{
  flex:1;min-height:0;
  display:flex;flex-direction:column;justify-content:center;
  gap:clamp(6px,1vh,12px);
  padding:clamp(4px,1vw,14px);
}
.duel-answer-display{
  min-height:clamp(48px,8.5vh,84px);
  font-size:clamp(28px,min(4.5vw,6.8vh),56px);
}
.duel-keypad{flex:1;min-height:0;grid-template-rows:repeat(4,minmax(0,1fr))}
.duel-keypad .keypad-btn{min-height:0;height:100%;font-size:clamp(20px,min(3vw,4.6vh),40px)}

/* Startmeny & modaler */
.overlay{
  position:fixed;inset:0;display:grid;place-items:center;overflow:auto;z-index:6;
  background:#080f20c8;padding:16px;backdrop-filter:blur(7px);
}
.intro{
  width:min(760px,100%);max-height:100%;overflow:auto;text-align:center;
  background:#172b48;border:1px solid #4a658b;border-radius:26px;
  padding:clamp(18px,3.2vw,38px);box-shadow:0 24px 100px #050914aa;
}
.intro-icon{font-size:clamp(34px,5.5vw,62px);line-height:1}
.intro h2{font-size:clamp(28px,4.5vw,50px);line-height:1.06;letter-spacing:-.05em;margin:10px 0 6px}
.intro .instructions{font-size:clamp(14px,1.6vw,19px);color:var(--muted);line-height:1.35;margin:6px 0 16px}

.play-choices{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:0 0 14px}
.mode-choice{
  border:2px solid #49617e;border-radius:15px;background:#213651;
  padding:12px 8px;min-height:90px;text-align:center;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;
}
.mode-choice strong{font-size:clamp(15px,1.7vw,22px)}
.mode-choice span{font-size:clamp(11px,1.05vw,14px);color:#c2d6ea}
.mode-choice.selected{border-color:var(--lime);background:#254d47;box-shadow:inset 0 0 0 1px var(--lime)}

.config-panel{
  display:flex;flex-direction:column;gap:12px;
  background:#101f37;border:1px solid #354f73;border-radius:18px;
  padding:clamp(12px,1.8vw,18px);text-align:left;margin-bottom:14px;
}
.config-group{display:flex;flex-direction:column;gap:6px}
.config-label{
  font-size:12px;text-transform:uppercase;letter-spacing:.09em;color:var(--muted);font-weight:800;
}
.seg-row{display:grid;gap:8px}
.seg-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.seg-3{grid-template-columns:repeat(3,minmax(0,1fr))}
.seg-4{grid-template-columns:repeat(4,minmax(0,1fr))}
.seg-btn{
  border:2px solid #3f577a;border-radius:12px;background:#1b314f;
  padding:9px 8px;min-height:46px;
  display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  font-size:clamp(13px,1.2vw,16px);font-weight:800;text-align:center;
}
.seg-btn small{font-size:clamp(10px,.95vw,12px);color:var(--muted);font-weight:650}
.seg-btn:not(:disabled):hover{background:#254166}
.seg-btn.selected{border-color:var(--cyan);background:#1b455e;color:#fff}
.seg-btn.selected small{color:#d0f6ff}
.seg-btn:disabled{opacity:.42;border-style:dashed}

.compete-box{
  border-top:1px solid #2d4466;padding-top:12px;
  display:flex;flex-direction:column;gap:9px;
}
.toggle-row{display:flex;align-items:center;gap:12px;cursor:pointer;user-select:none}
.toggle-row input{position:absolute;opacity:0;width:1px;height:1px}
.toggle-switch{
  flex:0 0 48px;height:28px;border-radius:999px;
  background:#2d4261;border:1px solid #526e94;position:relative;
  transition:background .15s,border-color .15s;
}
.toggle-switch::after{
  content:"";position:absolute;top:3px;left:3px;width:20px;height:20px;border-radius:50%;
  background:#d8e6f8;transition:transform .15s,background .15s;
}
.toggle-row input:checked + .toggle-switch{background:#2a5b46;border-color:var(--lime)}
.toggle-row input:checked + .toggle-switch::after{transform:translateX(20px);background:var(--lime)}
.toggle-row input:focus-visible + .toggle-switch{outline:3px solid var(--gold);outline-offset:2px}
.toggle-text{display:flex;flex-direction:column;gap:2px}
.toggle-text strong{font-size:clamp(14px,1.3vw,17px)}
.toggle-text small{color:var(--muted);font-size:clamp(11px,1vw,13px)}

.player-name-wrap input,.highscore-form input{
  width:100%;
  background:#0b182d;color:var(--ink);
  border:2px solid #48688f;border-radius:11px;
  padding:10px 13px;font:700 16px/1.3 system-ui,sans-serif;
}
.player-name-wrap input::placeholder,.highscore-form input::placeholder{color:#7f97b8}

.intro-rule{font-size:clamp(13px,1.35vw,17px);color:var(--muted);line-height:1.4;margin:8px 0}
.chips{display:flex;justify-content:center;gap:7px;flex-wrap:wrap;margin:10px 0 16px}
.chip{font-size:12px;border:1px solid #476383;background:#213c5d;border-radius:999px;padding:5px 11px;color:#e5f4ff}

.primary{
  background:var(--lime);color:#132b15;border:0;border-radius:13px;
  padding:13px 26px;font-size:clamp(17px,1.8vw,24px);font-weight:900;min-height:50px;
  box-shadow:0 5px 0 #6eaa41;
}
.primary:hover{background:#d2ff9d}
.secondary{
  border:1px solid #587195;background:#243e5e;border-radius:12px;
  padding:11px 16px;font-size:16px;min-height:44px;
}
.secondary:hover{background:#2e4e74}
.small-btn{padding:8px 14px;font-size:14px;min-height:38px}
.small-primary{padding:10px 18px;font-size:16px;min-height:44px;box-shadow:0 3px 0 #6eaa41}
.intro-main-actions{display:flex;justify-content:center}
.intro-sub-actions{display:flex;justify-content:center;gap:10px;flex-wrap:wrap;margin-top:12px}

/* Resultatvy & Highscore-kort */
.results{width:min(1100px,100%);margin:0 auto;padding:12px 0 30px}
.results-top{text-align:center;margin-bottom:18px}
.results h2{font-size:clamp(30px,4.5vw,60px);margin:10px 0;line-height:1.1}
.results p{color:var(--muted);font-size:clamp(15px,1.5vw,21px);margin:8px 0}
.result-category-badge{
  display:inline-block;margin-top:6px;padding:6px 14px;border-radius:999px;
  border:1px solid #4d6e96;background:#193152;color:#d6f5ff;font-size:14px;font-weight:800;
}
.summary{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin:20px 0}
.summary>div{
  background:#172b48;border:1px solid #415778;border-radius:17px;
  padding:clamp(12px,2vw,22px);text-align:center;
}
.summary span{display:block;color:var(--muted);font-size:clamp(13px,1.3vw,19px)}
.summary strong{display:block;font-size:clamp(25px,4vw,58px);font-variant-numeric:tabular-nums;margin-top:5px}
.summary>div:first-child strong{color:var(--gold)}
.summary>div:nth-child(2) strong{color:var(--lime)}
.summary>div:nth-child(3) strong{color:var(--red)}

.highscore-card{
  background:#162c47;border:1px solid #46698e;border-radius:17px;
  padding:clamp(14px,2vw,22px);margin:0 0 18px;
}
.highscore-card-head{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:8px}
.highscore-card h3{margin:0;font-size:clamp(18px,2vw,24px);color:var(--gold)}
.highscore-status{margin:0;font-size:clamp(14px,1.4vw,18px);color:#e4f2ff}
.highscore-status.good{color:var(--lime);font-weight:850}
.highscore-status.bad{color:var(--red)}
.highscore-form{display:flex;gap:10px;flex-wrap:wrap;margin-top:12px}
.highscore-form input{flex:1 1 220px}

.review{background:#14243d;border:1px solid var(--line);border-radius:17px;padding:clamp(12px,2vw,24px)}
.review h3{font-size:clamp(18px,2.2vw,29px);margin:0 0 12px}
.review-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,220px),1fr));gap:9px}
.review-item{border:1px solid #3d5476;border-radius:11px;padding:12px;background:#1b304c}
.review-item strong{font-size:clamp(20px,2.3vw,30px);color:var(--lime);display:block}
.review-item span{display:block;color:var(--red);font-size:clamp(14px,1.3vw,18px);margin-top:4px}
.actions{display:flex;justify-content:center;flex-wrap:wrap;gap:12px;margin-top:22px}
.perfect{color:var(--lime);font-size:24px;text-align:center;padding:16px}

.duel-result-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px;margin:18px 0}
.duel-result-team{
  text-align:center;border:2px solid var(--team-line);background:#192f4b;
  padding:clamp(13px,2vw,23px);border-radius:18px;
}
.blue{--team-line:#5cbdf9;--team-ink:#72d1ff}
.pink{--team-line:#f79ac5;--team-ink:#ffafda}
.duel-result-team span{display:block;font-size:clamp(17px,2vw,28px);color:var(--team-ink)}
.duel-result-team strong{font-size:clamp(48px,7vw,100px);line-height:1.2;color:var(--team-ink);display:block}
.duel-result-team b{font-size:clamp(12px,1.2vw,16px)}
.duel-result-team.winner{background:#263e40;border-color:var(--lime)}

.confetti{position:fixed;pointer-events:none;width:9px;height:16px;z-index:9;top:-20px;animation:fall 1.7s ease-in forwards}
@keyframes fall{to{transform:translate(var(--dx),110vh) rotate(740deg);opacity:.1}}
.star.latest{animation:star-pulse .46s ease-out}
@keyframes star-pulse{0%{transform:scale(.5)}55%{transform:scale(1.4)}100%{transform:scale(1.14)}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}.confetti{display:none}}

/* Gemensam smartboardvy */
body.in-game{height:100dvh;overflow:hidden;overscroll-behavior:none}
body.in-game .shell{
  max-width:none;height:100dvh;min-height:0;overflow:hidden;
  padding:clamp(3px,.55vh,8px) clamp(4px,.6vw,12px);
  gap:clamp(3px,.55vh,8px);
}
body.in-game header{flex:0 0 auto;min-height:0;gap:5px;flex-wrap:nowrap}
body.in-game header .tools{flex-wrap:nowrap;gap:4px}
body.in-game header .tool{
  white-space:nowrap;min-height:0;
  font-size:clamp(10px,.95vw,15px);
  padding:clamp(5px,.8vh,9px) clamp(5px,.55vw,11px);
}
body.in-game .logo{width:clamp(26px,4.8vh,44px);height:clamp(26px,4.8vh,44px);font-size:clamp(20px,3.5vh,32px)}
body.in-game .brand h1{font-size:clamp(15px,2vw,27px)}
body.in-game .sub{font-size:clamp(10px,.9vw,13px)}

/* Solo smartboardvy */
.solo-compact-bar,.solo-steps,.duel-landscape-bar,.duel-stars{display:none}
body.in-game.solo-active .shell{
  display:grid;
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:clamp(53px,8.1vh,81px) clamp(30px,4.7vh,49px) minmax(0,1fr);
}
body.in-game.solo-active header{grid-column:1;grid-row:1;justify-self:end;z-index:3;pointer-events:none}
body.in-game.solo-active header .brand{display:none}
body.in-game.solo-active header .tools{pointer-events:auto}
body.in-game.solo-active #openLeaderboard{display:none}
body.in-game.solo-active #statusbar,body.in-game.solo-active #progress{display:none!important}

.solo-compact-bar{
  border:1px solid #3b5276;background:#1b304d;
  border-radius:clamp(8px,1vw,15px);
  font-variant-numeric:tabular-nums;min-width:0;min-height:0;
}
body.in-game.solo-active .solo-compact-bar{
  grid-column:1;grid-row:1;
  display:grid;grid-template-columns:minmax(0,1fr) max-content minmax(0,1fr);
  align-items:center;padding:0 clamp(4px,.65vw,12px);
}
.solo-info-left,.solo-info-right{display:flex;align-items:center;gap:clamp(5px,.9vw,15px);min-width:0}
.solo-info-left{justify-content:space-evenly}
.solo-info-right{justify-content:flex-start;padding-left:clamp(5px,1.8vw,27px);padding-right:clamp(230px,23vw,330px)}
.solo-metric{white-space:nowrap;font-size:clamp(11px,1.1vw,19px);font-weight:800;color:#d1def0}
.solo-metric strong{font-size:clamp(15px,1.7vw,29px);font-weight:950;color:var(--gold)}
.solo-score strong{color:var(--lime)}
.solo-badge{
  padding:4px 9px;border-radius:999px;border:1px solid #4c6c92;background:#142844;
  color:var(--cyan);font-size:clamp(10px,.9vw,14px);white-space:nowrap;
}
.solo-wide-question{
  text-align:center;font-weight:1000;white-space:nowrap;
  font-size:clamp(40px,min(6.2vw,9.1vh),82px);line-height:1;letter-spacing:-.055em;
}

.solo-steps{
  grid-template-columns:repeat(36,minmax(0,1fr));
  gap:clamp(2px,.24vw,6px);padding:clamp(3px,.5vh,6px);
  border:1px solid #36506f;border-radius:9px;background:#14243de8;
}
.solo-step{min-width:0;min-height:0;background:#384d69;border-radius:clamp(2px,.3vw,6px)}
.solo-step.done-right{background:var(--lime)}
.solo-step.done-wrong{background:#ff98ab}
body.in-game.solo-active .solo-steps{display:grid;grid-column:1;grid-row:2}

body.in-game.solo-active #game{
  display:block;position:relative;grid-column:1;grid-row:3;
  height:100%;min-width:0;min-height:0;overflow:hidden;
  border:1px solid #3275a7;border-radius:clamp(9px,1vw,17px);
  background:#1b3656;padding:clamp(3px,.4vw,7px);
}
body.in-game.solo-active #game .side{display:none}
body.in-game.solo-active #game .board-wrap{width:100%;height:100%}
body.in-game.solo-active #game .cell{font-size:clamp(20px,min(3.45vw,5.5vh),62px);font-weight:900}
body.in-game.solo-active #feedback{
  position:absolute;z-index:2;pointer-events:none;
  top:clamp(8px,1.5vh,18px);left:50%;transform:translateX(-50%);
  width:max-content;max-width:92%;height:auto;min-height:0;margin:0;
  border:1px solid #537194;border-radius:100px;background:#0b1729ef;
  padding:clamp(7px,1.1vh,14px) clamp(14px,1.5vw,26px);text-align:center;
}
body.in-game.solo-active #feedback:empty{display:none}
body.in-game.solo-active #feedback.good{background:#203b2bf2;border-color:var(--lime)}
body.in-game.solo-active #feedback.bad{background:#431d32f2;border-color:#ff9aa7}

/* Duellvy */
body.in-game.duel-active #openLeaderboard{display:none}
.duel-game{position:relative;display:flex;flex-direction:column;gap:clamp(4px,.7vh,9px);flex:1;min-width:0;min-height:0}
.duel-question-card{
  flex:0 0 auto;min-height:60px;border:1px solid #3e5578;border-radius:13px;background:#182e4d;
  display:flex;justify-content:center;align-items:center;gap:clamp(8px,2.5vw,40px);padding:4px 8px;text-align:center;
}
.duel-question{font-size:clamp(32px,6.8vh,80px);line-height:1;font-weight:950;white-space:nowrap}
.duel-round-notice{font-size:clamp(10px,1.1vw,17px);color:var(--gold)}
.duel-boards{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));grid-template-rows:minmax(0,1fr);
  gap:clamp(5px,.85vw,15px);flex:1;min-height:0;
}
.duel-player{
  position:relative;display:flex;flex-direction:column;gap:clamp(3px,.5vh,7px);
  min-width:0;min-height:0;overflow:hidden;
  padding:clamp(4px,.65vw,10px);
  border:2px solid var(--team-line);border-radius:clamp(10px,1vw,17px);background:#132540;
}
.duel-player-head{
  display:flex;justify-content:space-between;align-items:center;gap:5px;
  flex:0 0 auto;height:clamp(32px,6vh,54px);padding:2px clamp(6px,.85vw,14px);
  border-radius:10px;background:#1d3453;
}
.duel-team{font-size:clamp(13px,2.45vh,29px);font-weight:900;color:var(--team-ink);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.duel-points{font-size:clamp(12px,2.1vh,23px);white-space:nowrap}
.duel-points strong{font-size:clamp(21px,3.7vh,44px);margin-left:3px;color:var(--team-ink)}
.duel-player .board-wrap{width:100%;height:auto}
.duel-player .cell{font-size:clamp(11px,min(1.7vw,2.8vh),29px);box-shadow:none}
.duel-feedback{
  height:clamp(19px,3.3vh,32px);flex:0 0 auto;
  display:flex;justify-content:center;align-items:center;
  font-size:clamp(11px,2.2vh,19px);font-weight:850;white-space:nowrap;
}
.duel-player.won-round{border-color:var(--lime);box-shadow:0 0 21px #baf47760}
.duel-player.lost-round{opacity:.8}

body.in-game.duel-active .duel-stars{
  display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
  flex:0 0 auto;height:clamp(29px,4.5vh,48px);gap:clamp(5px,.85vw,15px);
}
.stars-side{
  display:grid;grid-template-columns:repeat(10,minmax(0,1fr));
  align-items:center;justify-items:center;
  border:1px solid #35496d;border-radius:9px;background:#14243de8;
  min-height:0;min-width:0;padding:0 clamp(4px,.65vw,11px);
}
.stars-blue{border-color:#3275a7}
.stars-pink{border-color:#b56692}
.star{
  font-size:clamp(16px,min(2.25vw,3.9vh),35px);line-height:1;
  color:#485978;text-shadow:0 1px 0 #080f20;text-align:center;user-select:none;
}
.star.lit{color:#ffdb59;text-shadow:0 0 9px #ffcd3b95,0 0 2px #fff9b2;transform:scale(1.14)}

.duel-start-layer{
  position:absolute;inset:0;z-index:5;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:clamp(12px,3vh,28px);border-radius:inherit;
  background:linear-gradient(140deg,#142e4af5,#0a1528f4);
  padding:clamp(8px,1vw,20px);
}
.start-caption{font-size:clamp(19px,2.65vw,39px);font-weight:950;text-align:center;max-width:100%;overflow-wrap:anywhere}
#blueStartLayer .start-caption{color:#72d1ff}
#pinkStartLayer .start-caption{color:#ffafda}
.duel-ready-button{
  width:min(82%,360px);min-height:clamp(105px,23vh,200px);
  border-radius:clamp(18px,2.2vw,35px);font-weight:1000;font-size:clamp(35px,4.7vw,73px);
  border:3px solid #ffffff80;box-shadow:0 9px 0 #070d17,0 10px 42px #071021bd;
  touch-action:none;user-select:none;-webkit-user-select:none;
}
.blue-ready{background:#54c1f4;color:#08243d}
.pink-ready{background:#ffa5d0;color:#41122c}
.duel-ready-button.is-ready,.duel-ready-button.is-ready:disabled{
  opacity:1;background:#d8f983;color:#1e3616;border-color:#fff;
  box-shadow:0 0 36px #baf4778c;transform:translateY(4px);
}

.duel-countdown{
  position:absolute;inset:0;z-index:9;
  display:flex;flex-direction:column;align-items:center;justify-content:center;
  gap:clamp(9px,2vh,22px);
  background:radial-gradient(ellipse at center,#263e66f5,#091529fc 75%);
  border-radius:16px;text-align:center;pointer-events:auto;
}
.duel-countdown .countdown-label{font-size:clamp(24px,4vw,54px);font-weight:950;color:#e6f2ff;letter-spacing:.035em}
.duel-countdown .countdown-number{
  font-size:clamp(130px,31vh,315px);font-weight:1000;line-height:1;
  color:#ffe26d;text-shadow:0 0 45px #d9a43299,0 8px 0 #563f19;font-variant-numeric:tabular-nums;
}
.duel-countdown .countdown-number.pulse{animation:count-pop .25s ease-out}
.duel-countdown .countdown-help{font-size:clamp(18px,2vw,30px);font-weight:800;color:#cee6fa}
@keyframes count-pop{from{transform:scale(1.2);opacity:.65}to{transform:scale(1);opacity:1}}
.start-help{color:#d8e5f7;font-size:clamp(14px,1.55vw,24px);text-align:center}
body.waiting-duel .duel-feedback{display:none!important}

/* Liggande smartboard för duell */
@media (orientation:landscape) and (min-width:800px){
  body.in-game.duel-active .shell{
    display:grid;grid-template-columns:minmax(0,1fr);
    grid-template-rows:clamp(53px,8.1vh,81px) clamp(30px,4.7vh,49px) minmax(0,1fr);
  }
  body.in-game.duel-active header{grid-column:1;grid-row:1;justify-self:end;align-self:stretch;z-index:3;pointer-events:none}
  body.in-game.duel-active header .brand{display:none}
  body.in-game.duel-active header .tools{pointer-events:auto}
  body.in-game.duel-active #duelStatus{display:none!important}
  body.in-game.duel-active .duel-landscape-bar{
    display:grid;grid-column:1;grid-row:1;
    grid-template-columns:minmax(0,1fr) max-content minmax(0,1fr);
    align-items:center;min-width:0;min-height:0;
    border:1px solid #3b5276;border-radius:clamp(8px,1vw,15px);background:#1b304d;
    padding:0 clamp(4px,.65vw,12px);font-variant-numeric:tabular-nums;
  }
  .land-info-left{display:flex;align-items:center;justify-content:space-evenly;gap:clamp(3px,.6vw,12px);min-width:0}
  .land-info-right{display:flex;align-items:center;justify-content:flex-start;min-width:0;padding-left:clamp(5px,1.8vw,27px);padding-right:clamp(225px,23vw,325px)}
  .land-team{display:flex;align-items:center;justify-content:center;gap:clamp(3px,.45vw,10px);white-space:nowrap;font-size:clamp(12px,1.3vw,24px);font-weight:900}
  .land-team>span{max-width:clamp(66px,11vw,190px);overflow:hidden;text-overflow:ellipsis;display:inline-block;white-space:nowrap}
  .land-blue{color:#72d1ff}
  .land-pink{color:#ffafda}
  .land-team strong{font-size:clamp(21px,2.2vw,38px);line-height:1}
  .land-metric{display:flex;align-items:center;justify-content:center;gap:clamp(3px,.45vw,8px);color:#d1def0;font-size:clamp(11px,1vw,17px);white-space:nowrap}
  .land-metric strong{font-size:clamp(14px,1.55vw,25px);color:var(--gold)}
  .land-question{text-align:center;white-space:nowrap;font-weight:950;font-size:clamp(38px,min(6.2vw,9.1vh),79px);letter-spacing:-.055em;line-height:1}

  body.in-game.duel-active .duel-stars{grid-column:1;grid-row:2;height:100%}
  body.in-game.duel-active #duelGame{grid-column:1;grid-row:3;overflow:hidden;gap:0}
  body.in-game.duel-active .duel-question-card{display:none}
  body.in-game.duel-active .duel-player{padding:clamp(3px,.4vw,7px);gap:0}
  body.in-game.duel-active .duel-player-head{display:none}
  body.in-game.duel-active .duel-player .board-wrap{height:100%;min-height:0}
  body.in-game.duel-active .duel-player .cell{font-size:clamp(17px,min(2.3vw,4.3vh),50px)}
  body.in-game.duel-active .duel-feedback{
    position:absolute;top:clamp(7px,1.5vh,20px);left:50%;transform:translateX(-50%);
    z-index:2;pointer-events:none;height:auto;width:max-content;max-width:90%;
    padding:clamp(8px,1.1vh,13px) clamp(12px,1.2vw,22px);
    border:1px solid #537194;border-radius:100px;background:#0b1729ec;
    font-size:clamp(14px,1.5vw,25px);box-shadow:0 6px 24px #0008;text-align:center;
  }
  body.in-game.duel-active .duel-feedback:not(.good):not(.bad){display:none}
  body.in-game.duel-active .duel-feedback.bad{border-color:#ff9aa7;background:#431d32f2;color:#fff}
  body.in-game.duel-active .duel-feedback.good{border-color:var(--lime);background:#203b2bf2;color:#fff}
}

@media (orientation:landscape) and (min-width:800px) and (max-width:1100px){
  body.in-game header .tool{font-size:10px;padding:6px 5px}
  .land-info-left{gap:2px}
  .land-team{font-size:11px;gap:3px}
  .land-team strong{font-size:23px}
  .land-metric{font-size:10px;gap:3px}
  .land-metric strong{font-size:14px}
  .land-info-right,.solo-info-right{padding-left:4px;padding-right:clamp(210px,26vw,270px)}
  .solo-info-left{gap:4px}
  .solo-metric{font-size:11px}
  .solo-metric strong{font-size:16px}
  .solo-badge{display:none}
}

/* Stående läge / mindre skärmar */
@media (orientation:portrait),(max-width:799px){
  body.in-game.solo-active .shell{
    grid-template-rows:clamp(35px,5vh,54px) clamp(54px,9vh,83px) clamp(28px,4vh,42px) minmax(0,1fr);
    padding:clamp(4px,.8vw,9px);
  }
  body.in-game.solo-active header{grid-column:1;grid-row:1;justify-self:stretch;justify-content:flex-end}
  body.in-game.solo-active .solo-compact-bar{grid-column:1;grid-row:2}
  body.in-game.solo-active .solo-steps{grid-column:1;grid-row:3}
  body.in-game.solo-active #game{grid-column:1;grid-row:4}
  body.in-game.solo-active .solo-wide-question{font-size:clamp(28px,min(6vw,6vh),58px)}
  body.in-game.solo-active .solo-metric{font-size:clamp(9px,1.5vw,13px)}
  body.in-game.solo-active .solo-metric strong{font-size:clamp(12px,2.4vw,19px)}
  body.in-game.solo-active .solo-info-right{padding:0 4px;justify-content:center}
  body.in-game.solo-active .solo-info-left{flex-direction:column;gap:0}
  body.in-game.solo-active .solo-badge{display:none}
  body.in-game.solo-active #game .cell{font-size:clamp(15px,min(5.1vw,4vh),44px)}
  body.in-game.duel-active .shell{display:flex;flex-direction:column}
  body.in-game.duel-active .duel-question-card{height:clamp(51px,9vh,90px)}
  body.in-game.duel-active .duel-player .cell{font-size:clamp(10px,min(2vw,2.8vh),23px)}
  body.in-game.duel-active .duel-stars{height:clamp(28px,3.8vh,38px)}
  .star{font-size:clamp(13px,min(3.2vw,2.8vh),26px)}
  .duel-ready-button{min-height:clamp(90px,14vh,160px);font-size:clamp(26px,4.5vw,56px)}
}

@media (max-width:620px){
  body.in-game .logo,body.in-game .sub{display:none}
  body.in-game .brand h1{font-size:13px}
  body.in-game header .tool{font-size:10px;padding:4px}
  body.in-game .stat{padding:3px 5px}
  body.in-game .stat strong{font-size:20px}
  body.in-game.duel-active .duel-player-head{flex-direction:column;gap:0;height:43px;padding:2px}
  body.in-game.duel-active .duel-team,body.in-game.duel-active .duel-points{font-size:11px}
  body.in-game.duel-active .duel-points strong{font-size:14px}
  .duel-feedback{font-size:10px}
  .duel-player .board{gap:1px}
  .duel-player .cell{font-size:clamp(8px,2vw,13px)}
  .play-choices{grid-template-columns:1fr;gap:7px}
  .mode-choice{min-height:64px;padding:10px 8px}
  .seg-3{grid-template-columns:1fr}
}

@media (orientation:landscape) and (max-height:520px) and (min-width:800px){
  body.in-game.solo-active .shell,body.in-game.duel-active .shell{grid-template-rows:45px 27px minmax(0,1fr)}
  .solo-wide-question{font-size:clamp(30px,7.5vh,50px)}
  .star{font-size:clamp(14px,3.8vh,25px)}
  .start-help{font-size:12px}
  .duel-ready-button{min-height:clamp(70px,19vh,110px)}
}

/* Turnering & Topplista */
.tour-overlay,.lb-overlay{z-index:12}
.tour-dialog{
  background:#172b48;border:1px solid #4d6c92;border-radius:22px;
  box-shadow:0 20px 90px #040a16db;width:min(1070px,100%);
  max-height:min(94dvh,980px);overflow:auto;padding:clamp(15px,2.6vw,30px);
}
.lb-dialog{width:min(820px,100%)}
.tour-dialog h2{margin:0 0 7px;font-size:clamp(24px,3.6vw,42px);letter-spacing:-.035em}
.tour-muted{color:var(--muted);line-height:1.45;font-size:clamp(13px,1.3vw,17px)}

.tour-config-grid{display:flex;flex-direction:column;gap:12px;margin:14px 0}
.tour-subjects{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-top:6px}
.tour-tri{grid-template-columns:repeat(3,minmax(0,1fr))}
.tour-option{
  padding:11px 7px;border:2px solid #4a6081;border-radius:12px;background:#243d60;
  min-height:52px;font-weight:900;font-size:clamp(14px,1.4vw,18px);
}
.tour-option.active{border-color:var(--lime);background:#234a43}
.tour-option:disabled{opacity:.42;border-style:dashed}

.tour-label{display:block;font-size:17px;font-weight:850;margin:14px 0 7px}
#tourNames{
  display:block;width:100%;min-height:140px;background:#0c1d36;color:white;
  font:700 clamp(17px,2vw,22px)/1.5 system-ui,sans-serif;resize:vertical;
  border:2px solid #4e7395;border-radius:14px;padding:12px 16px;
}
#tourNames:focus{outline:3px solid var(--gold);outline-offset:3px}
.tour-count{margin:8px 0 15px;color:var(--gold);font-weight:850}
.tour-actions{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin:18px 0 0}
.tour-hero{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-bottom:14px}
.tour-badge{display:inline-block;padding:6px 12px;border:1px solid #6887a6;background:#203b59;border-radius:20px;font-size:14px;color:#daebff;font-weight:850}
.tour-feature{
  border:1px solid #5f8770;border-radius:17px;background:#25473d;
  padding:clamp(14px,2vw,23px);margin:15px 0;
  display:flex;gap:14px;align-items:center;justify-content:space-between;flex-wrap:wrap;
}
.tour-feature strong{font-size:clamp(19px,2vw,27px);display:block}
.tour-feature p{margin:4px 0 0;color:#d4f6e1}
.tour-progress{font-size:clamp(14px,1.5vw,18px);color:var(--gold);font-weight:800}
.tour-columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:13px}
.tour-section{background:#101f37;border:1px solid #3b577b;border-radius:16px;padding:clamp(12px,1.5vw,18px);min-width:0}
.tour-section h3{margin:0 0 10px;font-size:clamp(18px,2vw,25px)}
.tour-group{border-top:1px solid #354a68;padding:10px 0 6px}
.tour-group:first-of-type{border-top:0}
.tour-group b{display:block;margin-bottom:5px;font-size:16px}
.tour-table{width:100%;border-collapse:collapse;table-layout:fixed;font-size:clamp(12px,1.1vw,15px)}
.tour-table th,.tour-table td{padding:6px 5px;border-bottom:1px solid #304563;text-align:center;font-variant-numeric:tabular-nums}
.tour-table th:first-child,.tour-table td:first-child{text-align:left;width:47%;overflow-wrap:anywhere}
.tour-table th{color:var(--muted);font-size:12px}
.tour-qualifier{background:#255041}
.tour-fixture{display:flex;justify-content:space-between;gap:12px;align-items:center;padding:9px 5px;border-bottom:1px solid #304563;font-size:clamp(13px,1.2vw,16px)}
.tour-fixture:last-child{border-bottom:0}
.tour-fixture>span:first-child{overflow-wrap:anywhere}
.tour-fixture b{color:var(--gold);white-space:nowrap}
.tour-bracket{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}
.tour-bracket-stage h4{margin:0 0 8px;color:var(--gold);font-size:17px}
.tour-bracket-match{padding:10px 8px;border:1px solid #415978;background:#1e3552;border-radius:11px;margin:6px 0;min-height:71px}
.tour-bracket-match b{display:block;font-size:13px;margin-bottom:5px;color:var(--muted)}
.tour-bracket-match .win{color:var(--lime);font-weight:950}
.tour-bracket-match .match-line{display:flex;justify-content:space-between;gap:6px;font-size:clamp(12px,1.1vw,16px);overflow-wrap:anywhere}
.tour-bracket-match .match-line span{min-width:0}
.tour-champion{text-align:center;font-size:clamp(26px,3vw,45px);font-weight:950;color:var(--gold);padding:16px}

/* Topplista tabell */
.lb-filters{display:flex;flex-direction:column;gap:8px;margin-bottom:16px}
.lb-body{
  background:#101f37;border:1px solid #385378;border-radius:16px;
  padding:clamp(10px,1.5vw,18px);min-height:180px;
}
.lb-table{width:100%;border-collapse:collapse;font-size:clamp(13px,1.25vw,17px)}
.lb-table th,.lb-table td{padding:10px 8px;border-bottom:1px solid #2b405f;text-align:left;font-variant-numeric:tabular-nums}
.lb-table th{color:var(--muted);font-size:12px;text-transform:uppercase;letter-spacing:.06em}
.lb-table td.num,.lb-table th.num{text-align:right}
.lb-table tr.lb-highlight{background:#234c43}
.lb-table tr.lb-highlight td{color:#fff;font-weight:900}
.lb-rank{width:54px;font-weight:900;color:var(--gold)}
.lb-score{color:var(--lime);font-weight:850}
.lb-time{color:var(--gold);font-weight:850}
.lb-date{color:var(--muted);font-size:.85em}
.lb-method{
  display:inline-block;padding:2px 8px;border-radius:999px;
  border:1px solid #3c587c;background:#172b47;color:#cde4fb;
  font-size:.78em;font-weight:750;white-space:nowrap;
}
.lb-empty{text-align:center;padding:30px 12px;color:var(--muted);font-size:16px}

@media(max-width:720px){
  .tour-columns,.tour-bracket,.tour-subjects,.tour-tri{grid-template-columns:1fr}
  .seg-4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .lb-date,.lb-table th.lb-date-col{display:none}
}
