* { box-sizing: border-box; }

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

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

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

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

#infoBox {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  padding: 10px 16px 12px;
  border-radius: 16px;
  background: rgba(70, 40, 20, 0.72);
  backdrop-filter: blur(4px);
}

#timer {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.05;
  color: #ffd94a;
  font-variant-numeric: tabular-nums;
}

#timer.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; }
#counts { margin-top: 6px; font-size: 16px; }
#counts b { font-size: 20px; color: #ffd94a; }

#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(70, 40, 20, 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: #5a3210; }

#hint {
  position: absolute;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 8px));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 40px);
  padding: 9px 20px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  text-align: center;
  border-radius: 999px;
  background: rgba(70, 40, 20, 0.8);
  backdrop-filter: blur(4px);
}

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

/* ---------- cards: start, the end of a morning, 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(255, 190, 70, 0.92), rgba(150, 80, 20, 0.96));
  backdrop-filter: blur(3px);
}

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

.card h1 {
  margin: 0;
  font-size: 64px;
  letter-spacing: 4px;
  line-height: 1.05;
  color: #fff6c8;
  text-shadow: 0 5px 0 #8a4a0a;
}

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

.gold { color: #fff27a; }

.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;
}

.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: #6a3a00;
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 15px 32px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #c99a10;
  touch-action: manipulation;
}

button.big.plain { background: #fff; color: #7a3a10; box-shadow: 0 6px 0 #d8b9a0; }

#shop { background: rgba(60, 30, 10, 0.6); 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: #fff8e4;
  color: #3a2a10;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

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

#shop h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  letter-spacing: 3px;
  text-align: left;
  color: #8a6a3a;
}

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

.shopMoney { margin: 6px 0 4px; 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 #f0e2bc;
  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.use { background: #3a7bd5; box-shadow: 0 4px 0 #24528f; }
.item button:disabled { background: #c9c2b0; box-shadow: 0 4px 0 #a8a090; cursor: default; }

@media (max-width: 700px) {
  .card h1 { font-size: 40px; }
  #timer { font-size: 28px; }
  #infoBox { padding: 8px 12px; }
  #hint { font-size: 14px; }
}
