:root {
  --ink: #1a1030;
  --yellow: #ffd93b;
  --pink: #ff3d6e;
  --green: #6dff5a;
  --cyan: #2fd3c8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(circle at 30% 20%, #3b1f7a, #140a2e 70%);
  color: #fff;
  font-family: "Fredoka", "Comic Sans MS", sans-serif;
}

#wrap {
  position: relative;
  width: min(100%, calc((100vh - 110px) * 16 / 9));
  min-width: 300px;
  aspect-ratio: 16 / 9;
  container-type: inline-size;
  border: 5px solid var(--ink);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 10px 0 var(--ink), 0 24px 40px rgba(0, 0, 0, .5);
}

canvas#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#wrap, .bar { user-select: none; -webkit-user-select: none; }
#nameInput { user-select: text; -webkit-user-select: text; }

/* ---------- Schermen over het spel heen ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5em;
  padding: 1.2em;
  overflow: auto;
  text-align: center;
  font-size: max(9px, 1.75cqw);
  background: rgba(20, 10, 46, .72);
}

.hidden { display: none !important; }

.title, .boom {
  margin: 0;
  font-weight: 700;
  line-height: 1;
  -webkit-text-stroke: .14em var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 .12em 0 var(--ink);
}
.title { font-size: 3.4em; color: #fff; transform: rotate(-2deg); }
.title span { color: var(--yellow); }
.boom { font-size: 4.2em; color: var(--pink); animation: pop .5s ease-out; }

.sub { margin: 0; font-size: 1.4em; font-weight: 700; }

.menu-grid {
  display: flex;
  gap: 2em;
  align-items: flex-start;
  justify-content: center;
  margin-top: .6em;
}
.menu-left { display: flex; flex-direction: column; align-items: center; gap: .7em; }

.choices { display: flex; gap: 1em; }

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .2em;
  padding: .4em .6em .5em;
  font: inherit;
  font-weight: 700;
  font-size: 1.1em;
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border: .2em solid var(--ink);
  border-radius: 1em;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.choice canvas { width: 6.6em; height: 8.8em; display: block; }
.choice:hover { transform: translateY(-.2em); }
.choice.selected {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 .3em 0 var(--ink);
  animation: bounce 1s ease-in-out infinite;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 1.2em;
  color: var(--ink);
  background: var(--yellow);
  border: .18em solid var(--ink);
  border-radius: .8em;
  padding: .4em 1.1em;
  box-shadow: 0 .25em 0 var(--ink);
  cursor: pointer;
  transition: transform .1s, box-shadow .1s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(.18em); box-shadow: 0 .07em 0 var(--ink); }
.btn small { font-size: .65em; font-weight: 500; }
.btn-big { font-size: 1.7em; padding: .3em 1.6em; background: var(--green); }
.btn-alt { background: var(--cyan); }
.btn-small { font-size: 15px; padding: 6px 14px; }

.howto { margin: 0; max-width: 24em; font-size: .9em; line-height: 1.5; opacity: .9; }
kbd {
  display: inline-block;
  padding: 0 .4em;
  border: .12em solid var(--ink);
  border-radius: .3em;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}
.green { color: var(--green); }
.pink { color: var(--pink); }

/* ---------- Highscores ---------- */
.panel {
  min-width: 17em;
  padding: .5em .9em .7em;
  background: rgba(255, 255, 255, .1);
  border: .18em solid var(--ink);
  border-radius: 1em;
}
.panel h2 { margin: 0 0 .3em; font-size: 1.4em; color: var(--yellow); }

.scores { list-style: none; margin: 0; padding: 0; }
.scores li {
  display: flex;
  align-items: center;
  gap: .5em;
  padding: .12em .35em;
  border-radius: .4em;
}
.scores li:nth-child(odd) { background: rgba(255, 255, 255, .05); }
.scores li.me { background: rgba(255, 217, 59, .35); animation: glow 1s ease-in-out infinite alternate; }
.scores li.empty { justify-content: center; opacity: .8; }
.scores .rank { width: 1.6em; text-align: right; font-weight: 700; }
.scores .name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 9em; }
.scores .pts { font-weight: 700; color: var(--yellow); }
.badge {
  display: inline-grid;
  place-items: center;
  width: 1.4em;
  height: 1.4em;
  border-radius: 50%;
  border: .12em solid var(--ink);
  font-size: .85em;
  font-weight: 700;
}
.badge.p1 { background: #ffe11a; color: #2563ff; }
.badge.p2 { background: #ff2d7a; color: #f2ef3a; }

/* ---------- Game over ---------- */
.final { margin: 0; font-size: 1.6em; }
.final strong { color: var(--yellow); font-size: 1.4em; }
.info { margin: 0; opacity: .85; }
#recordForm { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .5em; }
.newrecord { width: 100%; margin: 0; font-weight: 700; color: var(--green); font-size: 1.2em; }
#nameInput {
  font: inherit;
  font-size: 1.2em;
  width: 10em;
  padding: .3em .6em;
  border: .18em solid var(--ink);
  border-radius: .6em;
  outline: none;
}
#nameInput:focus { box-shadow: 0 0 0 .2em var(--yellow); }
.buttons { display: flex; gap: 1em; margin-top: .3em; }

/* ---------- Balk onder het spel ---------- */
.bar {
  width: min(100%, calc((100vh - 110px) * 16 / 9));
  min-width: 300px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.bar a { color: #fff; font-weight: 700; text-decoration: none; opacity: .85; }
.bar a:hover { opacity: 1; text-decoration: underline; }

@keyframes bounce { 50% { transform: translateY(-.25em); } }
@keyframes pop { 0% { transform: scale(.3); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes glow { to { background: rgba(255, 217, 59, .6); } }
