*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e1a;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  font-family: monospace;
}

.hidden { display: none !important; }

#canvas-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Touch controls ─────────────────────────────────────────── */
#touch-controls {
  display: none; /* zichtbaarheid via JS (alleen PLAYING + touch) */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

#touch-left-group {
  display: flex;
  gap: 12px;
  pointer-events: none;
}

.touch-btn {
  pointer-events: all;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(27, 42, 74, 0.5);
  border: 2px solid #4da6ff;
  color: #4da6ff;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  touch-action: none;
  outline: none;
  opacity: 0.75;
  transition: opacity 0.08s, background 0.08s;
}

.touch-btn.pressed {
  opacity: 1;
  background: rgba(77, 166, 255, 0.3);
}

#btn-jump {
  width: 74px;
  height: 74px;
  font-size: 24px;
}

/* ── HUD ────────────────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 20;
  color: #4da6ff;
}

#hud-level {
  font-size: 13px;
  opacity: 0.75;
  letter-spacing: 0.04em;
}

#hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#hud-deaths {
  font-size: 14px;
  color: #ffffff;
  opacity: 0.9;
}

#hud-deaths .skull { font-size: 15px; }

#btn-hud-pause {
  pointer-events: all;
  min-width: 44px;
  min-height: 44px;
  background: rgba(27, 42, 74, 0.7);
  border: 2px solid #4da6ff;
  border-radius: 8px;
  color: #4da6ff;
  font-size: 14px;
  font-family: monospace;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#btn-hud-pause:active { background: rgba(77, 166, 255, 0.35); }

/* ── Schermen (menu, levelselect, pauze, einde) ─────────────── */
.screen {
  position: fixed;
  inset: 0;
  background: #0a0e1a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  z-index: 30;
  color: #ffffff;
  overflow: hidden;
}

.screen.overlay {
  background: rgba(10, 14, 26, 0.86);
  z-index: 40;
}

#confirm-screen { z-index: 50; }

.screen-title {
  font-size: 34px;
  letter-spacing: 0.12em;
  color: #4da6ff;
}

/* ── Hoofdmenu ──────────────────────────────────────────────── */
#menu-title {
  font-size: clamp(34px, 7vw, 64px);
  letter-spacing: 0.1em;
  color: #ffffff;
  text-shadow: 0 0 18px rgba(77, 166, 255, 0.55);
  z-index: 2;
  text-align: center;
}

#menu-title.glitching #title-text {
  color: #ff3b5c;
  text-shadow: 3px 0 #00e0ff, -3px 0 #ff3b5c;
}

#menu-crown { font-size: 0.55em; margin-left: 10px; }

#menu-stats {
  font-size: 13px;
  color: #3d5a99;
  z-index: 2;
}

#menu-tiles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.menu-tile {
  position: absolute;
  top: -40px;
  width: 30px;
  height: 30px;
  background: #1b2a4a;
  border-top: 2px solid #3d5a99;
  animation: tile-fall linear forwards;
}

@keyframes tile-fall {
  from { transform: translateY(0); }
  to   { transform: translateY(115vh); }
}

/* ── Knoppen ────────────────────────────────────────────────── */
.btn-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  z-index: 2;
}

.btn-row {
  display: flex;
  gap: 16px;
  z-index: 2;
}

.ui-btn {
  min-width: 230px;
  min-height: 48px;
  padding: 12px 28px;
  background: #1b2a4a;
  border: 2px solid #4da6ff;
  border-radius: 8px;
  color: #ffffff;
  font-family: monospace;
  font-size: 17px;
  letter-spacing: 0.08em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s, transform 0.06s;
}

.ui-btn:active {
  background: rgba(77, 166, 255, 0.3);
  transform: scale(0.97);
}

.ui-btn.primary {
  background: #4da6ff;
  border-color: #4da6ff;
  color: #0a0e1a;
  font-weight: bold;
}

.ui-btn.primary:active { background: #00e0ff; }

.btn-row .ui-btn { min-width: 120px; }

.reset-btn {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  min-height: 44px;
  padding: 10px 18px;
  background: none;
  border: none;
  color: #3d5a99;
  font-family: monospace;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.reset-btn:active { color: #ff3b5c; }

/* ── Level-select ───────────────────────────────────────────── */
#level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(58px, 72px));
  gap: 12px;
  z-index: 2;
}

.level-cell {
  position: relative;
  aspect-ratio: 1;
  min-height: 48px;
  background: #1b2a4a;
  border: 2px solid #3d5a99;
  border-radius: 8px;
  color: #ffffff;
  font-family: monospace;
  font-size: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.level-cell:active { background: rgba(77, 166, 255, 0.25); }

.level-cell.done { border-color: #00e0ff; }

.level-cell .cell-deaths {
  font-size: 9px;
  color: #00e0ff;
  margin-top: 2px;
  opacity: 0.85;
}

.level-cell.next {
  border-color: #4da6ff;
  animation: next-pulse 1.6s ease-in-out infinite;
}

@keyframes next-pulse {
  0%, 100% { box-shadow: 0 0 4px rgba(77, 166, 255, 0.4); }
  50%      { box-shadow: 0 0 16px rgba(77, 166, 255, 0.9); }
}

.level-cell.locked {
  background: #10182d;
  border-color: #1b2a4a;
  color: #3d5a99;
  cursor: default;
  font-size: 14px;
}

/* geskipt via rewarded ad: grijze rand i.p.v. cyaan */
.level-cell.skipped { border-color: #5a6b8c; }
.level-cell.skipped .cell-deaths { color: #5a6b8c; }

/* ── Mute-knop (menu + pauze) ───────────────────────────────── */
.icon-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  min-width: 44px;
  min-height: 44px;
  background: #1b2a4a;
  border: 2px solid #4da6ff;
  border-radius: 8px;
  font-size: 19px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.icon-btn:active { background: rgba(77, 166, 255, 0.3); }

/* ── Skip-level aanbod (rewarded ad) ────────────────────────── */
#skip-offer {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  z-index: 15;
}

.skip-btn {
  min-height: 44px;
  padding: 10px 16px;
  background: rgba(27, 42, 74, 0.88);
  border: 2px solid #ffd166;
  border-radius: 8px;
  color: #ffd166;
  font-family: monospace;
  font-size: 13px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.skip-btn:active { background: rgba(255, 209, 102, 0.25); }

.skip-close {
  min-width: 44px;
  border-color: #3d5a99;
  color: #3d5a99;
}

/* ── Hoofdstukken ────────────────────────────────────────────── */
#chapter-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  max-width: 92vw;
  z-index: 2;
}

.chapter-arrow {
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  background: #10182d;
  border: 2px solid #3d5a99;
  border-radius: 10px;
  color: #4da6ff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.chapter-arrow:active { background: rgba(77, 166, 255, 0.25); }

.chapter-arrow:disabled {
  color: #2c3a5c;
  border-color: #1b2a4a;
  cursor: default;
}

#chapter-nav-mid {
  min-width: 220px;
  text-align: center;
}

#chapter-nav-kicker {
  font-size: 13px;
  letter-spacing: 0.18em;
  color: #5a6b8c;
}

#chapter-nav-name {
  font-size: 34px;
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #ffffff;
  margin-top: 2px;
}

#chapter-nav-name.locked { color: #3d5a99; }

#chapter-kicker {
  font-size: 15px;
  letter-spacing: 0.35em;
  color: #3d5a99;
  z-index: 2;
}

#chapter-title {
  font-size: clamp(36px, 7vw, 64px);
  letter-spacing: 0.12em;
  color: #ff3b5c;
  text-shadow: 0 0 22px rgba(255, 59, 92, 0.45);
  z-index: 2;
}

#chapter-tag {
  font-size: 15px;
  color: #ffd166;
  z-index: 2;
}

/* ── Shop / skins ───────────────────────────────────────────── */
#menu-wallet {
  font-size: 15px;
  color: #ffd166;
  letter-spacing: 0.06em;
  z-index: 2;
}

#shop-wallet {
  font-size: 20px;
  color: #ffd166;
  z-index: 2;
}

#skin-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  z-index: 2;
}

#skin-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}

#skin-preview {
  width: 96px;
  height: 120px;
  background: rgba(10, 14, 26, 0.5);
  border: 2px solid #1b2a4a;
  border-radius: 10px;
}

#skin-kicker {
  font-size: 13px;
  letter-spacing: 0.18em;
  color: #5a6b8c;
}

#skin-name-big {
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 0.05em;
  color: #ffffff;
}

#skin-action { min-width: 150px; }
#skin-action.on   { background: #4da6ff; color: #0a0e1a; border-color: #4da6ff; }
#skin-action.ad   { border-color: #ffd166; color: #ffd166; }
#skin-action.poor { border-color: #3d5a99; color: #3d5a99; }

/* ── Achievements ────────────────────────────────────────────── */
#ach-progress {
  font-size: 14px;
  color: #5a6b8c;
  letter-spacing: 0.1em;
  z-index: 2;
}

#ach-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 460px);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 2;
  padding: 4px;
}

.ach-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #10182d;
  border: 2px solid #1b2a4a;
  border-radius: 10px;
  padding: 10px 14px;
  text-align: left;
}

.ach-row.unlocked { background: #1b2a4a; border-color: #4da6ff; }

.ach-icon {
  font-size: 22px;
  flex: 0 0 auto;
  width: 26px;
  text-align: center;
}

.ach-text { flex: 1; }

.ach-name {
  font-size: 15px;
  color: #3d5a99;
  letter-spacing: 0.04em;
}
.ach-row.unlocked .ach-name { color: #ffffff; }

.ach-desc {
  font-size: 11px;
  color: #3d5a99;
  margin-top: 2px;
}
.ach-row.unlocked .ach-desc { color: #8a97b8; }

#ach-toast {
  position: fixed;
  top: 64px;
  left: 50%;
  transform: translateX(-50%) translateY(-14px);
  background: #1b2a4a;
  border: 2px solid #ffd166;
  color: #ffd166;
  padding: 10px 18px;
  border-radius: 10px;
  font-family: monospace;
  font-size: 15px;
  letter-spacing: 0.04em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 50;
  white-space: nowrap;
}
#ach-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.skin-cell {
  background: #1b2a4a;
  border: 2px solid #3d5a99;
  border-radius: 10px;
  padding: 10px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.skin-cell.equipped { border-color: #4da6ff; box-shadow: 0 0 12px rgba(77, 166, 255, 0.5); }

.skin-swatch {
  width: 30px;
  height: 38px;
  border-radius: 5px;
  background: rgba(10, 14, 26, 0.5);
}

.skin-name {
  font-size: 12px;
  color: #ffffff;
  letter-spacing: 0.03em;
}

.skin-btn {
  min-height: 30px;
  width: 100%;
  padding: 6px 4px;
  background: #0f1830;
  border: 1px solid #4da6ff;
  border-radius: 6px;
  color: #4da6ff;
  font-family: monospace;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.skin-btn.on     { background: #4da6ff; color: #0a0e1a; border-color: #4da6ff; }
.skin-btn.ad     { border-color: #ffd166; color: #ffd166; }
.skin-btn.poor   { border-color: #3d5a99; color: #3d5a99; }
.skin-btn:active { background: rgba(77, 166, 255, 0.3); }

/* ── Eindscherm ─────────────────────────────────────────────── */
#end-title {
  font-size: clamp(26px, 5.5vw, 46px);
  letter-spacing: 0.08em;
  color: #00e0ff;
  text-shadow: 0 0 22px rgba(0, 224, 255, 0.6);
  text-align: center;
  padding: 0 16px;
  z-index: 2;
}

#end-stats {
  font-size: 15px;
  color: #ffd166;
  text-align: center;
  line-height: 1.9;
  z-index: 2;
}

#pause-hint {
  font-size: 12px;
  color: #3d5a99;
  letter-spacing: 0.04em;
  z-index: 2;
}

#confirm-text {
  font-size: 16px;
  color: #ffffff;
  text-align: center;
  padding: 0 24px;
  max-width: 560px;
  line-height: 1.7;
}

/* ── Portrait overlay ───────────────────────────────────────── */
#portrait-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: #0a0e1a;
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: #4da6ff;
  font-family: monospace;
  font-size: 18px;
  letter-spacing: 0.05em;
}

@media (orientation: portrait) {
  #portrait-overlay { display: flex; }
}

.rotate-icon {
  width: 44px;
  height: 68px;
  border: 3px solid #4da6ff;
  border-radius: 8px;
  position: relative;
  animation: rotate-hint 2.4s ease-in-out infinite;
}

.rotate-icon::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: #4da6ff;
}

.rotate-icon::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4da6ff;
}

@keyframes rotate-hint {
  0%, 30%   { transform: rotate(0deg); }
  65%, 100% { transform: rotate(-90deg); }
}
