/* Eén scherm, één nachtlucht. Tijdens het spelen blijft de sterrenhemel staan. */
:root {
  --sky: #141a3a;
  --sky2: #1f2756;
  --panel: #262f66;
  --line: #3a4583;
  --ink: #f3f1ff;
  --muted: #a9b0e0;
  --gold: #ffc83d;
  --mint: #5ee0a8;
  --coral: #ff7a6b;
  --amber: #e9b949;
  --display: "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
[hidden]:not([hidden="until-found" i]) { display: none !important; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, var(--sky2), var(--sky) 70%);
  background-color: var(--sky);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  min-height: 100vh;
}
.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding-inline: 16px;
  padding-block: 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.settings { position: relative; }
.gear {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .25);
  color: var(--muted);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}
.gear svg { width: 20px; height: 20px; display: block; }
.gear[aria-expanded="true"] { background: var(--panel); color: var(--gold); }
.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  min-width: 196px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}
.menu button {
  display: block;
  width: 100%;
  font: 700 .95rem var(--body);
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 12px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.menu button:hover { background: var(--sky2); }
.menu button.danger { color: var(--coral); }
.menu p { margin: 4px 8px 8px; font-weight: 700; line-height: 1.35; }
.who { margin: 6px 12px 4px; font-size: .8rem; color: var(--muted); letter-spacing: .04em; }
#switchCode { margin-top: 4px; color: var(--muted); }
#logout { color: var(--muted); }
.menu-ask { display: flex; gap: 6px; }
.menu-ask button { text-align: center; background: var(--sky2); }
.menu-ask #gearYes { background: var(--coral); color: #3a0a05; }
h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: 2.2rem;
  line-height: 1;
  margin: 0;
  letter-spacing: .01em;
}
h1 span { color: var(--gold); }
.tally { font-family: var(--display); font-size: 1.05rem; color: var(--muted); }
.tally b { color: var(--gold); font-size: 1.4rem; }

.tabs { display: flex; gap: 4px; background: rgba(0, 0, 0, .25); padding: 4px; border-radius: 999px; }
.tab {
  flex: 1;
  font: 800 .95rem var(--display);
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 6px;
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }

.sky {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 6px;
  padding: 14px;
  border-radius: 22px;
  background: rgba(0, 0, 0, .18);
  border: 1px solid var(--line);
}
.star { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.star svg { width: 100%; max-width: 44px; height: auto; display: block; }
.star svg path { fill: var(--line); transition: fill .4s; }
.star.p1 svg path { fill: #6c6aa8; }
.star.p2 svg path { fill: #b49a4c; }
.star.gold svg path { fill: var(--gold); filter: drop-shadow(0 0 6px rgba(255, 200, 61, .6)); }
.star.now svg { animation: pulse 1s ease-in-out infinite; }
.star.extra small { color: var(--mint); }
.star small { font-size: .66rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@keyframes pulse { 50% { transform: scale(1.15); } }
.star.pop svg { animation: pop .7s ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.7) rotate(15deg); } 100% { transform: scale(1); } }
.legend { font-size: .82rem; color: var(--muted); margin: -6px 4px 0; line-height: 1.4; }

.card {
  background: var(--panel);
  border-radius: 26px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .25);
}
.label {
  font-family: var(--display);
  font-size: .95rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.intro { margin: 0; line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font: 700 .95rem var(--body);
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--gold); border-color: var(--gold); color: #2a2000; }
.big {
  font: 800 1.4rem var(--display);
  background: var(--gold);
  color: #2a2000;
  border: 0;
  border-radius: 18px;
  padding: 14px;
  cursor: pointer;
}
.big:active { transform: translateY(2px); }
.big:disabled { opacity: .55; cursor: wait; }
.big:disabled:active { transform: none; }
.ghost {
  font: 700 .95rem var(--body);
  background: none;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  padding: 2px;
}
button:focus-visible, .field:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }

.dots { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dot.fast { background: var(--gold); }
.dot.slow { background: var(--mint); }
.dot.wrong { background: var(--coral); }
.timer { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--gold); transform-origin: left; }
.qrow { display: flex; align-items: baseline; justify-content: center; gap: .3em; flex-wrap: wrap; }
.q, .eq, .ans {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.4rem, 11vw, 3.4rem);
  line-height: 1.1;
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.eq { color: var(--muted); }
.ans { min-width: 3ch; text-align: center; border-bottom: 4px solid var(--line); transition: border-color .2s; }
.ans.good { border-color: var(--mint); color: var(--mint); }
.ans.bad { border-color: var(--coral); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.hint {
  background: rgba(0, 0, 0, .2);
  border-radius: 16px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: .98rem;
  line-height: 1.4;
  text-align: center;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hint.cheer { color: var(--mint); }
.hint.help { color: var(--gold); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button {
  font: 800 1.6rem var(--display);
  color: var(--ink);
  background: var(--sky2);
  border: 0;
  border-radius: 16px;
  height: clamp(46px, 8.5vh, 62px);
  cursor: pointer;
  touch-action: manipulation;
}
.pad button:active { background: var(--line); }
.pad .ok { background: var(--mint); color: #06301f; }
.pad .del { font-size: 1.3rem; color: var(--muted); }
.kbtip { display: none; font-size: .85rem; color: var(--muted); text-align: center; margin: 0; }

.end { text-align: center; }
.end .score { font: 800 3rem var(--display); color: var(--gold); line-height: 1; margin: 0; }
.end p { margin: 0; line-height: 1.5; }
.practice { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.practice span {
  font: 700 1.1rem var(--display);
  background: var(--sky2);
  border-radius: 12px;
  padding: 6px 12px;
  font-variant-numeric: tabular-nums;
}

.listbar { display: flex; gap: 8px; flex-wrap: wrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  background: var(--sky2);
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--body);
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: center;
  min-height: 104px;
  justify-content: center;
}
.tile:hover { border-color: var(--line); }
.tile .sum { font: 800 1.7rem var(--display); line-height: 1; font-variant-numeric: tabular-nums; }
.tile .res { font: 800 1.7rem var(--display); line-height: 1; color: var(--muted); }
.tile.open { border-color: var(--gold); }
.tile.open .res { color: var(--gold); }
.tile .truc { font-size: .78rem; color: var(--muted); line-height: 1.3; }
.tile.extra .sum { color: var(--mint); }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sumbox { background: var(--sky2); border-radius: 14px; padding: 10px 6px; text-align: center; }
.sumbox b { display: block; font: 800 1.7rem var(--display); line-height: 1; font-variant-numeric: tabular-nums; }
.sumbox span { font-size: .8rem; color: var(--muted); }
.sumbox.fast b { color: var(--gold); }
.sumbox.slow b { color: var(--mint); }
.sumbox.wrong b { color: var(--coral); }
.gridwrap { overflow-x: auto; }
table.res { border-collapse: separate; border-spacing: 3px; margin: 0 auto; font-variant-numeric: tabular-nums; }
.res th { font: 800 .9rem var(--display); color: var(--muted); width: 2.4em; height: 2.1em; }
.res td {
  width: 2.6em;
  height: 2.2em;
  border-radius: 7px;
  text-align: center;
  font: 700 .82rem var(--body);
  background: var(--sky2);
  color: var(--muted);
}
.res td.fast { background: var(--gold); color: #2a2000; }
.res td.slow { background: var(--mint); color: #06301f; }
.res td.wrong { background: var(--coral); color: #3a0a05; }
.res td.mirror { opacity: .45; }
.keyrow { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; font-size: .85rem; color: var(--muted); }
.keyrow i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 5px; vertical-align: -1px; }
.watch { font-size: .95rem; line-height: 1.5; margin: 0; }
.watch b { font-family: var(--display); font-size: 1.05rem; }
.sync { font-size: .78rem; color: var(--muted); text-align: center; margin: 0; }

.login { display: flex; flex-direction: column; gap: 12px; }
.field {
  font: 700 1.05rem var(--body);
  color: var(--ink);
  background: var(--sky2);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  width: 100%;
}

body.playing .legend, body.playing .tabs, body.playing .settings { display: none; }
body.playing .wrap { padding-block: 10px 12px; gap: 10px; }
body.playing h1 { font-size: 1.5rem; }
body.playing .card { padding: 14px; gap: 10px; }
body.playing .sky {
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 2px;
  padding: 8px 10px;
  border-radius: 16px;
}
body.playing .star svg { max-width: 30px; }
body.playing .star small { font-size: .56rem; }
@media (max-width: 699px) {
  body.playing .star small { display: none; }
}
@media (min-width: 700px) {
  body.playing .wrap { max-width: 900px; }
  body.playing header { display: none; }
  #playView {
    display: grid;
    grid-template-columns: 1fr 300px;
    column-gap: 24px;
    row-gap: 10px;
    grid-template-areas: "dots pad" "timer pad" "qrow pad" "hint pad" "kbtip pad" "stop pad";
    align-items: center;
  }
  #dots { grid-area: dots; }
  .timer { grid-area: timer; }
  .qrow { grid-area: qrow; }
  #hint { grid-area: hint; }
  .kbtip { display: block; grid-area: kbtip; }
  #stopBtn { grid-area: stop; justify-self: center; }
  .pad { grid-area: pad; }
  .pad button { height: clamp(44px, 9vh, 64px); }
  .q, .eq, .ans { font-size: clamp(3rem, 7vw, 4.2rem); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
