/* Boomhut bouwen: HUD over a full-screen WebGL canvas. Phone first, touch first. */
:root {
  --cream: #fff6e6;
  --ink: #3b2a1a;
  --wood: #8b5a2b;
  --wood-dark: #5e3b1c;
  --leaf: #3f9b4b;
  --leaf-dark: #2c7437;
  --danger: #d2503f;
  --danger-dark: #9f3526;
  --shadow: 0 6px 18px rgba(40, 25, 10, .22);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; background: #8fd0ff; touch-action: manipulation; -webkit-text-size-adjust: 100%; }
body {
  position: fixed; inset: 0;
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 700; color: var(--ink);
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }

/* ---- HUD frame ---- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.top {
  position: absolute; left: calc(12px + var(--sal)); right: calc(12px + var(--sar)); top: calc(12px + var(--sat));
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none !important;
}
.top > * { pointer-events: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px 0 11px; border-radius: 22px;
  background: var(--cream); box-shadow: var(--shadow), inset 0 -3px 0 rgba(139, 90, 43, .18); font-size: 17px;
}
.pill svg { width: 22px; height: 22px; color: #f2b32a; }
.pill.bump { animation: bump .5s ease; }
.icons { display: flex; gap: 8px; }
.icon {
  width: 44px; height: 44px; border-radius: 50%; background: var(--cream); color: var(--wood-dark);
  display: grid; place-items: center; box-shadow: var(--shadow), inset 0 -3px 0 rgba(139, 90, 43, .18);
  transition: transform .08s ease, opacity .15s ease;
}
.icon svg { width: 24px; height: 24px; }
.icon:active, .pill:active { transform: translateY(2px) scale(.96); }
.icon:disabled { opacity: .45; }
#btn-night .moon { display: none; }
#btn-night.night { background: #26345e; color: #ffe08a; }
#btn-night.night .sun { display: none; }
#btn-night.night .moon { display: block; }
#btn-sound .mute { display: none; }
#btn-sound.off .waves { display: none; }
#btn-sound.off .mute { display: block; }

.bubble {
  position: absolute; left: calc(12px + var(--sal)); top: calc(64px + var(--sat)); max-width: min(78vw, 340px);
  padding: 7px 12px; border-radius: 14px; background: rgba(255, 246, 230, .9); font-size: 14px; line-height: 1.25;
  box-shadow: 0 3px 10px rgba(40, 25, 10, .14); pointer-events: none !important;
}
.bubble:empty { display: none; }

.panel {
  position: absolute; left: calc(12px + var(--sal)); top: calc(64px + var(--sat)); width: min(calc(100vw - 24px), 340px);
  padding: 14px 16px 10px; border-radius: 20px; background: var(--cream); box-shadow: var(--shadow);
  animation: drop .18s ease;
}
.panel h2 { margin: 0 0 8px; font-size: 18px; color: var(--wood-dark); }
.panel ol { list-style: none; margin: 0; padding: 0; }
.panel li { display: flex; align-items: flex-start; gap: 9px; padding: 5px 0; font-size: 15px; line-height: 1.25; }
.panel li::before {
  content: ""; flex: none; width: 20px; height: 20px; border-radius: 50%; margin-top: -1px;
  border: 2.5px solid rgba(139, 90, 43, .4); background: #fff;
}
.panel li.done { color: var(--leaf-dark); }
.panel li.done::before {
  border-color: var(--leaf); background: var(--leaf) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M4.5 10.5l3.5 3.5 7.5-8' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 15px no-repeat;
}
.tip { margin: 8px 0 0; font-size: 13px; font-weight: 600; color: rgba(59, 42, 26, .7); line-height: 1.3; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.link { font-size: 12.5px; font-weight: 700; color: rgba(59, 42, 26, .6); text-decoration: none; padding: 6px 2px; }

.bottom {
  position: absolute; left: 0; right: 0; bottom: calc(14px + var(--sab)); display: flex; flex-direction: column; align-items: center; gap: 10px;
  pointer-events: none !important;
}
.bottom > * { pointer-events: auto; }
.tools { display: flex; gap: 8px; padding: 7px; border-radius: 26px; background: var(--cream); box-shadow: var(--shadow); }
.tool {
  width: 84px; height: 66px; border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--wood-dark); font-size: 13.5px; transition: transform .08s ease, background .12s ease;
}
.tool svg { width: 28px; height: 28px; }
.tool:active { transform: scale(.94); }
.tool.on { background: var(--leaf); color: #fff; box-shadow: inset 0 -4px 0 var(--leaf-dark); }
#tool-remove.on { background: var(--danger); box-shadow: inset 0 -4px 0 var(--danger-dark); }
.swatches {
  display: flex; gap: 9px; padding: 7px 10px; border-radius: 24px; background: rgba(255, 246, 230, .92); box-shadow: 0 3px 10px rgba(40, 25, 10, .16);
  transition: opacity .15s ease, transform .15s ease;
}
.swatches.off { opacity: 0; transform: translateY(8px); pointer-events: none !important; }
.swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 4px solid var(--roof); background: var(--wall);
  transition: transform .1s ease; box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}
.swatch.on { transform: scale(1.22); box-shadow: 0 0 0 3px #fff, 0 2px 6px rgba(0, 0, 0, .35); }

/* ---- cards ---- */
.card {
  position: absolute; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%);
  width: min(calc(100vw - 28px), 400px); padding: 20px 20px 10px; border-radius: 26px; background: var(--cream);
  box-shadow: 0 12px 34px rgba(40, 25, 10, .3); text-align: center; animation: rise .35s cubic-bezier(.2, 1.3, .4, 1);
}
.card h1 { margin: 0 0 6px; font-size: 30px; line-height: 1.1; color: var(--wood-dark); letter-spacing: -.01em; }
.card p { margin: 0 0 14px; font-size: 15.5px; font-weight: 600; line-height: 1.35; }
.btn {
  display: block; width: 100%; min-height: 50px; padding: 0 16px; margin: 0 0 9px; border-radius: 16px; font-size: 17px;
  background: #f0e2c8; color: var(--wood-dark); box-shadow: inset 0 -4px 0 rgba(139, 90, 43, .22); transition: transform .08s ease;
}
.btn:active { transform: translateY(2px) scale(.985); }
.btn.primary { background: var(--leaf); color: #fff; box-shadow: inset 0 -5px 0 var(--leaf-dark); min-height: 56px; font-size: 19px; }
.btn.danger { background: var(--danger); color: #fff; box-shadow: inset 0 -4px 0 var(--danger-dark); }
.overlay { position: absolute; inset: 0; background: rgba(30, 20, 10, .35); display: grid; place-items: center; }
.card.small { position: static; transform: none; padding: 20px 18px 10px; width: min(calc(100vw - 40px), 340px); animation: drop .18s ease; }
.row { display: flex; gap: 10px; }

#toast {
  position: absolute; left: 50%; top: calc(118px + var(--sat)); transform: translate(-50%, -8px); width: max-content; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: 18px; background: var(--ink); color: #fff; font-size: 15.5px; line-height: 1.25; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; box-shadow: var(--shadow);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.good { background: var(--leaf); }
#toast.big { font-size: 22px; padding: 14px 22px; background: #f2b32a; color: var(--ink); }
#toast small { display: block; font-size: 14px; font-weight: 600; margin-top: 2px; }

@keyframes rise { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes bump { 30% { transform: scale(1.18); } 60% { transform: scale(.96); } }

@media (min-width: 760px) {
  .tool { width: 96px; height: 70px; font-size: 14.5px; }
  .card h1 { font-size: 34px; }
  .bubble { font-size: 15px; }
}
@media (max-height: 460px) {
  .card { padding-top: 14px; }
  .card p { display: none; }
  .tool { height: 54px; }
  .tool svg { width: 22px; height: 22px; }
}
