:root {
  --ink: #e9efdf;
  --ink-dim: rgba(233, 239, 223, 0.55);
  --hammer: #e07b2f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #38472f;
  font-family: 'JetBrains Mono', monospace;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#canvas {
  display: block;
  position: fixed;
  inset: 0;
  cursor: crosshair;
}

/* ---- HUD (top-left) ---- */
#hud {
  position: fixed;
  top: 18px;
  left: 18px;
  display: flex;
  gap: 26px;
  z-index: 5;
  pointer-events: none;
}
#hud > div {
  display: flex;
  flex-direction: column;
  line-height: 1;
}
#hud .label {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--ink-dim);
  margin-bottom: 6px;
}
#height-value, #best-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
#best-value { color: var(--hammer); }
.unit {
  font-size: 14px;
  font-weight: 400;
  opacity: 0.7;
  margin-left: 2px;
}

/* ---- title flourish (top-right) ---- */
#title-flourish {
  position: fixed;
  top: 16px;
  right: 22px;
  text-align: right;
  z-index: 5;
  pointer-events: none;
}
#title-flourish .big {
  display: block;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 32px;
  font-weight: 500;
  color: var(--ink);
  text-shadow: 0 2px 8px rgba(0,0,0,0.55);
  line-height: 1;
}
#title-flourish .small {
  display: block;
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 4px;
}

/* ---- instructions card ---- */
#instructions {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 26, 16, 0.55);
  backdrop-filter: blur(3px);
  transition: opacity 0.5s ease;
}
#instructions.hidden {
  opacity: 0;
  pointer-events: none;
}
#instructions .card {
  background: rgba(28, 34, 22, 0.92);
  border: 1px solid rgba(224, 123, 47, 0.4);
  border-radius: 16px;
  padding: 34px 38px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: rise 0.6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
#instructions h1 {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-weight: 500;
  font-size: 38px;
  color: var(--ink);
  margin-bottom: 18px;
}
#instructions p {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 12px;
}
#instructions p.muted {
  color: var(--ink-dim);
  font-style: italic;
  font-family: 'Newsreader', serif;
  font-size: 15px;
}
#start-btn {
  margin-top: 16px;
  padding: 12px 26px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 1px;
  color: #1a1a14;
  background: var(--hammer);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 20px rgba(224, 123, 47, 0.4);
}
#start-btn:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(224,123,47,0.5); }
#start-btn:active { transform: translateY(0); }

/* ---- controls (reset button, bottom-left) ---- */
#controls {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 5;
}
#reset-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--ink-dim);
  background: rgba(20, 26, 16, 0.55);
  border: 1px solid rgba(233,239,223,0.15);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}
#reset-btn:hover { color: var(--ink); border-color: rgba(224,123,47,0.5); }

/* ---- footer ---- */
footer {
  position: fixed;
  bottom: 16px;
  right: 20px;
  z-index: 5;
}
footer a {
  font-family: 'Newsreader', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
  text-decoration: none;
  transition: color 0.2s;
}
footer a:hover { color: var(--hammer); }

@media (max-width: 640px) {
  #title-flourish .big { font-size: 22px; }
  #title-flourish .small { display: none; }
  #height-value, #best-value { font-size: 24px; }
  #instructions .card { margin: 20px; padding: 26px; }
}