* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #2a1a22;
  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: default; }
canvas.point { cursor: pointer; }

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

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

.label {
  font-size: 12px;
  letter-spacing: 2.5px;
  opacity: 0.85;
}

#scoreBox {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  width: 190px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
}

#score {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.05;
  color: #ffc94a;
}

/* the tallest the flames got this game */
#biggest {
  margin-top: 4px;
  font-size: 13px;
  letter-spacing: 1.5px;
}

#biggest b { font-size: 18px; color: #ff9a4a; letter-spacing: 1px; }
#biggest.bump b { display: inline-block; animation: bump 0.45s; }

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

#finalBiggest {
  margin: -8px 0 18px;
  font-size: 16px;
  letter-spacing: 1.5px;
  opacity: 0.9;
}

#finalBiggest b { color: #ff9a4a; }

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

.meter { margin-top: 10px; }

.bar {
  position: relative;
  height: 14px;
  margin-top: 3px;
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.35);
}

.bar .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: linear-gradient(90deg, #ffd34a, #ff7a1f);
}

/* the top of the fireplace: past this line, sparks fly out */
#fireBar .line {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 3px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 5px rgba(0, 0, 0, 0.7);
}

#fireBar.over .fill { background: linear-gradient(90deg, #ffd34a, #ff7a1f 60%, #ff2a1a); }
#fireBar.over { animation: throb 0.5s infinite alternate; }

/* the warning: the fire is still under the line but growing past it. A
   ghost of the fill shows where it's heading. */
#fireBar .aim {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: repeating-linear-gradient(135deg, rgba(255, 170, 40, 0.55) 0 6px, rgba(255, 170, 40, 0.2) 6px 12px);
  display: none;
}
#fireBar.warn .aim { display: block; }
#fireBar.warn { animation: warn 0.35s infinite alternate; }

@keyframes warn {
  to { border-color: #ffb020; box-shadow: 0 0 10px rgba(255, 170, 30, 0.8); }
}

#houseMeter { visibility: hidden; }
#houseMeter.on { visibility: visible; }
#houseBar .fill { background: linear-gradient(90deg, #ff8a1f, #e0201a); }
#houseMeter.on .label { color: #ff8a6a; opacity: 1; font-weight: 700; }

@keyframes throb {
  to { border-color: #ff5a3a; }
}

#soundBtn {
  position: absolute;
  top: max(18px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  pointer-events: auto;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.7);
  background: rgba(40, 15, 10, 0.45);
  color: #fff;
  font: inherit;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 8px 12px;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  touch-action: manipulation;
}

@media (hover: hover) {
  #soundBtn:hover { border-color: #fff; }
}
#soundBtn[aria-pressed="true"] { background: rgba(255, 255, 255, 0.9); color: #4a1a0a; }

#message {
  position: absolute;
  top: 26%;
  left: 50%;
  transform: translateX(-50%);
  width: min(90vw, 720px);
  text-align: center;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.25s;
}

#message.on { opacity: 1; }

#msgBig {
  font-size: 44px;
  font-weight: 700;
}

#msgSmall {
  margin-top: 4px;
  font-size: 18px;
}

#hint {
  position: absolute;
  bottom: max(26px, calc(env(safe-area-inset-bottom) + 8px));
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 340px);
  padding: 7px 16px;
  font-size: 14px;
  letter-spacing: 1.2px;
  text-align: center;
  border-radius: 999px;
  background: rgba(30, 10, 5, 0.6);
  backdrop-filter: blur(4px);
}

#hint:empty { display: none; }
#hint.alarm { background: rgba(190, 30, 20, 0.85); font-weight: 700; }
#hint.warn { background: rgba(215, 120, 10, 0.9); font-weight: 700; }

@media (max-width: 700px) {
  #hint { max-width: calc(100% - 40px); bottom: max(60px, calc(env(safe-area-inset-bottom) + 50px)); }
}

/* ---------- start and game-over cards ---------- */

.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% 70%, rgba(230, 100, 30, 0.82), rgba(40, 10, 5, 0.95));
  backdrop-filter: blur(3px);
}

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

#over {
  background: radial-gradient(circle at 50% 40%, rgba(60, 50, 50, 0.6), rgba(10, 8, 8, 0.85));
  backdrop-filter: none;
}

.card h1 {
  margin: 0;
  font-size: 58px;
  letter-spacing: 3px;
  line-height: 1.05;
}

.card .tag {
  margin: 8px 0 22px;
  font-size: 18px;
  letter-spacing: 1px;
  opacity: 0.92;
}

#survivor b { color: #ffd34a; }

.card .keys {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  font-size: 15px;
  line-height: 2;
}

.card .keys b {
  display: inline-block;
  padding: 1px 8px;
  margin-right: 6px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 5px;
  font-size: 12px;
  letter-spacing: 1px;
}

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

.card .note .hot { color: #ffb08a; }

button.big {
  cursor: pointer;
  border: none;
  background: #ffc94a;
  color: #5a1e08;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 3px;
  padding: 15px 34px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(255, 180, 60, 0.35);
  touch-action: manipulation;
}

@media (hover: hover) {
  button.big:hover { background: #ffdb7a; }
}

#finalScore {
  font-size: 22px;
  letter-spacing: 1.5px;
  margin-bottom: 18px;
}

#finalScore b { font-size: 40px; color: #ffc94a; display: block; }

#nameRow {
  margin-bottom: 18px;
  font-size: 15px;
}

#nameRow > div { margin-top: 8px; display: flex; gap: 8px; justify-content: center; }

#nameInput {
  font: inherit;
  font-size: 18px;
  width: 210px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 2px solid #ffc94a;
  background: rgba(255, 255, 255, 0.95);
  color: #3a1206;
  user-select: text;
  -webkit-user-select: text;
}

#nameBtn {
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  background: #ffc94a;
  color: #5a1e08;
  touch-action: manipulation;
}

#leaders {
  list-style: none;
  counter-reset: place;
  margin: 8px 0 24px;
  padding: 0;
  min-width: 280px;
  font-size: 17px;
}

#leaders li {
  counter-increment: place;
  display: flex;
  gap: 12px;
  padding: 5px 14px;
  border-radius: 10px;
}

#leaders li::before { content: counter(place) "."; width: 22px; text-align: right; opacity: 0.7; }
#leaders li .who { flex: 1; text-align: left; }
#leaders li .pts { font-weight: 700; color: #ffc94a; }
#leaders li.you { background: rgba(255, 201, 74, 0.2); }
#leaders li.empty { opacity: 0.55; justify-content: center; }
#leaders li.empty::before { content: none; }

/* ---------- 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; }
body.touch #soundBtn { min-height: 44px; padding: 8px 16px; }

@media (max-width: 820px) {
  .card h1 { font-size: 40px; }
}
