/* ============================================================
   Ember Night — UI styling
   Dark translucent glass panels, warm ember accents, thin type.
   ============================================================ */

:root {
  --ember: #ff9a3c;
  --ember-hot: #ffd08a;
  --ember-deep: #e2561f;
  --moss: #7ee08a;
  --blood: #ff5a4a;
  --moon: #cfe0ff;
  --panel: rgba(9, 12, 17, 0.56);
  --panel-solid: rgba(9, 12, 17, 0.86);
  --stroke: rgba(255, 255, 255, 0.13);
  --text: #f2f0ea;
  --text-dim: rgba(242, 240, 234, 0.62);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #04070c;
  color: var(--text);
  font-family: var(--font);
  user-select: none;
  /* Mobile: no page pan, no pinch-zoom, no pull-to-refresh mid-drag. */
  overscroll-behavior: none;
  touch-action: none;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------- overlays */
#vignette,
#danger-zone,
#damage,
#flash,
#grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#vignette {
  background: radial-gradient(ellipse at 50% 55%, rgba(0, 0, 0, 0) 34%, rgba(0, 0, 0, 0.55) 78%, rgba(0, 0, 0, 0.88) 100%);
  opacity: 0.85;
  transition: opacity 0.4s linear;
}

#danger-zone {
  background: radial-gradient(ellipse at 50% 50%, rgba(60, 0, 0, 0) 28%, rgba(120, 8, 8, 0.55) 82%, rgba(80, 0, 0, 0.85) 100%);
  opacity: 0;
  mix-blend-mode: multiply;
}

#damage {
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 40, 20, 0) 30%, rgba(255, 40, 20, 0.45) 80%, rgba(150, 10, 0, 0.6) 100%);
  opacity: 0;
}

#flash {
  background: #ffd9a8;
  opacity: 0;
}

#grain {
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  animation: grainShift 1.1s steps(3) infinite;
  mix-blend-mode: overlay;
}
@keyframes grainShift {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-2%, 1%); }
  66% { transform: translate(1%, -2%); }
  100% { transform: translate(0, 0); }
}

/* --------------------------------------------------------------- HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  backdrop-filter: blur(9px) saturate(1.1);
  -webkit-backdrop-filter: blur(9px) saturate(1.1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* --- challenges */
#challenges {
  position: absolute;
  top: 18px;
  left: 18px;
  width: min(360px, 42vw);
  padding: 10px 12px 12px;
}

.panel-title {
  font-size: 11px;
  letter-spacing: 0.16em;
  font-weight: 700;
  color: var(--text);
  opacity: 0.92;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.panel-title .dim {
  color: var(--text-dim);
  font-weight: 600;
}

.chal {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 9px;
  transition: background 0.25s ease, transform 0.25s ease;
}
.chal + .chal {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.chal.done {
  background: rgba(255, 154, 60, 0.14);
  animation: chalPop 0.6s ease;
}
.chal.fresh {
  animation: chalIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes chalPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}
@keyframes chalIn {
  0% { opacity: 0; transform: translateX(-14px); }
  100% { opacity: 1; transform: none; }
}

.chal-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ember-hot);
}
.chal-icon svg {
  width: 22px;
  height: 22px;
}
.chal-body {
  flex: 1;
  min-width: 0;
}
.chal-label {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chal-bar {
  height: 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.chal-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #ffb45c, #7ee08a);
  box-shadow: 0 0 12px rgba(255, 180, 92, 0.5);
  transition: width 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.chal-count {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  min-width: 44px;
  text-align: right;
  opacity: 0.9;
}

/* --- top right: night, score, combo */
#topright {
  position: absolute;
  top: 18px;
  right: 18px;
  width: min(300px, 40vw);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

#night-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  width: 100%;
}
#night-badge .moon {
  width: 22px;
  height: 22px;
  color: var(--moon);
  filter: drop-shadow(0 0 8px rgba(180, 210, 255, 0.6));
}
.night-text {
  line-height: 1.15;
}
#night-label {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.14em;
}
#night-sub {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

#night-track {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.09);
  border-radius: 3px;
  overflow: hidden;
}
#night-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(207, 224, 255, 0.5), var(--moon));
  box-shadow: 0 0 10px rgba(180, 210, 255, 0.7);
}

#score-panel {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 12px 6px;
  font-variant-numeric: tabular-nums;
}
.score-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  font-weight: 700;
}
#score {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(255, 170, 90, 0.4);
}
#score-delta {
  font-size: 13px;
  font-weight: 700;
  color: var(--ember-hot);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#score-delta.show {
  opacity: 1;
}

#combo-panel {
  padding: 3px 12px 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 122, 60, 0.25), rgba(255, 200, 120, 0.12));
  border: 1px solid rgba(255, 170, 90, 0.5);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--ember-hot);
  animation: comboPulse 0.45s ease;
}
@keyframes comboPulse {
  0% { transform: scale(0.7); opacity: 0.2; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* --- bars */
#bars {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(330px, 44vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bar-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(8px);
}
.bar-icon svg {
  width: 19px;
  height: 19px;
}
#bars .bar-row:nth-child(1) .bar-icon {
  color: var(--ember);
  box-shadow: 0 0 18px rgba(255, 140, 60, 0.3);
}
#bars .bar-row:nth-child(2) .bar-icon {
  color: #ff6b6b;
  box-shadow: 0 0 18px rgba(255, 90, 90, 0.25);
}
.bar {
  position: relative;
  flex: 1;
  height: 30px;
  border-radius: 9px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  overflow: hidden;
  backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.bar-fill {
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 0%;
  border-radius: 6px;
  transition: width 0.14s linear, background 0.5s ease;
}
#fire-fill {
  background: linear-gradient(90deg, #ff6a1f, #ffc061);
  box-shadow: 0 0 18px rgba(255, 120, 40, 0.55);
}
#comfort-fill {
  background: linear-gradient(90deg, #3fbf6a, #9ff0a8);
  box-shadow: 0 0 18px rgba(90, 220, 120, 0.4);
}
#comfort-fill.low {
  background: linear-gradient(90deg, #d63a2a, #ff8a6a);
  box-shadow: 0 0 18px rgba(220, 60, 40, 0.55);
}
.bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}
.bar-label > span:last-child {
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.72);
  text-transform: lowercase;
  font-size: 10.5px;
}
.bar.critical {
  animation: barCritical 0.9s infinite;
}
@keyframes barCritical {
  0%, 100% { border-color: var(--stroke); }
  50% { border-color: rgba(255, 90, 60, 0.85); box-shadow: 0 0 18px rgba(255, 70, 40, 0.35); }
}

/* --- hints */
#hints {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  opacity: 0.92;
  transition: opacity 0.6s ease;
}
.hint {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hint.used {
  opacity: 0.28;
}
.hint.used span {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 255, 255, 0.3);
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.04em;
}

/* --- reticle */
#reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  transition: transform 0.08s ease-out;
}
.r-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
}
.r-bracket i {
  position: absolute;
  width: 11px;
  height: 11px;
  border: 2px solid var(--ember-hot);
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
}
.r-bracket i:nth-child(1) { left: 0; top: 0; border-right: none; border-bottom: none; border-radius: 3px 0 0 0; }
.r-bracket i:nth-child(2) { right: 0; top: 0; border-left: none; border-bottom: none; border-radius: 0 3px 0 0; }
.r-bracket i:nth-child(3) { left: 0; bottom: 0; border-right: none; border-top: none; border-radius: 0 0 0 3px; }
.r-bracket i:nth-child(4) { right: 0; bottom: 0; border-left: none; border-top: none; border-radius: 0 0 3px 0; }
.r-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  opacity: 0;
}

#reticle.target .r-bracket i {
  opacity: 1;
  transform: scale(1);
}
#reticle.target .r-ring {
  opacity: 0.5;
}
#reticle.danger .r-bracket i {
  opacity: 1;
  border-color: var(--blood);
  animation: reticleDanger 0.42s infinite;
}
#reticle.danger .r-ring {
  opacity: 0.75;
  border-color: rgba(255, 90, 74, 0.6);
}
#reticle.danger .r-dot {
  background: var(--blood);
}
@keyframes reticleDanger {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.28); }
}
#reticle.busy {
  opacity: 0.4;
}
#reticle.locked {
  transform: translate(-50%, -50%) scale(0.86);
}

#busy-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  opacity: 0;
  transition: opacity 0.15s ease;
}
#busy-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
#busy-ring circle {
  fill: none;
  stroke: var(--ember-hot);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 119.4;
  filter: drop-shadow(0 0 6px rgba(255, 190, 110, 0.8));
}

/* --- floating popups */
#popups {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9), 0 0 20px rgba(0, 0, 0, 0.6);
  will-change: transform, opacity;
  white-space: nowrap;
}
.popup.kill { color: #fff3d6; }
.popup.revenge { color: #ff6b5a; }
.popup.wood { color: #ffb45c; }
.popup.splat { color: #d8ffcf; font-size: 20px; }
.popup.chal { color: #b6ffb0; font-size: 19px; }
.popup.warn { color: #ff8a5c; font-size: 18px; letter-spacing: 0.16em; }

/* --- off-screen indicators */
#indicators {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.ind {
  position: absolute;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  display: grid;
  place-items: center;
  transition: opacity 0.2s ease;
}
.ind svg {
  width: 100%;
  height: 100%;
}
.ind.mosquito { color: rgba(255, 210, 180, 0.85); }
.ind.danger { color: var(--blood); }
.ind.fire { color: var(--ember); }
.ind.wood { color: #d8b483; }
.ind span {
  position: absolute;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.1em;
  bottom: -2px;
  color: rgba(255, 255, 255, 0.75);
}

/* --- toast / messages */
#toast {
  position: absolute;
  left: 50%;
  top: 15%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.toast-item {
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(9px);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text);
  animation: toastIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  white-space: nowrap;
}
.toast-item.warn {
  color: #ffd2a8;
  border-color: rgba(255, 140, 80, 0.55);
  background: rgba(48, 18, 8, 0.72);
}
.toast-item.good {
  color: #cfffd0;
  border-color: rgba(120, 220, 130, 0.45);
  background: rgba(10, 34, 18, 0.7);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
.toast-item.out {
  animation: toastOut 0.5s ease forwards;
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-14px); }
}

/* --- big centre card (night transitions, dawn) */
#center-card {
  position: absolute;
  left: 50%;
  top: 44%;
  transform: translate(-50%, -50%);
  text-align: center;
  opacity: 0;
  transition: opacity 0.5s ease;
}
#center-card.show {
  opacity: 1;
}
#center-card .cc-big {
  font-size: clamp(34px, 7vw, 76px);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-shadow: 0 0 50px rgba(255, 160, 70, 0.5), 0 4px 24px rgba(0, 0, 0, 0.9);
}
#center-card .cc-sub {
  margin-top: 8px;
  font-size: clamp(12px, 1.6vw, 16px);
  letter-spacing: 0.3em;
  color: var(--text-dim);
  text-transform: uppercase;
}

/* ----------------------------------------------------------- screens */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(4, 8, 14, 0.35) 0%, rgba(3, 6, 10, 0.82) 65%, rgba(2, 4, 7, 0.95) 100%);
  backdrop-filter: blur(2px);
  z-index: 20;
  transition: opacity 0.5s ease;
}
.screen.fade {
  opacity: 0;
  pointer-events: none;
}

.title-inner {
  text-align: center;
  max-width: 780px;
  padding: 32px;
  animation: screenIn 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.title-inner.small {
  max-width: 560px;
}
@keyframes screenIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.logo-ember {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff0c0, var(--ember) 45%, rgba(226, 86, 31, 0) 70%);
  box-shadow: 0 0 30px 8px rgba(255, 150, 60, 0.5);
  animation: emberPulse 2.6s ease-in-out infinite;
}
@keyframes emberPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.35); opacity: 1; }
}
.logo h1 {
  margin: 0;
  font-size: clamp(30px, 6.4vw, 62px);
  letter-spacing: 0.24em;
  font-weight: 800;
  background: linear-gradient(180deg, #fff3dd, #ffb45c 60%, #e2561f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 60px rgba(255, 150, 60, 0.25);
}
h2 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
  letter-spacing: 0.14em;
  font-weight: 800;
}
.tagline {
  margin: 12px 0 26px;
  color: var(--text-dim);
  font-size: clamp(13px, 1.7vw, 16px);
  letter-spacing: 0.06em;
}

.howto {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
  text-align: left;
}
.howto-col {
  display: flex;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--stroke);
}
.howto-col .ico {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  color: var(--ember);
  filter: drop-shadow(0 0 8px rgba(255, 150, 60, 0.5));
}
.howto-col strong {
  display: block;
  font-size: 13.5px;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
}
.howto-col span {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.5;
}

.btn {
  pointer-events: auto;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 13px 34px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.11);
}
.btn.primary {
  background: linear-gradient(180deg, #ffb45c, #e2561f);
  border-color: rgba(255, 200, 140, 0.55);
  color: #1b0d05;
  box-shadow: 0 8px 34px rgba(226, 86, 31, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover {
  box-shadow: 0 12px 40px rgba(255, 130, 50, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
}
.best {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.08em;
}
.footer-note {
  margin-top: 20px;
  font-size: 11.5px;
  color: rgba(242, 240, 234, 0.42);
  letter-spacing: 0.05em;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 22px 0 18px;
}
.stat {
  padding: 12px 8px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}
.stat b {
  display: block;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ember-hot);
}
.stat span {
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.rank {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 20px;
}
.rank strong {
  color: var(--ember-hot);
  font-size: 15px;
}

/* --- loading */
#loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #04070c;
  z-index: 40;
  transition: opacity 0.6s ease;
}
#loading.done {
  opacity: 0;
  pointer-events: none;
}
.load-inner {
  text-align: center;
}
.load-flame {
  width: 22px;
  height: 22px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff0c0, var(--ember) 45%, rgba(226, 86, 31, 0) 72%);
  box-shadow: 0 0 34px 10px rgba(255, 150, 60, 0.45);
  animation: emberPulse 1.8s ease-in-out infinite;
}
.load-text {
  font-size: 12px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* --- touch controls (coarse pointers only, while the HUD is up) */

/* The whole screen is the look/swat zone: drag = look, quick tap = swat. It
   replaces the canvas as the input surface for every pointer family, so mouse
   and touch share one code path. Transparent, always mounted; it sits under
   the .screen overlays (z-index 20) so it can never eat a menu tap. */
#look-zone {
  position: absolute;
  inset: 0;
  z-index: 5;
  touch-action: none;
  cursor: crosshair;
}

#touch-wood {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(108px + env(safe-area-inset-bottom));
  width: 104px;
  height: 104px;
  padding: 0;
  border-radius: 50%;
  display: none;
  place-items: center;
  background: rgba(255, 150, 60, 0.16);
  border: 1px solid rgba(255, 170, 90, 0.5);
  color: var(--ember-hot);
  font: 800 11px var(--font);
  letter-spacing: 0.08em;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 6;
  backdrop-filter: blur(8px);
}

/* ⏸ in the top-right; the 52px top clears the hub shell's docked bar on
   phones. Click-driven in game.js — a click cannot double-fire across event
   families. */
#btn-pause {
  position: absolute;
  top: calc(52px + env(safe-area-inset-top));
  right: calc(14px + env(safe-area-inset-right));
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: var(--panel);
  color: var(--text);
  font: 700 12px/1 var(--font);
  display: none;
  place-items: center;
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 6;
  backdrop-filter: blur(8px);
  cursor: pointer;
}

@media (pointer: coarse) {
  #app.touch-on #touch-wood,
  #app.touch-on #btn-pause {
    display: grid;
  }
}

/* the keyboard hints are meaningless on a phone — and not just narrow ones: a
   landscape phone is 844px wide, far past the old 720px hide */
body.touch #hints {
  display: none;
}
/* nudge the score column clear of the pause icon */
body.touch #topright {
  right: 64px;
}

/* first-run coach marks — what a thumb does; each fades on first use */
#coach {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
#coach-look,
#coach-swat,
#coach-wood {
  position: absolute;
  font: 800 13px var(--font);
  letter-spacing: 0.14em;
  color: var(--text);
  text-shadow: 0 1px 8px rgba(4, 7, 12, 0.9);
  white-space: nowrap;
  animation: coachPulse 1.6s ease-in-out infinite;
}
#coach-look {
  left: 8%;
  top: 42%;
}
#coach-swat {
  left: 50%;
  transform: translateX(-50%);
  top: 52%;
}
#coach-wood {
  right: max(18px, env(safe-area-inset-right));
  bottom: calc(220px + env(safe-area-inset-bottom));
  width: 104px;
  text-align: center;
}
#coach .used {
  opacity: 0;
  animation: none;
  transition: opacity 0.3s;
}
@keyframes coachPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

@media (max-width: 720px) {
  #challenges {
    width: min(300px, 62vw);
    top: 12px;
    left: 12px;
    padding: 8px 9px 9px;
  }
  .chal-icon { width: 26px; height: 26px; flex-basis: 26px; }
  .chal-icon svg { width: 17px; height: 17px; }
  .chal-label { font-size: 11px; }
  #topright { width: min(210px, 46vw); top: 12px; right: 12px; }
  #score { font-size: 20px; }
  #bars { width: min(240px, 56vw); right: 12px; bottom: 12px; }
  #hints { display: none; }
  .bar { height: 26px; }
  #night-sub { display: none; }
}

/* ------------------------------------------------ mobile pass
   Phones play in landscape. In portrait, a small non-blocking nudge — it never
   eats a touch, and it disappears the moment the device is turned. */
@media (orientation: portrait) and (hover: none) and (pointer: coarse) {
  #app::after {
    content: "↻  Best played in landscape";
    position: fixed;
    left: 50%;
    bottom: max(10px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 9999;
    padding: 0.42rem 0.9rem;
    border: 1px solid rgba(243, 237, 225, 0.18);
    border-radius: 999px;
    background: rgba(8, 10, 16, 0.82);
    color: #f3ede1;
    font: 600 0.72rem/1.2 system-ui, -apple-system, sans-serif;
    letter-spacing: 0.04em;
    white-space: nowrap;
    pointer-events: none;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
  }
}

/* Phone landscape leaves ~300px of height once the browser's own UI is showing
   — far less than the menu is tall. A launch button you cannot reach is a game
   you cannot start, so the menu scales to whatever height it is given, with
   scrolling as the backstop for anything extreme. */
@media (max-height: 520px) {
  .screen {
    padding: 8px;
    overflow-y: auto;
    align-content: center;
  }
  .screen > .title-inner {
    transform: scale(0.72);
  }
}
@media (max-height: 460px) { .screen > .title-inner { transform: scale(0.62); } }
@media (max-height: 400px) { .screen > .title-inner { transform: scale(0.54); } }
@media (max-height: 360px) { .screen > .title-inner { transform: scale(0.48); } }
@media (max-height: 320px) { .screen > .title-inner { transform: scale(0.42); } }
@media (max-height: 280px) { .screen > .title-inner { transform: scale(0.36); } }

/* ── promo capture: narrative captions (?cine=1) ──────────────────────────
   Fades on GAME time (hud.storyUpdate), so fixed-stepped video capture keeps
   each line on screen for its full scripted duration. */
#story-line {
  position: absolute;
  left: 50%;
  top: 66%;
  transform: translateX(-50%);
  width: min(82vw, 760px);
  text-align: center;
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-size: clamp(19px, 3.2vw, 28px);
  line-height: 1.45;
  color: #ffdca8;
  background: rgba(5, 7, 10, 0.48);
  padding: 10px 28px;
  border-radius: 8px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.95), 0 0 22px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
  z-index: 30;
}
#story-line.on { opacity: 1; }
