:root {
  color-scheme: light; --paper:#f6f3eb; --ink:#24223a; --purple:#36255e; --lilac:#ded3fd;
  --yellow:#f6e567; --line:#d8d1c5; --muted:#615e70; --white:#fffdf7;
  font-family: system-ui, sans-serif; color:var(--ink); background:var(--paper);
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; }
a { color:inherit; }
button,input { font:inherit; }
button { cursor:pointer; }
:focus-visible { outline:3px solid #8a56ea; outline-offset:3px; }
.top { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); align-items:center; gap:1rem; padding:1rem; border-bottom:1px solid var(--line); }
.brand { display:flex; align-items:center; gap:.65rem; font-size:1.2rem; font-weight:850; text-decoration:none; white-space:nowrap; }
.top > .brand { grid-column:1; grid-row:1; justify-self:start; }
.brand span { display:grid; place-items:center; width:2.1rem; height:2.1rem; border-radius:.6rem; color:var(--yellow); background:var(--purple); font-size:1.6rem; line-height:1; }
.top nav { grid-column:2; grid-row:1; justify-self:center; display:flex; align-items:center; gap:.25rem; padding:.25rem; border:1px solid var(--line); border-radius:999px; }
.top nav a, .top nav .nav-tools > summary {
  display:flex;
  align-items:center;
  padding:.48rem .85rem;
  border-radius:999px;
  text-decoration:none;
  white-space:nowrap;
  font-size:.9rem;
  line-height:1.35;
  font-weight:700;
}
.top nav a[aria-current] { background:var(--lilac); }
.top p,footer { color:var(--muted); font-size:.85rem; }
.top-actions { grid-column:3; grid-row:1; display:flex; align-items:center; align-self:start; justify-self:end; gap:.75rem; min-width:0; }
main { width:100%; min-height:75vh; }
.intro { display:flex; align-items:end; justify-content:space-between; gap:1.5rem; margin:clamp(2rem,6vw,4.75rem) 0 2.25rem; }
h1,h2,p { margin:0; }
h1 { font-size:clamp(3.2rem,8vw,6.6rem); font-weight:900; line-height:.89; letter-spacing:-.08em; }
h1 em { font-family:Georgia,serif; color:#56388c; font-weight:700; }
.intro p { width:min(17rem,100%); color:var(--muted); line-height:1.6; }
.layout { display:grid; grid-template-columns:minmax(0, 12rem) minmax(0, 1fr); align-items:start; gap:.75rem; }
.settings,.game,.stats-card { border-radius:1.35rem; padding:clamp(1rem,3vw,1.8rem); }
.settings { padding:.85rem; }
.table-hint { margin-top:.25rem; color:var(--muted); font-size:.8rem; }
.settings,.stats-card { background:var(--white); border:1px solid var(--line); }
h2 { font-size:1.2rem; }
.tables { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:.35rem; margin:1.1rem 0 .65rem; }
.tables button { min-height:2.6rem; border:1px solid var(--line); background:var(--paper); color:var(--ink); font-weight:750; border-radius:.55rem; }
.tables button { min-height:0; aspect-ratio:1; padding:0; }
.tables button[aria-pressed="true"] { background:var(--lilac); border-color:#9281b9; }
.start { display:flex; align-items:center; justify-content:space-between; width:100%; min-height:3rem; padding:.55rem .85rem; margin-top:1rem; border:0; border-radius:.6rem; background:var(--yellow); color:var(--ink); font-weight:850; }
.game { min-height:22rem; color:var(--ink); }
.round-top { display:flex; justify-content:space-between; align-items:center; gap:.7rem; }
#counter { color:var(--muted); font-weight:700; }
progress { width:100%; height:.55rem; margin-top:.8rem; appearance:none; border:0; border-radius:1rem; overflow:hidden; background:#675585; }
progress::-webkit-progress-bar { background:#675585; }
progress::-webkit-progress-value { background:var(--yellow); }
progress::-moz-progress-bar { background:var(--yellow); }
.problem { margin:clamp(1.4rem,4vw,2.4rem) 0 1.35rem; text-align:center; font-size:clamp(2.6rem,6.5vw,5.25rem); font-weight:900; letter-spacing:-.055em; line-height:1; font-variant-numeric:tabular-nums; }
#answer-form { display:flex; justify-content:center; gap:.5rem; }
#answer { width:min(12rem,60%); border:1px solid #aa95ce; border-radius:.6rem; color:var(--ink); background:var(--white); padding:.8rem; }
#answer::placeholder { color:var(--muted); }
#answer-form button,.game-action { background:var(--yellow); color:var(--ink); border:0; border-radius:.6rem; padding:.75rem 1rem; font-weight:850; text-decoration:none; }
.game-action { display:table; margin:.65rem auto 0; }
#feedback { min-height:1.5rem; margin:.75rem 0 0; text-align:center; color:var(--muted); font-weight:650; }
.totals { display:grid; grid-template-columns:repeat(3,1fr); gap:.75rem; margin-bottom:1rem; }
.totals div { padding:1rem; background:var(--lilac); border-radius:1rem; }
.totals strong,.totals span { display:block; }
.totals strong { font-size:clamp(1.6rem,4vw,2.75rem); }
.stats-card p { margin:.75rem 0; color:var(--muted); }
.stat-row { display:grid; grid-template-columns:minmax(4rem,1fr) 2fr minmax(3rem,auto); align-items:center; gap:.75rem; padding:.7rem 0; border-bottom:1px solid var(--line); }
.stat-row progress { margin:0; }
.stat-row span:last-child { text-align:right; }
footer { width:100%; margin:1.6rem 0; border-top:1px solid var(--line); padding:1rem 1rem 0; }
.storage-notice { margin-top:1rem; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
@media(max-width:650px) {
  .top p { display:none; }
  .intro { align-items:start; flex-direction:column; }
  .layout { grid-template-columns:1fr; }
  .tables { grid-template-columns:repeat(9,minmax(0,1fr)); }
  .totals { gap:.4rem; }
  .totals div { padding:.6rem; }
}
.round-status { margin:0 0 1rem; text-align:center; color:var(--muted); font-variant-numeric:tabular-nums; }
.board { display:grid; grid-template-columns:repeat(9,minmax(0,1fr)); gap:2px; margin-top:1rem; }
.board span { display:grid; place-items:center; aspect-ratio:1; min-width:0; color:white; background:#513f75; border-radius:.25rem; font-size:clamp(.55rem,3.8cqw,1.3rem); white-space:nowrap; }
.board .inactive { opacity:.55; }
.board .solved { background:#23594b; }
.board [aria-current] { background:var(--yellow); color:var(--ink); font-weight:850; }
body { min-height:100dvh; display:flex; flex-direction:column; }
body:has(#spil:not([hidden])) { height:100dvh; }
body:has(#spil:not([hidden])) main { flex:1; min-height:0; display:flex; flex-direction:column; }
body:has(#spil:not([hidden])) footer { display:none; }
#spil:not([hidden]) { flex:1; min-height:0; display:flex; flex-direction:column; }
#spil .layout { flex:1; min-height:0; align-items:stretch; }
#spil .settings { align-self:start; }
.game { min-height:0; min-width:0; display:flex; flex-direction:column; padding:.75rem; }
.board-space { margin:.4rem 0; container-type:inline-size; }
.board { width:100%; margin:0; }

.problem { margin:.25rem 0; font-size:clamp(1.35rem,5dvh,2.5rem); }
.round-status { margin:0 0 .25rem; }
#answer,#answer-form button { padding:.35rem .65rem; }
#feedback { margin:.2rem 0 0; min-height:1.15em; }
@media(max-width:650px) {
  #spil .layout { grid-template-rows:auto minmax(0,1fr); gap:.25rem; }
  #spil .settings { padding:.35rem .65rem; }
  #spil .tables { max-width:22rem; margin:.25rem 0; }
  #spil .start { display:inline-flex; width:auto; min-height:1.8rem; margin:0; padding:.15rem .5rem; gap:.3rem; }
  .top { padding:.35rem .65rem; }
}
#spil .layout {
  --game-width:clamp(0px, calc(100dvh - 13rem), 42rem);
  grid-template-columns:12rem minmax(0, var(--game-width));
  justify-content:center;
}
.game {
  align-self:start;
  background:var(--purple);
  color:white;
}
.game #counter,.game .round-status,.game #feedback { color:var(--lilac); }
@media(max-width:650px) {
  #spil .layout {
    --game-width:clamp(0px, calc(100dvh - 19rem), 42rem);
    grid-template-columns:minmax(0, min(calc(100% - 1rem), var(--game-width)));
  }
}
#statistik { max-width:58rem; margin:2rem auto; padding:0 1rem; }
.stats-header { display:flex; flex-wrap:wrap; justify-content:space-between; align-items:center; gap:1rem; margin-bottom:1.5rem; }
.stats-header h1 { font-size:clamp(2rem,6vw,4rem); }
#stats-choice { font:inherit; max-width:100%; padding:.35rem; }
#stats-chart { display:block; width:100%; background:var(--white); border:1px solid var(--line); border-radius:1rem; fill:var(--ink); }

.math-home { display:grid; place-items:center; padding:2rem 1rem; text-align:center; }
.math-home h1 { max-width:12ch; }
.merge-game { max-width:30rem; margin:1.5rem auto; padding:0 1rem; }
.merge-game h1 { font-size:clamp(2.5rem,8vw,4rem); margin-bottom:.75rem; }
.merge-game p { color:var(--muted); line-height:1.5; }
.merge-toolbar { display:flex; align-items:center; justify-content:space-between; margin:.75rem 0; }
.merge-game button { color:var(--ink); background:var(--yellow); border:0; border-radius:.5rem; padding:.45rem .7rem; font-weight:750; }
#merge-board { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.3rem; padding:.45rem; border-radius:.75rem; background:var(--purple); }
#merge-board span { display:grid; place-items:center; aspect-ratio:1; border-radius:.35rem; background:hsl(var(--tile-hue,260) 50% 87%); color:var(--ink); font-size:clamp(.85rem,4vw,1.6rem); font-weight:850; }
#merge-board span:empty { background:#513f75; }
.merge-directions { display:flex; justify-content:center; gap:.4rem; margin:.65rem 0; }
.merge-directions button { min-width:2.75rem; }
@media(max-width:420px) {
  .top nav { justify-self:stretch; justify-content:center; }
  .top nav a, .top nav .nav-tools > summary { padding:.4rem .55rem; font-size:.8rem; }
}
@media(max-width:1100px) {
  .top { grid-template-columns:minmax(0,1fr) auto; gap:.5rem; }
  .top nav { grid-column:1 / -1; grid-row:2; }
  .top-actions { grid-column:2; grid-row:1; gap:.4rem; }
}
.round-top { flex-wrap:wrap; gap:.3rem .6rem; }
.stats-link { margin-left:auto; padding:.25rem .55rem; border-radius:.45rem; background:var(--lilac); color:var(--ink); font-size:.8rem; font-weight:750; text-decoration:none; white-space:nowrap; }
.stats-link:hover { background:white; }

.account,.leaderboard { background:var(--white); border:1px solid var(--line); border-radius:1rem; padding:1rem; }
.account { width:min(100%,26rem); text-align:left; }
.account form,.account label { display:grid; gap:.45rem; }
.account form { gap:.8rem; margin-top:.75rem; }
.account input { min-width:0; padding:.45rem; border:1px solid var(--line); border-radius:.4rem; }
.account button { border:0; background:var(--lilac); padding:.45rem .7rem; border-radius:.45rem; }
.account p,.leaderboard p { font-size:.85rem; color:var(--muted); }
#account-status:not(:empty) { margin-top:.6rem; }
.leaderboard { align-self:start; }
.leaderboard ol { padding-left:1.35rem; margin:0; overflow-wrap:anywhere; }
.leaderboard li,.leaderboard p { margin-top:.35rem; }
.rating-panel { margin-top:1rem; padding-top:.75rem; border-top:1px solid var(--line); }
.rating-panel h3 { margin-bottom:.3rem; font-size:1.1rem; }
.rating-panel ol { padding-left:1.35rem; }
.rating-panel li[aria-current="true"] { font-weight:800; }
@media(min-width:850px) {
  #spil .layout { grid-template-columns:12rem minmax(0, var(--game-width)) 13rem; }
}
@media(min-width:651px) and (max-width:849px) {
  .leaderboard { grid-column:2; }
}
@media(max-width:849px) {
  #spil .layout { grid-template-rows:auto; }
}
.top:has(.account-session:not([hidden])) .top-actions { flex-wrap:wrap; justify-content:flex-end; }
.top:has(.account-session:not([hidden])) .top-actions > p { display:none; }
@media(max-width:650px) {
  .top:has(.account-session:not([hidden])) .top-actions {
    grid-column:1 / -1;
    grid-row:3;
    justify-self:stretch;
    justify-content:center;
  }
}
.account-session { display:flex; flex-wrap:wrap; align-items:center; gap:.4rem; font-size:.85rem; overflow-wrap:anywhere; }
.account-session button { border:0; background:var(--lilac); padding:.4rem .65rem; border-radius:.45rem; }
.account-trophies { display:inline-flex; align-items:center; padding:.4rem .65rem; border-radius:.45rem; background:var(--lilac); color:var(--ink); text-decoration:none; }
.account-trophies:hover { background:white; }

/* Juletema på forsiden og begge spilsider. */
:root {
  --paper:#f5f1e7;
  --ink:#172e28;
  --purple:#123d32;
  --lilac:#dfebdf;
  --yellow:#f6d884;
  --line:#d6dace;
  --muted:#4e6258;
  --white:#fffdf6;
  --berry:#9c253b;
}
body {
  background:
    radial-gradient(circle at 16px 21px,#fff 1.5px,transparent 2.5px) 0 0 / 61px 67px,
    radial-gradient(circle at 41px 47px,#fff 1px,transparent 2px) 0 0 / 83px 91px,
    linear-gradient(135deg,#e3ede6,var(--paper) 50%,#f2e7dc);
}
.top {
  position:relative;
  color:#fffdf6;
  background:#123d32;
  border-bottom:0;
  box-shadow:inset 0 -3px #a92c46;
}
.top::after {
  content:"";
  position:absolute;
  inset:auto 0 0;
  height:5px;
  pointer-events:none;
  background:radial-gradient(circle,#ffe19b 1.5px,transparent 2.5px) 0 0 / 26px 5px;
}
.top .brand span { background:var(--berry); color:#ffe19b; }
.top nav { border-color:#83a392; }
.top nav a[aria-current] { color:var(--ink); }
.top p { color:#dfebdf; }
.account-session button { color:var(--ink); }
h1 em { color:var(--berry); }
.math-home h1 { text-wrap:balance; }
.math-home h1::after {
  content:"";
  display:block;
  width:4.5rem;
  height:.45rem;
  margin:1.15rem auto 0;
  border-radius:999px;
  background:repeating-linear-gradient(120deg,var(--berry) 0 8px,#fff9e8 8px 16px);
}
.account,.settings,.leaderboard,#stats-chart {
  box-shadow:0 .45rem 1.4rem #183b2810;
}
.board span { background:#29594a; }
.board .solved { background:#9c253b; }
.board [aria-current] { background:var(--yellow); }
#merge-board span { background:hsl(var(--tile-hue,260) 50% 87%); }
#merge-board span:empty { background:#29594a; }

.top { padding-bottom:1.55rem; }
.top::after { display:none; }
.christmas-lights {
  position:absolute; inset:auto 0 0;
  display:flex; justify-content:space-around; align-items:start;
  height:.95rem; border-top:2px solid #79947a; pointer-events:none; overflow:hidden;
}
.christmas-lights span {
  width:.5rem; height:.66rem; border-radius:35% 35% 55% 55%;
  color:#ffb752; background:currentColor; box-shadow:0 0 .55rem currentColor;
}
.christmas-lights span:nth-child(3n + 1) { color:#ff6277; }
.christmas-lights span:nth-child(3n + 2) { color:#9ce3b9; }
.christmas-decor { position:fixed; inset:0; pointer-events:none; }
.christmas-decor span { position:absolute; bottom:.5rem; font-size:clamp(2rem,7vw,5.5rem); }
.home-christmas-decor button { position:absolute; bottom:.5rem; padding:0; border:0; background:transparent; font-size:clamp(2rem,7vw,5.5rem); line-height:1; pointer-events:auto; }
.christmas-left { left:1rem; transform:rotate(-9deg); }
.christmas-right { right:1rem; transform:rotate(10deg); }
.math-home { gap:.85rem; align-content:center; }
.christmas-home { font-size:clamp(2rem,7vw,4.75rem); line-height:1.15; }
.gift-field { display:grid; gap:.4rem; width:min(100%,26rem); text-align:left; }
.gift-field input { width:100%; padding:.65rem; border:1px solid var(--line); border-radius:.4rem; background:var(--white); color:var(--ink); }
@media(max-width:1100px) {
  .christmas-decor { display:none; }
  .home-christmas-decor { display:block; }
  .home-christmas-decor .christmas-left { display:none; }
}

.barbara-unicorn { position:relative; width:min(80vw,24rem); border:6px solid #fff; border-radius:1rem; overflow:hidden; box-shadow:0 0 0 5px #ff5ab5, 0 1rem 2rem #a9006940; }
.barbara-unicorn img { display:block; width:100%; height:auto; image-rendering:pixelated; }
.barbara-unicorn::after {
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  clip-path:polygon(51% 41%, 57% 42%, 68% 46%, 78% 52%, 87% 60%, 94% 69%, 98% 79%, 98% 85%, 88% 93%, 83% 86%, 76% 78%, 69% 70%, 62% 62%, 53% 53%, 51% 47%);
  background:linear-gradient(135deg, transparent 35%, #ffffff80 35% 42%, transparent 42% 85%, #ffffff80 85% 92%, transparent 92%) 0 0 / 64px 64px;
  animation:rainbow-flow 1.2s steps(8) infinite;
}
@keyframes rainbow-flow { to { background-position:64px 64px; } }
@media (prefers-reduced-motion:reduce) {
  .barbara-unicorn::after { animation:none; background:none; }
}
body.barbara-theme,[data-theme="dark"] body.barbara-theme { color:#64104c; background:repeating-linear-gradient(135deg,#ffd5ee 0 35px,#ffe9f7 35px 70px,#ffbde4 70px 105px); }
.barbara-theme .top { color:#64104c; background:linear-gradient(100deg,#ff80c8,#ffd55c,#92f0bf,#83cfff,#d5a4ff,#ff83cf); box-shadow:inset 0 -5px #f50092; }
.barbara-theme .top nav { border-color:#c63d91; background:#fff1fa; flex-wrap:wrap; justify-content:center; }
.barbara-theme .top nav a[aria-current],.barbara-theme #barbara-corner { background:#ff8ad0; color:#64104c; }
.top nav #barbara-corner { padding:.48rem .85rem; border:0; border-radius:999px; background:#ff8ad0; color:#64104c; font-size:.9rem; font-weight:700; white-space:nowrap; }
.barbara-theme .top p,.barbara-theme .account-session { color:#64104c; }
.barbara-theme .christmas-home { display:none; }
.barbara-theme .math-home h1 { color:#a8006b; }
.barbara-theme .math-home h1 em { color:#e40091; }
.barbara-theme .math-home h1::after { background:linear-gradient(90deg,red,orange,#e9cf00,#37bf65,#259bea,#a549e5); }
.barbara-theme .gift-field input { border-color:#ea65b4; background:#fff5fc; color:#64104c; }

.top { flex-wrap:wrap; }
.theme-toggle {
  border:1px solid #83a392; border-radius:999px; padding:.35rem .7rem;
  background:transparent; color:inherit; font-size:.8rem; font-weight:700;
}
.theme-toggle[aria-pressed="true"] { background:#f6d884; color:#172e28; border-color:#f6d884; }
:root[data-theme="dark"] {
  color-scheme:dark;
  --paper:#14231e;
  --ink:#f4f4e9;
  --purple:#142e26;
  --white:#1e332b;
  --line:#50655a;
  --muted:#c0cec3;
  --berry:#ff9daf;
}
[data-theme="dark"] body {
  background:
    radial-gradient(circle at 16px 21px,#dbeee05c 1px,transparent 2px) 0 0 / 61px 67px,
    linear-gradient(135deg,#10251d,var(--paper) 50%,#261c22);
}
[data-theme="dark"] :is(.top nav a[aria-current],.account button,.account-session button,.stats-link,.start,.game-action,#answer-form button,.board [aria-current],.merge-game button,#merge-board span) { color:#172e28; }
[data-theme="dark"] .account-trophies { color:#172e28; }
[data-theme="dark"] .tables button[aria-pressed="true"] { background:#486656; }
[data-theme="dark"] .board .solved { background:#9c253b; }
[data-theme="dark"] .top .brand span { background:#9c253b; }
[data-theme="dark"] #stats-chart line { stroke:var(--line); }
[data-theme="dark"] #stats-chart polyline { stroke:#d4b8ff; }
[data-theme="dark"] #stats-chart circle { fill:#d4b8ff; }

.top nav { flex-wrap:wrap; }
.chess { max-width:32rem; margin:1.5rem auto; padding:0 1rem; }
.chess h1 { font-size:clamp(2.5rem,8vw,4rem); margin-bottom:.65rem; }
#chess-status { min-height:1.4em; margin-bottom:.75rem; }
#chess-lobby,#chess-join { display:flex; flex-wrap:wrap; align-items:end; gap:.5rem; }
#chess-lobby label { display:grid; gap:.25rem; }
#chess-lobby input { width:13ch; padding:.4rem; font:inherit; }
.chess-rating { margin:.8rem 0; padding:.8rem; border:1px solid var(--line); border-radius:.75rem; background:var(--white); }
.chess-rating h2 { margin:0 0 .35rem; font-size:1.25rem; }
.chess-rating p { margin:.3rem 0; font-size:.85rem; color:var(--muted); }
.chess-rating ol { margin:.3rem 0 0; padding-left:1.35rem; }
.chess-rating li[aria-current="true"] { font-weight:800; }
.chess-result-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.45rem; margin:.6rem 0; }
.chess-result-actions p { width:100%; margin:0; }
.chess button:not(.chess-square) { background:var(--yellow); color:#172e28; border:0; border-radius:.45rem; padding:.45rem .65rem; font-weight:700; }
#chess-board { width:100%; display:grid; grid-template-columns:repeat(8,minmax(0,1fr)); margin:.65rem 0; border:3px solid var(--purple); border-radius:.3rem; }
.chess-square { aspect-ratio:1; display:grid; place-items:center; border:0; padding:0; position:relative; font-size:clamp(1.35rem,8vw,2.7rem); line-height:1; color:#192b22; }
.chess-light { background:#eee2c3; }
.chess-dark { background:#50806b; }
.chess-square[aria-pressed="true"] { box-shadow:inset 0 0 0 3px #ffd55c; }
.chess-square.chess-target::after { content:""; position:absolute; inset:39%; background:#902439a8; border-radius:50%; pointer-events:none; }
#chess-promotion { display:block; margin-bottom:.5rem; }

.trophy-room { max-width:64rem; margin:clamp(2rem,6vw,4rem) auto; padding:0 1rem; }
.trophy-room h1 { margin-bottom:.6rem; font-size:clamp(2.5rem,7vw,4.5rem); }
.trophy-room > p { color:var(--muted); line-height:1.55; }
#trophy-status,#trophy-login { margin:1rem 0; }
.trophy-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,16rem),1fr)); gap:.8rem; margin-top:1.5rem; }
.trophy-card { display:grid; grid-template-columns:auto 1fr; align-items:start; gap:.15rem .8rem; padding:1rem; border:1px solid var(--line); border-radius:1rem; background:var(--white); }
.trophy-card.is-locked { opacity:.72; }
.trophy-icon { grid-row:span 3; font-size:2rem; }
.trophy-card h2 { font-size:1.05rem; }
.trophy-card p,.trophy-card small { color:var(--muted); }
.trophy-card p { margin:.25rem 0; line-height:1.45; }

.duel-link { display:inline-block; margin-top:.75rem; }
.duel { max-width:32rem; margin:2rem auto; padding:0 1rem; }
.duel h1 { font-size:clamp(2rem,7vw,3.8rem); margin-bottom:.8rem; }
#duel-status { margin-bottom:1rem; }
#duel-lobby,#duel-join,#duel-answer-form { display:flex; flex-wrap:wrap; align-items:end; gap:.6rem; }
#duel-room { padding:1rem; margin-bottom:1rem; background:var(--white); border:1px solid var(--line); border-radius:1rem; }
#duel-lobby { margin-bottom:1rem; }
#duel-room label:not(.sr-only),#duel-join label { display:grid; gap:.3rem; margin:.5rem 0 0; }
#duel-room progress { margin:0; }
.duel button { padding:.45rem .7rem; border:0; border-radius:.45rem; color:#172e28; background:var(--yellow); font-weight:750; }
.duel input { width:9ch; padding:.4rem; font:inherit; }
#duel-code { letter-spacing:.12em; }
#duel-answer-form { justify-content:center; margin:.6rem 0; }
#duel-leave { margin-top:.75rem; }

.duel { max-width:42rem; }
#duel-board { margin-top:.8rem; }
#duel-board span,.duel-watch-boards .board span { font-size:clamp(.42rem,2.1vw,1.05rem); }
#duel-watch { margin:1.25rem 0; }
#duel-watch-status { margin:.3rem 0; }
#duel-watch-list { display:flex; flex-wrap:wrap; gap:.45rem; }
#duel-watch-list [aria-pressed="true"] { outline:2px solid currentColor; outline-offset:2px; }
.duel-watch-boards { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:clamp(.35rem,2vw,1rem); }
.duel-watch-boards p { margin-bottom:.35rem; font-weight:700; }
.duel-watch-boards .board span { font-size:clamp(.35rem,1.45vw,.8rem); }
.duel-watch-boards .board .solved,#duel-board .solved { background:#9c253b; }
#duel-watch-name { margin:.8rem 0 .45rem; }
.duel-watch-heading { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.5rem; }
#duel-watch-match:fullscreen {
  background:var(--paper); color:var(--ink); overflow:auto;
  padding:clamp(.65rem,2vmin,1.5rem);
}
#duel-watch-match:fullscreen .duel-watch-heading,
#duel-watch-match:fullscreen > p,
#duel-watch-match:fullscreen .duel-watch-boards {
  width:min(100%, max(36rem,calc(200dvh - 13rem)));
  margin-inline:auto;
}
#duel-watch-match:fullscreen .board span { font-size:clamp(.45rem,2.4vmin,1.6rem); }

@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  body:has(#spil:not([hidden])) { height:auto; }
  #spil .layout { grid-template-columns:minmax(0,1fr); grid-template-rows:none; grid-auto-rows:auto; }
  #spil .leaderboard { grid-column:auto; }
  #spil .settings { padding:.35rem .65rem; }
  #spil .duel-link { margin:.25rem 0 0 .25rem; }
  #spil .game { width:100%; padding:.45rem; }
  #spil:has(#answer-form:not([hidden])) :is(.settings,.leaderboard) { display:none; }
  body:has(#answer-form:not([hidden]), #duel-answer-form:not([hidden])) .top { display:none; }
  #spil .game .board-space {
    width:min(100%, max(9rem, calc(var(--visible-height, 100dvh) - 8.5rem)));
    margin:.25rem auto;
  }
  #spil .game .board span { font-size:clamp(.42rem,3.8cqw,1rem); }
  #spil #answer-form #answer,.duel #duel-answer { font-size:1rem; }
  #spil .problem,#duel-question { font-size:1.55rem; }
  #spil #progress { margin-top:.3rem; }

  .duel:has(#duel-room:not([hidden])) { margin:.25rem auto; padding:0 .4rem; }
  .duel:has(#duel-answer-form:not([hidden])) > :is(h1,a) { display:none; }
  .duel:has(#duel-room:not([hidden])) #duel-status { margin-bottom:.2rem; }
  #duel-room { padding:.35rem .5rem; }
  .duel-progress { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.55rem; }
  #duel-room .duel-progress label { margin:.15rem 0; gap:.1rem; font-size:.8rem; }
  #duel-room #duel-board {
    width:min(100%, max(9rem, calc(var(--visible-height, 100dvh) - 9.5rem)));
    margin:.25rem auto;
    container-type:inline-size;
  }
  #duel-board span { font-size:clamp(.42rem,3.8cqw,1rem); }
  #duel-answer-form { margin:.25rem 0; }
}
#stop-round { display:none; border:0; }
@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  #spil:has(#answer-form:not([hidden])) #stop-round { display:inline-block; }
  #spil:has(#answer-form:not([hidden])) .round-top a { display:none; }
}

@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  body:has(#answer-form:not([hidden]), #duel-answer-form:not([hidden])) :is(footer,#storage-notice) { display:none; }
  body:has(#answer-form:not([hidden]), #duel-answer-form:not([hidden])) main { min-height:0; }

  #spil:has(#answer-form:not([hidden])) .game,
  .duel:has(#duel-answer-form:not([hidden])) {
    height:var(--visible-height, 100dvh);
    padding-bottom:max(.45rem,env(safe-area-inset-bottom));
  }
  .duel:has(#duel-answer-form:not([hidden])) {
    display:flex; flex-direction:column; margin:0 auto;
  }
  .duel:has(#duel-answer-form:not([hidden])) #duel-room {
    flex:1; min-height:0; margin-bottom:0; display:flex; flex-direction:column;
  }
  #spil:has(#answer-form:not([hidden])) .board-space,
  #duel-room:has(#duel-answer-form:not([hidden])) .duel-board-space {
    flex:1; min-height:0; width:100%; margin:.25rem 0;
    container-type:size; display:grid;
    grid-template-rows:minmax(0,1fr);
    place-items:end center;
  }
  #spil:has(#answer-form:not([hidden])) #board,
  #duel-room:has(#duel-answer-form:not([hidden])) #duel-board {
    width:min(100%,100cqh); margin:0; container-type:inline-size;
  }
  #spil:has(#answer-form:not([hidden])) #feedback:empty { min-height:0; margin:0; }
  #duel-room:has(#duel-answer-form:not([hidden])) #duel-leave { order:-1; align-self:end; margin:0; }
}
@media(max-width:650px), (max-height:500px) and (pointer:coarse) {
  html:has(#spil:not([hidden]) #answer-form:not([hidden]),
    #duel:not([hidden]) #duel-answer-form:not([hidden])) {
    overflow:hidden;
    overscroll-behavior:none;
  }
  #spil:not([hidden]):has(#answer-form:not([hidden])) .game,
  #duel:not([hidden]):has(#duel-answer-form:not([hidden])) {
    position:fixed;
    top:var(--visible-top,0px);
    inset-inline:0;
    z-index:5;
    width:100%;
    max-width:none;
    height:var(--visible-height,100dvh);
    margin:0;
    border-radius:0;
  }
  #duel:not([hidden]):has(#duel-answer-form:not([hidden])) { background:var(--paper); }
}

.duel-create-options { display:grid; justify-items:start; gap:.3rem; }
#duel-lobby .duel-create-options label { display:flex; align-items:center; gap:.35rem; }
#duel-open { width:auto; }
#duel-challenges-list { padding:0; margin:.4rem 0; list-style:none; }
#duel-challenges-list li {
  display:flex; align-items:center; justify-content:space-between; gap:.5rem;
  padding:.4rem 0; border-bottom:1px solid var(--line); overflow-wrap:anywhere;
}
#duel-opponents { display:flex; flex-wrap:wrap; gap:.3rem .6rem; align-items:center; font-size:.8rem; }
.duel-watch-boards section { min-width:0; }
.duel-watch-boards p,#duel-opponents p { overflow-wrap:anywhere; }

#duel-watch-match:fullscreen {
  display:flex;
  flex-direction:column;
  gap:.35rem;
  overflow:hidden;
}
#duel-watch-match:fullscreen .duel-watch-heading,
#duel-watch-match:fullscreen > p,
#duel-watch-match:fullscreen .duel-watch-boards { width:100%; }
#duel-watch-match:fullscreen > p:empty { display:none; }
#duel-watch-match:fullscreen #duel-watch-name {
  margin:0;
  min-width:0;
  overflow-wrap:anywhere;
}
#duel-watch-match:fullscreen .duel-watch-boards {
  flex:1;
  min-height:0;
  grid-auto-rows:minmax(0,1fr);
}
#duel-watch-match:fullscreen .duel-watch-boards section {
  container-type:size;
  min-height:0;
}
#duel-watch-match:fullscreen .duel-watch-boards p {
  margin:0;
  line-height:1.6rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  text-align:center;
}
#duel-watch-match:fullscreen .duel-watch-boards .board {
  width:min(100%, max(0px, calc(100cqh - 1.6rem)));
  margin-inline:auto;
  container-type:inline-size;
}
#duel-watch-match:fullscreen .duel-watch-boards .board span {
  font-size:clamp(.3rem,3.55cqw,1.4rem);
}
@media(min-aspect-ratio:2/1) {
  #duel-watch-match:fullscreen .duel-watch-boards:has(section:nth-child(3)) {
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  #duel-watch-match:fullscreen .duel-watch-boards:has(section:nth-child(4)) {
    grid-template-columns:repeat(4,minmax(0,1fr));
  }
}

.chess-clocks { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.45rem; margin-top:.6rem; }
.chess-clocks > div {
  display:flex; justify-content:space-between; align-items:center; gap:.3rem;
  padding:.45rem .65rem; border:2px solid var(--line); border-radius:.45rem; background:var(--white);
}
.chess-clocks [aria-current="true"] { border-color:var(--yellow); box-shadow:inset 0 0 0 1px var(--yellow); }
.chess-clocks [aria-current="true"] span { font-weight:800; }
.chess-clocks strong { font-variant-numeric:tabular-nums; }
.chess-piece {
  display:block; width:90%; height:90%; overflow:visible; pointer-events:none;
  fill:var(--piece-fill); stroke:var(--piece-edge); stroke-width:2;
  stroke-linejoin:round; stroke-linecap:round;
}
.chess-piece-w { --piece-fill:#fff5da; --piece-edge:#26332c; }
.chess-piece-b { --piece-fill:#24352f; --piece-edge:#fff0d2; }
.chess-piece-detail { fill:var(--piece-edge); stroke:none; }
.chess-piece-line { fill:none; }
.chess-square.chess-queued { box-shadow:inset 0 0 0 3px #a22370; }
.chess-premove { display:flex; align-items:center; flex-wrap:wrap; gap:.5rem; margin-bottom:.65rem; }
.chess-premove p { font-size:.85rem; }

.chess-watch { margin:1.2rem 0; }
#chess-watch-list { display:flex; flex-wrap:wrap; gap:.45rem; padding:0; list-style:none; }
#chess-watch-heading { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.45rem; }
#chess-watch-heading h2 { overflow-wrap:anywhere; }
#chess-status:has(~ #chess-match #chess-watch-turn:not([hidden])) { display:none; }
#chess-watch-turn { margin-top:.4rem; }
#chess-match:fullscreen {
  background:var(--paper); color:var(--ink); overflow:auto;
  display:flex; flex-direction:column; align-items:center; gap:.4rem; padding:.75rem;
}
#chess-match:fullscreen :is(#chess-board,.chess-clocks,#chess-watch-heading) {
  width:min(100%,max(10rem,calc(100dvh - 10rem)));
}
#chess-match:fullscreen .chess-clocks { grid-template-columns:repeat(2,minmax(0,1fr)); margin:0; }
#chess-match:fullscreen #chess-board { margin:0; }

/* Trofæer: konturer indtil de er optjent, lys omkring de afslørede billeder. */
.trophy-card { position:relative; grid-template-columns: 1fr; text-align:center; justify-items:center; gap:.4rem; overflow:hidden; padding:1.35rem; }
.trophy-card.is-locked { opacity:1; }
.trophy-icon { grid-row:auto; display:grid; place-items:center; width:8rem; height:8rem; margin:.4rem auto 1rem; border-radius:50%; background:#1b2826; font-size:4rem; transition:filter .25s, box-shadow .25s; }
.trophy-icon img { display:block; width:100%; height:100%; object-fit:cover; border-radius:50%; }
.trophy-card.is-locked .trophy-icon { filter:blur(8px) grayscale(1); opacity:.5; }
.trophy-card.is-earned .trophy-icon { box-shadow:0 0 0 3px #d8b15a, 0 0 30px 8px rgba(232,180,69,.65); }
.trophy-card.is-unicorn.is-earned .trophy-icon { box-shadow:0 0 0 3px #ff80c8, 0 0 30px 8px #ff80c880; }
.trophy-state { font-size:.7rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
.trophy-card.is-earned .trophy-state { color:#9a6512; }
.trophy-card.is-unicorn.is-earned .trophy-state { color:#a8006b; }
[data-theme="dark"] .trophy-card.is-earned .trophy-state { color:#f2d077; }
[data-theme="dark"] .trophy-card.is-unicorn.is-earned .trophy-state { color:#ff9bd5; }

.number-hunt { max-width:32rem; margin:clamp(1rem,5vw,3rem) auto; padding:0 1rem; }
.number-hunt h1 { font-size:clamp(3rem,12vw,5.25rem); }
.hunt-controls,.hunt-progress { display:flex; flex-wrap:wrap; align-items:end; justify-content:space-between; gap:.6rem; }
.hunt-controls { margin:1.2rem 0 .75rem; }
.number-hunt button { border:0; border-radius:.6rem; background:var(--yellow); color:#172e28; padding:.55rem .85rem; font-weight:800; }
.hunt-game { padding:clamp(.85rem,4vw,1.35rem); border-radius:1rem; background:var(--white); border:1px solid var(--line); }
.hunt-progress { align-items:center; font-weight:700; }

[data-variant="division"] .board span { font-size:clamp(.45rem, 2.8cqw, 1rem); }

.top nav .nav-tools { position:relative; }
.top nav .nav-tools summary {
  gap:.35rem;
  list-style:none;
  cursor:pointer;
}
.top nav .nav-tools summary::-webkit-details-marker { display:none; }
.top nav .nav-tools summary::after {
  content:"";
  width:.4em;
  height:.4em;
  border-inline-end:2px solid currentColor;
  border-block-end:2px solid currentColor;
  transform:translateY(-.1em) rotate(45deg);
}
.top nav .nav-tools:is([open], :has([aria-current])) > summary {
  background:var(--lilac);
  color:#172e28;
}
.top nav .nav-tools:not([open]) .nav-tools-menu { display:none; }
.top nav .nav-tools-menu {
  position:absolute;
  z-index:12;
  inset-block-start:calc(100% + .35rem);
  inset-inline-end:0;
  min-width:max-content;
  padding:.25rem;
  border:1px solid var(--line);
  border-radius:.7rem;
  background:var(--white);
  color:var(--ink);
  box-shadow:0 .45rem 1rem #0003;
}
.top nav .nav-tools-menu a { display:block; border-radius:.4rem; }
.top nav .nav-tools-menu a:hover {
  background:var(--lilac);
  color:#172e28;
}
