* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #6db3e8;
  font-family: "Nunito", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
h1, h3, button { font-family: "Lilita One", "Nunito", sans-serif; font-weight: 400; letter-spacing: 1px; }

#game { position: fixed; inset: 0; display: block; }

/* ---------------- vizier ---------------- */
#vizier { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none; }
#vizier[hidden] { display: none; }
#kruis { position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; transform: translate(-50%, -50%); }
#kruis::before, #kruis::after {
  content: ""; position: absolute; background: rgba(255,255,255,.85);
  box-shadow: 0 0 3px rgba(0,0,0,.6);
}
#kruis::before { left: 8px; top: 0; width: 2px; height: 18px; }
#kruis::after { left: 0; top: 8px; width: 18px; height: 2px; }
#ring { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); }

#flits {
  position: fixed; inset: 0; z-index: 7; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(200,20,20,.15) 40%, rgba(180,0,0,.55) 100%);
  transition: opacity .35s;
}
#onderwater {
  position: fixed; inset: 0; z-index: 6; pointer-events: none; opacity: 0;
  background: rgba(30, 80, 190, .3);
}

/* vastgehouden item rechtsonder in beeld (first-person hand) */
#hand {
  position: fixed; right: clamp(-20px, -2vh, -10px); bottom: clamp(-16px, -1.5vh, -8px);
  z-index: 4; pointer-events: none;
  width: clamp(110px, 26vh, 230px); height: clamp(110px, 26vh, 230px);
  transform: rotate(-12deg);
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.45));
  animation: hand-idle 2.6s ease-in-out infinite;
}
#hand[hidden] { display: none; }
#hand canvas { width: 100%; height: 100%; image-rendering: pixelated; }
@keyframes hand-idle {
  0%, 100% { transform: rotate(-12deg) translateY(0); }
  50%      { transform: rotate(-10deg) translateY(6px); }
}
#hand.zwaai { animation: hand-zwaai .32s ease-in-out infinite; }
@keyframes hand-zwaai {
  0%, 100% { transform: rotate(-8deg) translate(0, 0); }
  50%      { transform: rotate(-38deg) translate(-26px, 14px); }
}

/* ---------------- HUD ---------------- */
#hud[hidden] { display: none; }
#harten {
  position: fixed; left: 14px; top: 12px; z-index: 8;
  display: flex; gap: 3px; pointer-events: none;
}
.hart { position: relative; width: clamp(20px, 3.4vh, 26px); height: clamp(20px, 3.4vh, 26px); }
.hart svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.hart .vul { position: absolute; inset: 0; overflow: hidden; }

#dagchip {
  position: fixed; right: 14px; top: 12px; z-index: 8;
  display: flex; align-items: center; gap: 8px; pointer-events: none;
  background: rgba(20, 28, 20, .72); border: 2px solid rgba(255,255,255,.25);
  border-radius: 12px; padding: 5px 14px;
  color: #fff; font-weight: 800; font-size: clamp(15px, 2.6vh, 20px);
}
#dag-icoon { display: flex; }
#dag-klok { width: 22px; height: 22px; }

/* luchtmeter (bubbels) boven de sneltas als je onder water bent */
#adem {
  position: fixed; left: 50%; bottom: clamp(58px, 9.8vh, 76px); transform: translateX(-50%);
  z-index: 8; display: flex; gap: 5px; pointer-events: none;
}
#adem[hidden] { display: none; }
#adem .bubbel {
  width: 15px; height: 15px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #eaf6ff 0 30%, #9fd0f5 65%, #5aa3e0 100%);
  border: 1.5px solid rgba(20, 50, 90, .55);
  transition: opacity .2s;
}
#adem .bubbel.leeg { opacity: .18; }

#hotbar {
  position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 8;
  display: flex; gap: 4px;
}
.slot {
  position: relative; width: clamp(40px, 7.2vh, 54px); height: clamp(40px, 7.2vh, 54px);
  background: rgba(20, 24, 30, .72); border: 2px solid rgba(255,255,255,.28);
  border-radius: 8px; cursor: pointer;
}
.slot.sel { border-color: #ffe14d; box-shadow: 0 0 10px rgba(255, 225, 77, .55); }
.slot canvas { position: absolute; inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); image-rendering: pixelated; }
.slot .n {
  position: absolute; right: 3px; bottom: 1px; z-index: 2;
  color: #fff; font-size: 13px; font-weight: 800;
  text-shadow: 0 1px 2px #000, 0 0 3px #000;
}

/* ---------------- opdrachten ---------------- */
#btn-opdr {
  position: fixed; left: 14px; top: clamp(44px, 6.5vh, 52px); z-index: 8;
  display: flex; align-items: center; gap: 7px;
  background: rgba(20, 28, 20, .72); border: 2px solid rgba(255,255,255,.25);
  border-radius: 12px; padding: 5px 12px; cursor: pointer;
  color: #ffd97a; font-family: "Nunito", sans-serif; font-weight: 800;
  font-size: clamp(13px, 2.2vh, 16px);
}
#btn-opdr::before {
  content: ""; width: 18px; height: 18px; flex: none;
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="%23ffd97a" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="4" width="14" height="17" rx="2"/><path d="M9 4a3 3 0 0 1 6 0"/><path d="m8.5 12 2 2 4-4.5"/></svg>') no-repeat center / contain;
}
body.touch #btn-opdr { top: 104px; }

#opdr {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 21;
  width: min(92vw, 480px); max-height: 82vh;
  display: flex; flex-direction: column;
  background: #2a2620; border: 3px solid #5a4a32; border-radius: 14px;
  box-shadow: 0 14px 50px rgba(0,0,0,.6); color: #f0e6d2;
}
#opdr[hidden] { display: none; }
#opdr-kop {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 2px solid #5a4a32;
  font-family: "Lilita One", sans-serif; font-size: clamp(17px, 3vh, 22px); color: #ffd97a;
}
#btn-opdr-sluit {
  width: 34px; height: 34px; border: none; border-radius: 8px; cursor: pointer;
  background: #6e3b2c; color: #fff; font-size: 22px; line-height: 1;
}
#opdr-lijst { overflow-y: auto; padding: 10px 14px 14px; }
.opdracht {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0,0,0,.22); border-radius: 10px; padding: 5px 10px; margin-bottom: 4px;
  font-weight: 800; font-size: clamp(12px, 2.2vh, 14px);
}
.opdracht .vink {
  width: 24px; height: 24px; flex: none; border-radius: 7px;
  border: 2px solid #5a4a32; display: flex; align-items: center; justify-content: center;
}
.opdracht.klaar { color: #9be27f; }
.opdracht.klaar .vink { background: #4a9c3d; border-color: #7ed957; }
.opdracht .otekst { flex: 1; }
.opdracht .ovoort { opacity: .75; font-size: .85em; margin-left: 6px; }
.opdracht .obeloning { display: block; font-size: .78em; color: #c9b688; font-weight: 700; }

#toast {
  position: fixed; left: 50%; top: clamp(52px, 8vh, 70px); transform: translate(-50%, -16px); z-index: 26;
  background: rgba(20, 28, 20, .92); border: 2px solid #7ed957;
  border-radius: 12px; padding: 9px 18px;
  color: #d6ffc4; font-weight: 800; font-size: clamp(13px, 2.4vh, 17px);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
  max-width: min(88vw, 560px); text-align: center;
}
#toast.zichtbaar { opacity: 1; transform: translate(-50%, 0); }

/* ---------------- touch-besturing ---------------- */
#joy {
  position: fixed; left: 24px; bottom: 84px; z-index: 9;
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(20, 24, 30, .35); border: 2px solid rgba(255,255,255,.3);
  touch-action: none;
}
#joy[hidden] { display: none; }
#joy-knop {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px;
  transform: translate(-50%, -50%); border-radius: 50%;
  background: rgba(255,255,255,.75); box-shadow: 0 3px 8px rgba(0,0,0,.35);
}
#touch-knoppen { position: fixed; right: 18px; bottom: 84px; z-index: 9; display: flex; flex-direction: column; gap: 12px; }
#touch-knoppen[hidden] { display: none; }
#touch-knoppen button, #btn-rugzak {
  width: 62px; height: 62px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4);
  background: rgba(20, 24, 30, .55); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  touch-action: none;
}
#touch-knoppen button:active { background: rgba(90, 160, 70, .75); }
#btn-rugzak { position: fixed; right: 18px; bottom: 10px; z-index: 9; width: 54px; height: 54px; }
#btn-rugzak[hidden] { display: none; }

/* ---------------- paneel (rugzak/werkbank) ---------------- */
#paneel {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 20;
  width: min(92vw, 720px); max-height: 86vh;
  display: flex; flex-direction: column;
  background: #2a2620; border: 3px solid #5a4a32; border-radius: 14px;
  box-shadow: 0 14px 50px rgba(0,0,0,.6); color: #f0e6d2;
}
#paneel[hidden] { display: none; }
#paneel-kop {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; border-bottom: 2px solid #5a4a32;
  font-family: "Lilita One", sans-serif; font-size: clamp(17px, 3vh, 22px); color: #ffd97a;
}
#btn-sluit {
  width: 34px; height: 34px; border: none; border-radius: 8px; cursor: pointer;
  background: #6e3b2c; color: #fff; font-size: 22px; line-height: 1;
}
#paneel-body { display: flex; gap: 16px; padding: 14px 16px; overflow: hidden; min-height: 0; }
#inv-kant { flex: 1.15; min-width: 0; }
#craft-kant { flex: 1; min-width: 0; border-left: 2px solid #5a4a32; padding-left: 16px; display: flex; flex-direction: column; min-height: 0; }
#recepten { overflow-y: auto; min-height: 0; padding-right: 4px; }

/* nette, thematische scrollbalk (alleen zichtbaar als het echt moet) */
#recepten, #opdr-lijst, #paneel-body { scrollbar-width: thin; scrollbar-color: #5a4a32 transparent; }
#recepten::-webkit-scrollbar, #opdr-lijst::-webkit-scrollbar, #paneel-body::-webkit-scrollbar { width: 8px; }
#recepten::-webkit-scrollbar-track, #opdr-lijst::-webkit-scrollbar-track, #paneel-body::-webkit-scrollbar-track { background: transparent; }
#recepten::-webkit-scrollbar-thumb, #opdr-lijst::-webkit-scrollbar-thumb, #paneel-body::-webkit-scrollbar-thumb {
  background: #5a4a32; border-radius: 6px;
}
#paneel h3 { margin: 6px 0 6px; font-size: clamp(14px, 2.4vh, 17px); color: #c9b688; text-transform: uppercase; letter-spacing: 2px; }
.grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.grid .slot { width: auto; height: auto; aspect-ratio: 1; }
.recept {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,.22); border-radius: 10px; padding: 4px 8px; margin-bottom: 4px;
}
.recept canvas { image-rendering: pixelated; }
.recept .info { flex: 1; min-width: 0; }
.recept .naam { font-weight: 800; font-size: clamp(13px, 2.2vh, 15px); }
.recept .kost { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.recept .kost span { display: flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 800; color: #9be27f; }
.recept .kost span.mis { color: #f28d7d; }
.recept .kost canvas { width: 16px; height: 16px; }
.recept button {
  border: none; border-radius: 8px; padding: 6px 13px; cursor: pointer;
  font-size: clamp(12px, 2.1vh, 14px); color: #13260e;
  background: #7ed957; border-bottom: 4px solid #4a9c3d;
}
.recept button:disabled { filter: grayscale(.8); opacity: .55; cursor: default; }
.recept button:not(:disabled):active { transform: translateY(2px); border-bottom-width: 2px; }

@media (max-width: 620px) {
  #paneel-body { flex-direction: column; }
  #craft-kant { border-left: none; padding-left: 0; border-top: 2px solid #5a4a32; padding-top: 10px; }
}

/* ---------------- overlays ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background:
    linear-gradient(180deg, rgba(0,0,0,0) 62%, rgba(38, 84, 32, .9) 62%, #1d4a17 100%),
    linear-gradient(180deg, #2a6bb5 0%, #5aa3e0 45%, #8ec9ef 62%, #8ec9ef 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: clamp(6px, 1.6vh, 16px); text-align: center;
  padding: clamp(8px, 2vh, 24px);
  color: #fff; overflow: hidden;
}
.overlay[hidden] { display: none; }
.overlay h1 {
  font-size: clamp(28px, min(7.5vh, 8.6vw), 76px); margin: 0; line-height: 1.02;
  color: #fff; text-shadow: 0 4px 0 #2c5e22, 0 8px 22px rgba(0,0,0,.35);
}
.overlay .sub { font-size: clamp(14px, 2.5vh, 19px); font-weight: 800; max-width: 560px; margin: 0; text-shadow: 0 2px 6px rgba(0,0,0,.4); }
.overlay .hulp { font-size: clamp(11px, 2vh, 14px); font-weight: 700; opacity: .95; margin: 4px 0 0; text-shadow: 0 1px 4px rgba(0,0,0,.5); }
#start-cubes { width: clamp(220px, 38vh, 380px); height: auto; image-rendering: pixelated; }
.stats {
  font-weight: 800; font-size: clamp(14px, 2.4vh, 18px);
  background: rgba(0, 0, 0, .3); border: 2px solid rgba(255,255,255,.4);
  padding: clamp(4px, .9vh, 8px) clamp(16px, 3vw, 28px); border-radius: 10px;
}
.overlay button {
  font-size: clamp(16px, 2.8vh, 24px); cursor: pointer;
  border: none; border-radius: 14px;
  padding: clamp(9px, 1.7vh, 14px) clamp(24px, 4.5vw, 48px);
  color: #13260e; background: #7ed957; border-bottom: 6px solid #4a9c3d;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
  transition: transform .08s;
}
.overlay button:active { transform: translateY(4px); border-bottom-width: 2px; }
.overlay button.secondary { color: #fff; background: #5a4a32; border-bottom-color: #3b3021; }
.overlay button:disabled { filter: grayscale(.6); opacity: .7; cursor: default; }
.btn-row { display: flex; gap: clamp(10px, 2vw, 18px); flex-wrap: wrap; justify-content: center; }

#dood-label { font-weight: 800; letter-spacing: 6px; text-transform: uppercase; font-size: clamp(13px, 2.4vh, 20px); opacity: .95; }
#dood-dagen { font-family: "Lilita One", sans-serif; font-size: clamp(56px, 14vh, 130px); line-height: 1; color: #ffe14d; text-shadow: 0 5px 0 #8a6231, 0 10px 24px rgba(0,0,0,.4); }
#dood-record { font-size: clamp(15px, 2.8vh, 24px); font-weight: 800; color: #ffe14d; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }
#dood.overlay { background: linear-gradient(180deg, #1c1220 0%, #33202c 60%, #4a2c33 130%); }
#pauze.overlay { background: linear-gradient(180deg, #16211c 0%, #22352a 60%, #2c4534 130%); }

/* ---------------- standaardknoppen ---------------- */
#btn-mute, #btn-fs, #btn-home {
  position: fixed; bottom: 16px; z-index: 35;
  width: 54px; height: 54px; border-radius: 50%; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.92);
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
  transition: transform .08s;
}
#btn-mute { right: 16px; }
#btn-fs { right: 82px; }
#btn-home { right: 148px; }
#btn-mute:active, #btn-fs:active, #btn-home:active { transform: scale(.92); }
#btn-mute[hidden], #btn-fs[hidden], #btn-home[hidden] { display: none; }
/* op touch-schermen zit rechtsonder de bouwknoppenrij → standaardknoppen naar boven */
body.touch #btn-mute { right: auto; left: 16px; top: 52px; bottom: auto; width: 44px; height: 44px; }
body.touch #btn-fs { right: auto; left: 68px; top: 52px; bottom: auto; width: 44px; height: 44px; }
body.touch #btn-home { right: auto; left: 120px; top: 52px; bottom: auto; width: 44px; height: 44px; }
