:root{
  --pastel-blue:#AEC6FF;
  --pastel-red:#FFB3BA;
  --text-color:#333;
  --nav-height:75px;
  --history-height:90px;
  --ivory:#fffdf0;
  --gold:#FFD700;
  --link-blue:#007AFF;

  /* TargetMatch sizing */
  --tm-die: clamp(58px, 16.2vw, 86px);
  --tm-gap: clamp(6px, 1.6vw, 10px);
}

    body,html{
      margin:0; padding:0; height:100%;
      font-family:'Segoe UI',system-ui,sans-serif;
      background:var(--page-bg, radial-gradient(circle,#ffffff 0%,#f0f4ff 100%));
      overflow:hidden;
      display:flex; flex-direction:column;
    }

    body.operandum-mode,
    html.operandum-mode{
      --page-bg: radial-gradient(circle,#fbfffb 0%,#edf8ef 100%);
    }

#main-area{
  flex:1;
  display:flex; flex-direction:column;
  justify-content:center; align-items:center;
  user-select:none;
  position:relative;
  -webkit-tap-highlight-color:transparent;
  transform:translateZ(0);
  width:100%;
  overflow:hidden;
}

#result-text{
  height:50px;
  font-weight:900;
  color:var(--text-color);
  font-size:1.6rem;
  text-transform:uppercase;
  text-align:center;
  transition:opacity 0.6s ease;
  white-space: pre-line;
}
.result-hidden{ opacity:0; }
.result-visible{ opacity:1; }

#dice-container{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
  align-items:center;
  justify-content:center;
  padding:15px;
  cursor:pointer;
  min-height:180px;
  width:100%;
  box-sizing:border-box;
}

/* T6 */
.die{
  width:70px; height:70px;
  border:3px solid var(--text-color);
  border-bottom-width:7px;
  border-radius:14px;
  background:var(--ivory);
  display:grid;
  grid-template:repeat(3,1fr)/repeat(3,1fr);
  padding:8px;
  position:relative;
  box-sizing:border-box;
}
.die.large{ width:105px; height:105px; border-width:4px; border-bottom-width:8px; padding:12px; }
.die.locked{ background-color:var(--pastel-blue); transform:translateY(4px); border-bottom-width:3px; }
.die.rolling{ filter:blur(2px); transform:scale(0.96); }
.dot{ background-color:var(--text-color); border-radius:50%; width:13px; height:13px; margin:auto; }
.die.large .dot{ width:20px; height:20px; }
.star-box{ grid-column:1/span 3; grid-row:1/span 3; display:flex; align-items:center; justify-content:center; pointer-events:none; }
.star-shape{ width:45px; height:45px; background:#ccc; clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%); }
.poker-val{ grid-column:1/span 3; grid-row:1/span 3; display:flex; align-items:center; justify-content:center; font-weight:900; pointer-events:none; line-height:1; }

/* T10 */
.t10-svg{
  width:140px;
  height:140px;
  filter: drop-shadow(0 6px 0 var(--text-color));
}
.t10-svg.rolling{
  filter: blur(3px);
  transform: scale(0.94);
}

/* SUMMA */
#summa-board{ display:none; gap:6px; margin:15px 0; width:95%; max-width:450px; justify-content:center; z-index:10; }
.tile{ flex:1; height:75px; border:2.5px solid var(--text-color); border-radius:8px; display:flex; align-items:center; justify-content:center; font-weight:900; font-size:1.3rem; background:var(--ivory); color:var(--text-color); cursor:pointer; transition:all 0.1s; }
.tile.active{ background:var(--text-color); color:white; transform:translateY(2px); }
.tile.closed{ background:#ccc; color:white; border-color:#ccc; cursor:default; }
.tile.winner{ background:var(--gold); color:white; border-color:#ccac00; transform:scale(1.05); }

/* TIOKOMPISAR */
#operandum-area{
  display:none;
  width:100%;
  max-width:560px;
  padding:12px 16px 0 16px;
  box-sizing:border-box;
}
.operandum-card{
  width:100%;
  min-height:100%;
  display:flex;
  flex-direction:column;
  gap:22px;
  align-items:stretch;
}
.operandum-title{
  font-size:clamp(2.3rem, 9vw, 3.4rem);
  font-weight:900;
  color:var(--text-color);
  line-height:1;
  letter-spacing:0.02em;
  font-family:Georgia, "Times New Roman", serif;
  text-align:center;
  margin-top:6px;
}
.operandum-reset-btn{
  width:54px;
  height:54px;
  border-radius:999px;
  border:3px solid var(--text-color);
  background:#fff;
  color:var(--text-color);
  font-size:2rem;
  font-weight:900;
  display:flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  padding:0;
  box-shadow:none;
  -webkit-appearance:none;
  appearance:none;
  align-self:center;
}
.operandum-reset-btn:active{
  transform:translateY(1px);
}
.operandum-target-row{
  display:flex;
  justify-content:center;
  gap:86px;
  width:100%;
}
.operandum-pair{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
}
.operandum-pair.is-stacked{
  flex-direction:column;
  gap:8px;
}
.operandum-pair-label,
.operandum-section-label{
  font-size:1.08rem;
  font-weight:900;
  color:var(--text-color);
  text-align:center;
}
.operandum-section{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.operandum-operands-section{
  padding:18px 0 22px 0;
}
.operandum-lifeline-section{
  align-items:center;
}
.operandum-dice-row{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  justify-content:center;
}
.operandum-die-button{
  border:0;
  background:transparent;
  padding:0;
  margin:0;
  cursor:default;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  -webkit-tap-highlight-color:transparent;
}
.operandum-die-button.is-enabled{
  cursor:pointer;
}
.operandum-die-button.is-enabled .operandum-die{
  box-shadow:0 0 0 3px rgba(174, 198, 255, 0.55);
}
.operandum-die{
  width:66px;
  height:66px;
  padding:7px;
}
.operandum-hint,
.operandum-linkline{
  margin:0;
  text-align:center;
  line-height:1.45;
  color:#5d6470;
}
.operandum-hint{
  font-size:0.98rem;
  font-weight:600;
}
.operandum-linkline{
  font-size:0.92rem;
  margin-top:auto;
  padding-bottom:6px;
}
.operandum-linkline a{
  color:#0b3d91;
  font-weight:700;
  text-decoration:none;
}

#tenfriends-area{
  display:none;
  width:100%;
  max-width:560px;
  padding:8px 12px 0 12px;
  box-sizing:border-box;
  position:relative;
}
.tenfriends-card{
  width:100%;
  background:transparent;
  border:0;
  border-radius:0;
  padding:0;
  box-sizing:border-box;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  position:relative;
}
.tenfriends-menu-card{
  padding-top:28px;
}
.tenfriends-menu-title{
  font-size:clamp(2.4rem, 9vw, 3.6rem);
  font-weight:900;
  color:var(--text-color);
  text-align:center;
}
.tenfriends-menu-buttons{
  width:100%;
  max-width:360px;
  display:flex;
  flex-direction:column;
  gap:14px;
}
.tenfriends-mode-btn{
  width:100%;
  border:3px solid var(--text-color);
  background:#fff;
  color:var(--text-color);
  padding:18px 16px;
  border-radius:0;
  cursor:pointer;
  text-align:center;
  font-family:inherit;
  -webkit-appearance:none;
  appearance:none;
}
.tenfriends-mode-btn:active{
  transform:translateY(1px);
}
.tenfriends-mode-btn-title{
  display:block;
  font-size:1.45rem;
  font-weight:900;
  line-height:1.1;
}
.tenfriends-mode-btn-text{
  display:block;
  margin-top:6px;
  font-size:0.92rem;
  line-height:1.3;
  color:#5f6671;
}
.tenfriends-topbar{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  min-height:32px;
}
.tenfriends-mode-label{
  font-size:0.95rem;
  font-weight:900;
  letter-spacing:0.02em;
  color:#6a6a6a;
  text-transform:uppercase;
}
.tenfriends-timer{
  min-width:3ch;
  text-align:right;
  font-size:1.05rem;
  font-weight:900;
  color:#23633a;
  font-variant-numeric:tabular-nums;
}
.tenfriends-flash{
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  font-size:clamp(2rem, 6vw, 2.8rem);
  font-weight:900;
  color:#6a6a6a;
  opacity:0.92;
  flex-wrap:wrap;
  line-height:1;
}
.tenfriends-flash.correct{
  color:#23633a;
}
.tenfriends-flash.wrong{
  color:#9a3030;
}
.tenfriends-flash-old{
  text-decoration:line-through;
  text-decoration-thickness:2px;
}
.tenfriends-flash-new{
  color:#23633a;
}
.tenfriends-flash-hidden{
  opacity:0;
}
.tenfriends-equation{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:14px;
  flex-wrap:nowrap;
  min-height:132px;
  width:100%;
}
.tenfriends-number,
.tenfriends-plus{
  font-weight:900;
  color:var(--text-color);
  line-height:1;
}
.tenfriends-number{
  font-size:clamp(5.3rem, 21vw, 8rem);
}
.tenfriends-plus{
  font-size:clamp(3rem, 11vw, 4.6rem);
}
.tenfriends-answer{
  width:clamp(88px, 22vw, 116px);
  height:clamp(88px, 22vw, 116px);
  border:4px dashed #bfc8d8;
  border-radius:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:clamp(3.8rem, 16vw, 6rem);
  font-weight:900;
  color:var(--text-color);
  background:rgba(255,255,255,0.7);
  transition:all 0.18s ease;
}
.tenfriends-progress{
  width:100%;
  display:flex;
  justify-content:center;
  gap:8px;
  flex-wrap:nowrap;
  min-height:20px;
}
.tenfriends-dot{
  width:14px;
  height:14px;
  border-radius:999px;
  background:#d5d9e2;
  display:block;
}
.tenfriends-dot.correct{
  background:#58a56c;
}
.tenfriends-dot.wrong{
  background:#d86d6d;
}
.tenfriends-buttons{
  width:100%;
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:8px;
  max-width:246px;
}
.tenfriends-btn{
  aspect-ratio:1 / 1;
  min-height:56px;
  border-radius:0;
  border:3px solid var(--text-color);
  background:#fff;
  color:var(--text-color);
  font-size:clamp(5rem, 16vw, 6.2rem);
  font-weight:900;
  line-height:1;
  cursor:pointer;
  box-shadow:none;
  padding:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:inherit;
  -webkit-appearance:none;
  appearance:none;
}
.tenfriends-btn:active{
  transform:translateY(1px);
}
.tenfriends-summary-card{
  padding-top:20px;
}
.tenfriends-summary-title{
  font-size:clamp(2.1rem, 7vw, 3rem);
  font-weight:900;
  color:var(--text-color);
}
.tenfriends-summary-score{
  font-size:clamp(1.8rem, 6vw, 2.5rem);
  font-weight:900;
  color:var(--text-color);
}
.tenfriends-summary-time{
  font-size:1.15rem;
  font-weight:700;
  color:#23633a;
}
.tenfriends-restart-btn{
  margin-top:6px;
  min-width:180px;
  padding:16px 22px;
  border:0;
  border-radius:999px;
  background:var(--text-color);
  color:#fff;
  font-size:1.05rem;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 4px 0 #000;
}
.tenfriends-restart-btn:active{
  transform:translateY(2px);
  box-shadow:0 2px 0 #000;
}
.tenfriends-secondary-btn{
  margin-top:6px;
  min-width:180px;
  padding:12px 18px;
  border:2px solid #c7cfdb;
  border-radius:999px;
  background:#fff;
  color:var(--text-color);
  font-size:0.95rem;
  font-weight:900;
  cursor:pointer;
}
.tenfriends-secondary-btn:active{
  transform:translateY(1px);
}
.tenfriends-overlay{
  width:100%;
  min-height:420px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:radial-gradient(circle,#ffffff 0%,#f0f4ff 100%);
}
.tenfriends-countdown{
  font-size:clamp(10rem, 38vw, 16rem);
  font-weight:900;
  color:#2f8a4b;
  line-height:1;
}

/* HISTORIK */
#history-bar{ height:var(--history-height); background:rgba(240,240,240,0.5); border-top:1px solid #ddd; display:flex; flex-direction:column; }
#history-list{ display:flex; gap:12px; align-items:center; padding:10px; flex:1; justify-content:center; overflow:hidden; }
.history-entry{ display:flex; gap:4px; align-items:center; transition:all 0.3s ease; }
#history-list .history-entry:nth-child(1){ transform:scale(1.0); opacity:1.0; }
#history-list .history-entry:nth-child(2){ transform:scale(0.94); opacity:0.88; }
#history-list .history-entry:nth-child(3){ transform:scale(0.88); opacity:0.75; }
#history-list .history-entry:nth-child(4){ transform:scale(0.82); opacity:0.63; }
#history-list .history-entry:nth-child(5){ transform:scale(0.75); opacity:0.50; }
.mini-die{ width:30px; height:30px; border:2px solid var(--text-color); border-radius:6px; background:var(--ivory); display:grid; grid-template:repeat(3,1fr)/repeat(3,1fr); padding:3px; box-sizing:border-box; }
.mini-dot{ background-color:var(--text-color); border-radius:50%; width:5px; height:5px; margin:auto; }
.t10-kite-hist{ width:34px; height:44px; margin:0 -2px; }

/* ROLL BUTTON */
#roll-btn{
  display:none;
  width:85%;
  max-width:320px;
  padding:18px;
  background:var(--text-color);
  color:white;
  border:none;
  border-radius:50px;
  font-weight:bold;
  font-size:1.1rem;
  cursor:pointer;
  margin:10px 0;
  box-shadow:0 4px 0 #000;
}
#roll-btn.ui-locked{ background-color:#999; box-shadow:0 4px 0 #777; cursor:default; }

/* INFO */
#info-content{ display:none; width:100%; height:100%; padding:25px; overflow-y:auto; box-sizing:border-box; text-align:left; position:absolute; background:white; z-index:100; top:0; color:#444; line-height:1.4; }
.info-header{ text-align:center; margin-bottom:20px; }
.info-title{ color:var(--pastel-blue); font-size:1.8rem; margin:0 0 10px 0; }
.v-badge{ display:inline-block; background:#333; color:white; padding:5px 15px; border-radius:50px; font-weight:bold; font-size:0.75rem; margin-bottom:20px; }
.mode-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; margin:15px 0; }
.mode-card{ background:#f5f5f5; padding:15px 5px; border-radius:12px; font-weight:bold; cursor:pointer; text-align:center; font-size:0.9rem; border:1px solid #eee; }
.mode-card.full{ grid-column:span 2; }
.gray-box{ background:#f8f8f8; padding:20px; border-radius:15px; margin:20px 0; text-align:center; border:1px solid #eee; }
.red-box{ background:#fff5f5; border:1.5px solid #ffeded; padding:20px; border-radius:15px; margin:20px 0; text-align:center; }
.qr-small{ width:130px; height:130px; margin:10px auto; cursor:zoom-in; display:block; background:white; padding:8px; border:1px solid #ddd; border-radius:10px; }
#qr-overlay{ display:none; position:fixed; top:0; left:0; width:100%; height:100%; background:white; z-index:1000; justify-content:center; align-items:center; cursor:zoom-out; }
.share-link{ color:var(--link-blue); font-weight:bold; cursor:pointer; font-size:0.95rem; margin-top:10px; display:inline-block; }
.coffee-btn{ display:inline-block; background:#ffb3ba; color:white; padding:12px 25px; border-radius:50px; text-decoration:none; font-weight:bold; margin-top:15px; box-shadow:0 3px 0 #ff8a95; }
.terms{ font-size:0.7rem; color:#999; margin-top:25px; border-top:1px solid #eee; padding-top:15px; line-height:1.2; }

/* NAV */
nav{ height:var(--nav-height); border-top:2px solid #ddd; display:flex; background:white; z-index:1000; }
.nav-item{ flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; color:#bbb; cursor:pointer; }
.nav-item svg{ width:34px; height:34px; fill:#bbb; }
.nav-item.active{ color:var(--text-color); background-color:#fafafa; box-shadow:inset 0 5px 0 var(--pastel-blue); }
.nav-item.active svg{ fill:var(--text-color); }

/* ===== TargetMatch (Målmatch) ===== */
#targetmatch-area{
  display:none;
  width:100%;
  max-width:560px;
  padding:8px 12px 0 12px;
  box-sizing:border-box;
  flex-direction:column;
  align-items:center;
}

#targetmatch-header{
  display:flex;
  justify-content:center;
  align-items:center;
  margin: 8px 0 clamp(24px, 7vw, 48px) 0;
}

.target-circle{
  width:98px; height:98px;
  border-radius:999px;
  border:5px solid #111;
  display:flex; align-items:center; justify-content:center;
  font-weight:900;
  font-size:2.7rem;
  color:#111;
  box-sizing:border-box;
  cursor:pointer;
  transform: translateY(-6px);
  background:#008000; /* default */
}
.target-circle.tm8{ background:#0066cc; }
.target-circle.tm9{ background:#cc0000; }
.target-circle.tm10{ background:#008000; }

#targetmatch-grid{
  display:grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--tm-gap);
  width:100%;
  margin:0 auto;
  padding:0;
  box-sizing:border-box;
  justify-items:center;
  align-items:center;
  margin-bottom: clamp(24px, 7vw, 48px);
}

#targetmatch-controls{
  width:100%;
  display:flex;
  justify-content:center;
  margin-top:0;
  height:74px;
  align-items:flex-start;
}

.t10-wrap{
  width:var(--tm-die);
  height:var(--tm-die);
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:14px;
  cursor:pointer;
  box-sizing:border-box;
}
.t10-wrap.selected{
  outline:4px solid var(--pastel-blue);
  outline-offset:2px;
}
.t10-wrap.cleared{
  opacity:0.35;
  cursor:default;
}

.t10-wrap.winner svg text {
  display:none;
}
.t10-wrap.winner {
  background:transparent;
}
.t10-wrap.winner svg path {
  stroke:#243a6b;
  stroke-width:1.5;
  fill:#eaf3ff;
}

.t10-tm-svg{
  width:100%;
  height:100%;
  filter: drop-shadow(0 3px 0 var(--text-color));
  transform-origin:center;
}
.t10-tm-svg.rolling{
  filter: blur(2px);
  transform: scale(0.96);
}

.tm-btn-hidden{
  visibility:hidden;
  pointer-events:none;
}

@media (max-width: 430px){
  .operandum-target-row{
    gap:54px;
  }
  .operandum-pair{
    gap:8px;
  }
  .operandum-pair-label,
  .operandum-section-label{
    font-size:1rem;
  }
  .operandum-die{
    width:60px;
    height:60px;
    padding:6px;
  }
  .operandum-reset-btn{
    width:48px;
    height:48px;
    font-size:1.8rem;
  }
  .tenfriends-menu-buttons{
    max-width:320px;
    gap:12px;
  }
  .tenfriends-mode-btn-title{
    font-size:1.25rem;
  }
  .tenfriends-mode-btn-text{
    font-size:0.86rem;
  }
  .tenfriends-flash{
    min-height:42px;
    font-size:clamp(1.7rem, 6vw, 2.2rem);
  }
  .tenfriends-equation{
    min-height:118px;
    gap:10px;
  }
  .tenfriends-btn{
    min-height:52px;
    font-size:4.2rem;
  }
  .tenfriends-countdown{
    font-size:clamp(9rem, 36vw, 12rem);
  }
  #dice-container.penta-tight{
    padding-left: 6px;
    padding-right: 6px;
    padding-top: 12px;
    padding-bottom: 12px;
    gap: 6px;
  }
}

.tm-pick-overlay{
  position:fixed;
  inset:0;
  display:none;
  background: transparent;
  z-index:2000;
  padding:0;
  align-items:stretch;
  justify-content:stretch;
}

.tm-pick-overlay.open{ display:flex; }

.tm-pick-panel{
  width:100vw;
  height:100vh;
  background:#fff;
  border:0;
  border-radius:0;
  box-shadow:none;
  padding:16px;
  padding-top:calc(16px + env(safe-area-inset-top));
  padding-right:calc(16px + env(safe-area-inset-right));
  padding-bottom:calc(16px + env(safe-area-inset-bottom));
  padding-left:calc(16px + env(safe-area-inset-left));
  box-sizing:border-box;
  overflow:auto;
}

.tm-pick-overlay.open{ display:flex; }
.tm-pick-panel{
  width:min(420px, 100%);
  background:#fff;
  border:2px solid #ddd;
  border-radius:18px;
  padding:16px 16px 14px 16px;
  box-shadow:0 18px 60px rgba(0,0,0,0.25);
}
.tm-pick-title{
  font-weight:900;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:var(--text-color);
  font-size:0.9rem;
  text-align:center;
  margin-bottom:12px;
}
.tm-pick-row{
  display:flex;
  gap:12px;
  justify-content:center;
  align-items:center;
}
.tm-pick-circle{
  width:92px;
  height:92px;
  border-radius:999px;
  border:5px solid #111;
  font-weight:900;
  font-size:2.4rem;
  color:#111;
  cursor:pointer;
  box-sizing:border-box;
  background:#fff;
}
.tm-pick-circle.tm8{ background:#0066cc; }
.tm-pick-circle.tm9{ background:#cc0000; }
.tm-pick-circle.tm10{ background:#008000; }
.tm-pick-hint{
  text-align:center;
  font-size:0.75rem;
  color:#777;
  margin-top:10px;
}

.t10-wrap.winner{
  background: transparent !important;
  box-shadow: none !important;
  border: 0 !important;
  clip-path: none !important;
  display:flex;
  align-items:center;
  justify-content:center;
  color:#3f4752;
}

.t10-wrap.winner svg{
  width: 70%;
  height: 70%;
  display:block;
}

.t10-wrap.winner svg text{
  display:none;
}

.t10-wrap.winner svg path{
  fill:#eaf6ff !important;
  stroke:#2f3a4a !important;
  stroke-width:0.14 !important;
}
