* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #05060d;
  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; }

#seen, #fade {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
}

#seen { z-index: 5; box-shadow: inset 0 0 160px 60px #e0241c; }
#fade { z-index: 6; background: #000; transition: opacity 0.25s; }

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

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

.label {
  font-size: 12px;
  letter-spacing: 2.5px;
  font-weight: 700;
}

/* 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: 8px 16px 10px;
  border-radius: 16px;
  text-align: center;
  background: rgba(14, 18, 44, 0.72);
  backdrop-filter: blur(4px);
}

#clock {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.1;
  color: #ffe58a;
  font-variant-numeric: tabular-nums;
}

#clock.low { color: #ff8a80; animation: low 0.5s infinite alternate; }

@keyframes low {
  to { transform: scale(1.08); }
}

#infoBox .small { font-size: 10px; letter-spacing: 1.5px; opacity: 0.85; }

/* Mom, Dad and the sibling: how close each one is to waking up */
#family { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

.who { width: 74px; font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.who .face { font-size: 20px; line-height: 1.2; }
.who .bar { height: 6px; margin-top: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.22); overflow: hidden; }
.who .bar i { display: block; height: 100%; width: 0; background: #8fd0ff; }
.who.stir .bar i { background: #ffc94a; }
.who.awake { color: #ff8a80; }
.who.awake .bar i { background: #ff5a4a; }

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

#soundBtn {
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  touch-action: manipulation;
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(14, 18, 44, 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: #1c2350; }

#hint, #feet {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 340px);
  text-align: center;
  border-radius: 999px;
  backdrop-filter: blur(4px);
}

#hint {
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  padding: 9px 20px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1px;
  background: rgba(14, 18, 44, 0.8);
}

#hint:empty, #feet:empty { display: none; }
#hint.alert { background: #d0302a; }

/* tiptoeing or running, right above the hint */
#feet {
  bottom: max(66px, calc(env(safe-area-inset-bottom) + 56px));
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  background: rgba(14, 18, 44, 0.6);
}

#feet.loud { background: #c8641a; }

/* ---------- sticks and the hide button ---------- */

.stick {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 16px));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}

#walkStick { left: max(26px, calc(env(safe-area-inset-left) + 16px)); }
#lookStick { right: max(26px, calc(env(safe-area-inset-right) + 16px)); }

.stick .knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  pointer-events: none;
}

.stick span {
  position: absolute;
  top: -22px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  opacity: 0.7;
  pointer-events: none;
}

#actBtn {
  position: absolute;
  right: max(34px, calc(env(safe-area-inset-right) + 24px));
  top: 50%;
  transform: translateY(-50%);
  width: 116px;
  height: 116px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #ffd94a;
  color: #4a3200;
  font: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.5px;
  line-height: 1.2;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.35);
}

#actBtn:disabled {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
  color: rgba(255, 255, 255, 0.5);
  box-shadow: none;
  cursor: default;
}

#actBtn.held { transform: translateY(-50%) scale(0.94); }

/* ---------- cards: start, the end of a night, the shop ---------- */

.card {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  overflow-y: auto;
  background: radial-gradient(circle at 50% 40%, rgba(50, 64, 150, 0.9), rgba(8, 10, 30, 0.96));
  backdrop-filter: blur(3px);
}

.card.hidden, .hidden { display: none !important; }

.card h1 {
  margin: 0;
  font-size: 60px;
  letter-spacing: 4px;
  line-height: 1.05;
  color: #ffe58a;
  text-shadow: 0 5px 0 #1a1f55;
}

.card .tag {
  margin: 12px 0 22px;
  font-size: 20px;
  letter-spacing: 1px;
}

.gold { color: #ffe58a; }

.card .keys {
  list-style: none;
  margin: 0 0 18px;
  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.65;
  opacity: 0.95;
  margin: 0 0 26px;
}

.card .note:empty { display: none; }

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
}

button.big {
  cursor: pointer;
  border: none;
  background: #ffd94a;
  color: #4a3200;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 15px 32px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #b98a10;
  touch-action: manipulation;
}

button.big.plain { background: #fff; color: #1c2350; box-shadow: 0 6px 0 #9aa3d0; }
button.big:disabled { opacity: 0.55; cursor: default; padding: 8px 32px; }
button.big small { display: block; font-size: 10px; letter-spacing: 2px; }

#shop { background: rgba(5, 6, 20, 0.7); z-index: 30; }

#shop .panel {
  position: relative;
  width: min(100%, 480px);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px 20px 20px;
  border-radius: 22px;
  background: #f1f3ff;
  color: #1c2350;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

#shop h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 5px;
  color: #3a48b0;
}

#closeBtn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: #d8dcf5;
  color: #1c2350;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.shopMoney { margin: 6px 0 14px; font-size: 16px; }
.shopMoney b { font-size: 20px; color: #2a8a2a; }

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid #d8dcf5;
  text-align: left;
}

.item.using { border-color: #3cb043; }
.item .icon { font-size: 30px; width: 38px; text-align: center; }
.item .about { flex: 1; }
.item .name { font-weight: 800; letter-spacing: 1px; font-size: 16px; }
.item .what { font-size: 12px; line-height: 1.4; opacity: 0.8; }

.item button {
  border: none;
  border-radius: 999px;
  padding: 10px 14px;
  min-width: 92px;
  background: #3cb043;
  color: #fff;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 4px 0 #237a29;
  cursor: pointer;
  touch-action: manipulation;
}

.item button:disabled { background: #b9bdd0; box-shadow: 0 4px 0 #9094a8; cursor: default; }

@media (max-width: 700px), (max-height: 520px) {
  .card h1 { font-size: 38px; }
  .card .tag { font-size: 16px; margin: 8px 0 12px; }
  .card .keys { font-size: 12px; line-height: 1.9; margin-bottom: 10px; }
  .card .note { font-size: 12px; margin-bottom: 14px; }
  button.big { font-size: 15px; padding: 12px 22px; }
  #clock { font-size: 22px; }
  #infoBox { padding: 6px 10px 8px; }
  #infoBox .small { display: none; }
  .who { width: 58px; font-size: 9px; }
  .who .face { font-size: 16px; }
  #hint { font-size: 13px; max-width: calc(100% - 300px); }
  .stick { width: 112px; height: 112px; }
  #actBtn { width: 92px; height: 92px; font-size: 13px; }
}
