:root {
  --ink: #162016;
  --muted: #626954;
  --panel: rgba(255, 249, 228, 0.78);
  --panel-solid: rgba(255, 249, 228, 0.94);
  --panel-border: rgba(78, 68, 38, 0.18);
  --gold: #f2a31f;
  --terracotta: #b75d2c;
  --leaf: #2d7d43;
  --sky: #8fd4ff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow: hidden;
  background: #8fd4ff;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif;
}

button {
  font: inherit;
}

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #8fd4ff;
}

.stage::before,
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.stage::before {
  z-index: 2;
  opacity: 0.16;
  background:
    linear-gradient(180deg, rgba(255, 232, 177, 0.18), rgba(255, 255, 255, 0) 38%, rgba(72, 119, 73, 0.12)),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 4px);
}

.stage::after {
  z-index: 3;
  background:
    radial-gradient(ellipse at center, transparent 48%, rgba(46, 33, 16, 0.2) 100%),
    linear-gradient(90deg, rgba(255, 216, 146, 0.08), transparent 30%, transparent 70%, rgba(47, 82, 60, 0.08));
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  left: clamp(14px, 2vw, 28px);
  right: clamp(14px, 2vw, 28px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
  z-index: 4;
}

.hud-top {
  top: clamp(14px, 2vw, 26px);
}

.title-block {
  min-width: 0;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: clamp(10px, 1.1vw, 12px);
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7d4f17;
}

h1 {
  max-width: min(56vw, 620px);
  font-size: clamp(18px, 2vw, 32px);
  line-height: 1.05;
  color: #21301d;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
}

.hud-metrics {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-metrics span,
.controls button {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  color: #342b18;
  border-radius: 999px;
  padding: 9px 13px;
  font-size: clamp(11px, 1.1vw, 14px);
  font-weight: 850;
  box-shadow: 0 10px 28px rgba(40, 42, 22, 0.14);
  backdrop-filter: blur(14px);
}

.hud-metrics b {
  color: #a64a1e;
}

.progress-wrap {
  position: absolute;
  left: clamp(14px, 2vw, 28px);
  right: clamp(14px, 2vw, 28px);
  top: clamp(70px, 9vw, 90px);
  z-index: 4;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  background: rgba(255, 255, 255, 0.38);
}

#progressBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), #f4cf57, var(--terracotta));
}

.start-panel,
.finish-panel {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: clamp(20px, 5vw, 56px);
  text-align: center;
  background: linear-gradient(180deg, rgba(255, 249, 228, 0.26), rgba(255, 249, 228, 0.62));
}

.panel-copy,
.finish-panel > .eyebrow,
.finish-panel > h2,
.finish-panel > p {
  max-width: 760px;
}

.start-panel h2,
.finish-panel h2 {
  font-size: clamp(34px, 6vw, 82px);
  line-height: 0.96;
  color: #24311e;
  text-shadow: 0 4px 0 rgba(255, 255, 255, 0.42);
}

.start-panel p,
.finish-panel p {
  font-size: clamp(14px, 1.5vw, 19px);
  font-weight: 800;
  color: #65572c;
}

.primary-btn {
  border: 0;
  border-radius: 999px;
  padding: 15px 28px;
  min-width: 152px;
  background: linear-gradient(135deg, var(--gold), #d85a2a);
  color: #fffbea;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 18px 34px rgba(157, 78, 26, 0.32);
}

.primary-btn:active,
.controls button:active {
  transform: translateY(1px);
}

.controls {
  position: absolute;
  right: clamp(14px, 2vw, 28px);
  bottom: clamp(14px, 2vw, 28px);
  z-index: 5;
  display: flex;
  gap: 8px;
}

.controls button {
  cursor: pointer;
}

.stage.recording .title-block,
.stage.recording .controls {
  opacity: 0;
  pointer-events: none;
}

.stage.recording .hud {
  justify-content: flex-end;
}

.stage.recording .hud-metrics {
  opacity: 0.72;
  transform: scale(0.94);
  transform-origin: top right;
}

.stage.recording .progress-wrap {
  opacity: 0.52;
}

@media (max-width: 760px) {
  .hud {
    gap: 10px;
  }

  h1 {
    max-width: 46vw;
    font-size: 18px;
  }

  .hud-metrics {
    max-width: 48vw;
  }

  .progress-wrap {
    top: 88px;
  }

  .start-panel h2,
  .finish-panel h2 {
    font-size: clamp(34px, 10vw, 58px);
  }
}
