* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #0b0d1c;
  font-family: "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* the canvas takes every finger itself: no scrolling, no zooming */
canvas { display: block; touch-action: none; }

/* ---------- HUD ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

/* top middle: the arcade's back button takes the top left corner */
#infoBox {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 18px 9px;
  border-radius: 16px;
  text-align: center;
  background: rgba(20, 12, 34, 0.75);
  backdrop-filter: blur(4px);
}

#candy {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.15;
  color: #ffb43a;
  font-variant-numeric: tabular-nums;
}
#candy.bump { animation: bump 0.25s; }
@keyframes bump {
  50% { transform: scale(1.18); }
}

#clock {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
#clock.low { color: #ff8a80; animation: low 0.5s infinite alternate; }
@keyframes low {
  to { transform: scale(1.1); }
}
#infoBox .small { font-size: 10px; letter-spacing: 1.5px; opacity: 0.8; }

#topRight {
  position: fixed;
  z-index: 30;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
}

#soundBtn {
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  touch-action: manipulation;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(20, 12, 34, 0.6);
  color: #fff;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  min-height: 44px;
  backdrop-filter: blur(4px);
}
#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.92); color: #3a1a50; }

#hint {
  position: absolute;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 9px 20px;
  text-align: center;
  border-radius: 999px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: rgba(20, 12, 34, 0.82);
  backdrop-filter: blur(4px);
}
#hint:empty { display: none; }
#hint.scary { background: #3f7a2a; }

/* ---------- BOO! ---------- */

#boo {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle, rgba(60, 120, 40, 0.55), rgba(0, 0, 0, 0.85));
  animation: booIn 0.18s ease-out;
}
#booFace { font-size: min(46vw, 46vh); line-height: 1; animation: shake 0.08s infinite alternate; }
#booWord {
  font-size: min(20vw, 18vh);
  font-weight: 900;
  letter-spacing: 6px;
  color: #b6ff6a;
  text-shadow: 0 6px 0 #1a3a10;
}
@keyframes booIn {
  from { transform: scale(2.2); opacity: 0; }
}
@keyframes shake {
  from { transform: translate(-6px, 3px) rotate(-3deg); }
  to { transform: translate(6px, -3px) rotate(3deg); }
}

/* ---------- cards: start and the end of the night ---------- */

.card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  text-align: center;
  padding: 70px 20px 28px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 30%, rgba(110, 50, 140, 0.88), rgba(14, 8, 24, 0.97));
  backdrop-filter: blur(3px);
}
.card.hidden, .hidden { display: none !important; }
.card h1 {
  margin: 0;
  font-size: clamp(42px, 11vw, 64px);
  letter-spacing: 4px;
  line-height: 1.05;
  color: #ffb43a;
  text-shadow: 0 5px 0 #4a1a10;
}
.card .tag {
  margin: 12px 0 18px;
  font-size: 20px;
  letter-spacing: 0.5px;
}
.gold { color: #ffd36a; }
.pick { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: 3px; opacity: 0.8; }

#costumes {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 18px;
}
.costume {
  width: 92px;
  padding: 6px 4px 8px;
  border-radius: 16px;
  border: 3px solid transparent;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
}
.costume canvas { display: block; margin: 0 auto 2px; width: 64px; height: 72px; }
.costume.on { border-color: #ffb43a; background: rgba(255, 180, 58, 0.22); }
.costume:disabled { cursor: default; opacity: 0.55; }
.costume small { display: block; font-size: 10px; letter-spacing: 0.5px; font-weight: 600; opacity: 0.9; }

.card .keys {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 15px;
  line-height: 2.1;
}
.card .keys b {
  display: inline-block;
  padding: 1px 8px;
  margin: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 1px;
}
/* show the keys that match what you're holding */
.forTouch { display: none; }
@media (hover: none) {
  .forTouch { display: block; }
  .forKeys { display: none; }
}
.card .note {
  max-width: 480px;
  font-size: 15px;
  line-height: 1.6;
  opacity: 0.95;
  margin: 0 0 22px;
}
.card .note:empty { display: none; }
#pile {
  max-width: 460px;
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 1.25;
  word-break: break-all;
}
.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-bottom: 18px;
}
button.big {
  cursor: pointer;
  border: none;
  background: #ff9a1f;
  color: #3a1400;
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 15px 30px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #a8520a;
  touch-action: manipulation;
}
button.big.plain { background: #fff; color: #3a1a50; box-shadow: 0 6px 0 #a99abf; }
button.big:active { transform: translateY(3px); box-shadow: 0 3px 0 #a8520a; }
