* { box-sizing: border-box; }

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

#moneyBox {
  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(20, 50, 90, 0.55);
  backdrop-filter: blur(4px);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

#money {
  font-size: 38px;
  font-weight: 700;
  line-height: 1.05;
  color: #ffd94a;
}

#money.neg { color: #ff8a80; }
#money.bump { animation: bump 0.45s; }

@keyframes bump {
  40% { transform: scale(1.25); }
}

#luck {
  margin-top: 4px;
  font-size: 13px;
  letter-spacing: 1.5px;
}

#luck b { font-size: 17px; color: #8dff8a; }

#best {
  margin-top: 2px;
  font-size: 11px;
  letter-spacing: 1.5px;
  opacity: 0.85;
}

#topRight {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  gap: 10px;
  align-items: center;
}

#topRight button {
  pointer-events: auto;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  touch-action: manipulation;
}

#soundBtn {
  border: 2px solid rgba(255, 255, 255, 0.8);
  background: rgba(20, 50, 90, 0.45);
  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: #1a3a6a; }

#shopBtn {
  border: none;
  background: #ffd94a;
  color: #6a3a00;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 12px 26px;
  box-shadow: 0 6px 0 #c99a10, 0 10px 20px rgba(0, 0, 0, 0.25);
}

/* there's money for an upgrade: the shop button says so */
#shopBtn.ready { animation: ready 0.8s infinite alternate; }

@keyframes ready {
  to { background: #fff27a; box-shadow: 0 6px 0 #c99a10, 0 0 24px rgba(255, 240, 90, 0.95); }
}

@media (hover: hover) {
  #soundBtn:hover { border-color: #fff; }
  #shopBtn:hover { background: #ffe57a; }
}

#message {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 720px);
  text-align: center;
  text-shadow: 0 4px 0 #b06a00, 0 6px 20px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.25s;
}

#message.on { opacity: 1; animation: pop 0.5s; }

@keyframes pop {
  0% { transform: translateX(-50%) scale(0.4); }
  60% { transform: translateX(-50%) scale(1.15); }
}

#msgBig {
  font-size: 72px;
  font-weight: 800;
  color: #ffe14a;
  letter-spacing: 2px;
}

#msgSmall {
  margin-top: 2px;
  font-size: 30px;
  font-weight: 700;
}

#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: 7px 16px;
  font-size: 14px;
  letter-spacing: 1.2px;
  text-align: center;
  border-radius: 999px;
  background: rgba(20, 50, 90, 0.6);
  backdrop-filter: blur(4px);
}

#hint:empty { display: none; }

/* ---------- cards: start and 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(70, 150, 230, 0.85), rgba(15, 40, 90, 0.95));
  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: #ffd94a;
  text-shadow: 0 5px 0 #b06a00;
}

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

.gold { color: #ffd94a; }

.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-right: 6px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 1px;
}

.card .keys b.bad { color: #ffb0a8; }

.card .note {
  max-width: 480px;
  font-size: 14px;
  line-height: 1.65;
  opacity: 0.92;
  margin: 0 0 26px;
}

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

#shop { background: rgba(10, 30, 60, 0.6); }

#shop .panel {
  position: relative;
  width: min(100%, 460px);
  padding: 26px 24px 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;
}

#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 18px; font-size: 16px; }
.shopMoney b { font-size: 20px; color: #2a8a2a; }
.shopMoney b.neg { color: #d0302a; }

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 16px;
  background: #fff;
  border: 2px solid #f0e2bc;
  text-align: left;
}

.item .icon { font-size: 40px; }
.item .about { flex: 1; }
.item .name { font-weight: 800; letter-spacing: 2px; font-size: 18px; }
.item .name span { color: #2a8a2a; font-size: 15px; margin-left: 4px; }
.item .what { font-size: 13px; line-height: 1.4; margin-top: 2px; opacity: 0.8; }

#buyBtn {
  border: none;
  border-radius: 999px;
  padding: 12px 16px;
  min-width: 108px;
  background: #3cb043;
  color: #fff;
  font: inherit;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 16px;
  box-shadow: 0 4px 0 #237a29;
  cursor: pointer;
  touch-action: manipulation;
}

#buyBtn:disabled { background: #c9c2b0; box-shadow: 0 4px 0 #a8a090; cursor: default; }
#buyBtn.bought { animation: bump 0.4s; }

#buyNote { min-height: 22px; margin-top: 12px; font-size: 14px; color: #8a6a3a; }

#resetBtn {
  margin-top: 10px;
  border: none;
  background: none;
  color: #a08a6a;
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- touch screens ---------- */
/* body.touch is set by game.js when there's a finger instead of a mouse */

body:not(.touch) .tch, body.touch .desk { display: none !important; }

/* a phone: SHOP stays top right and SOUND goes under it */
@media (max-width: 520px) {
  #topRight { flex-direction: column-reverse; align-items: flex-end; gap: 8px; }
}

@media (max-width: 700px) {
  .card h1 { font-size: 44px; }
  #msgBig { font-size: 52px; }
  #msgSmall { font-size: 22px; }
  #money { font-size: 28px; }
  #moneyBox { padding: 8px 12px; }
  #shopBtn { font-size: 16px; padding: 10px 18px; }
  #soundBtn { font-size: 10px; padding: 6px 10px; }
}
