@import url('https://fonts.googleapis.com/css2?family=Rye&family=Special+Elite&display=swap');

:root {
  --bg0: #2a1b12;
  --bg1: #1a0f08;
  --accent: #f0b842;     /* brass / gold */
  --accent2: #c0392b;    /* outlaw red */
  --good: #6fae3e;       /* cactus green */
  --ink: #f3e3c2;        /* parchment ink */
  --wood: #3a2415;
  --wood-light: #5a3a22;
  --parchment: #e7d2a8;
  --display: "Rye", "Trebuchet MS", serif;
  --body: "Special Elite", "Courier New", monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a0f08;
  font-family: var(--body);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

#stage { position: fixed; inset: 0; }

#game { position: absolute; inset: 0; display: block; cursor: none; touch-action: none; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 22px;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
  z-index: 5;
}
.hud-left .hud-score { font-family: var(--display); font-size: 28px; letter-spacing: 1px; }
.hud-left .hud-score span { color: var(--accent); }
.hud-left .hud-best { font-size: 14px; opacity: .7; margin-top: 2px; }

.hud-center { text-align: center; min-width: 38vw; }
#timebar-wrap {
  width: 100%; height: 14px; border-radius: 8px;
  background: rgba(255,255,255,.12);
  overflow: hidden;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.15);
}
#timebar {
  height: 100%; width: 100%;
  background: linear-gradient(90deg, var(--good), var(--accent));
  transition: background .2s linear;
}
#time { font-size: 18px; font-weight: 700; margin-top: 4px; }

.hud-right { min-width: 110px; text-align: right; }
.combo {
  font-size: 34px; font-weight: 900;
  color: var(--accent2);
  transition: transform .08s ease;
}
.combo.pop { transform: scale(1.4); }

/* ---------- Mute ---------- */
#mute {
  position: absolute; bottom: 16px; right: 16px;
  width: 46px; height: 46px;
  border: none; border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff; font-size: 22px; cursor: pointer;
  z-index: 6;
  backdrop-filter: blur(4px);
}
#mute:hover { background: rgba(255,255,255,.22); }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  gap: 16px;
  background:
    radial-gradient(120% 120% at 50% 25%, rgba(58,30,18,.55), rgba(20,10,5,.9)),
    repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 2px, transparent 2px 26px);
  z-index: 10;
  padding: 24px;
}
.overlay h1 {
  font-family: var(--display);
  font-size: clamp(46px, 9vw, 108px);
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 3px 0 #6b3410, 0 6px 0 rgba(0,0,0,.4), 0 0 40px rgba(240,184,66,.4);
}
.overlay .tag { font-size: clamp(14px, 2.2vw, 19px); line-height: 1.6; opacity: .92; max-width: 600px; }
.overlay .hint { font-size: 13px; opacity: .65; max-width: 520px; }

.btn {
  font-family: var(--display);
  margin-top: 4px;
  padding: 14px 50px;
  font-size: 24px; letter-spacing: 1px;
  color: #2a1605;
  background: linear-gradient(180deg, #f5cd6b, var(--accent));
  border: 3px solid #3a2415;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 7px 0 #7a4a16, 0 12px 22px rgba(0,0,0,.5);
  transition: transform .05s ease, box-shadow .05s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 9px 0 #7a4a16, 0 16px 26px rgba(0,0,0,.55); }
.btn:active { transform: translateY(4px); box-shadow: 0 3px 0 #7a4a16; }

.sub {
  font-family: var(--display);
  font-size: clamp(16px, 2.6vw, 22px);
  color: var(--ink);
  letter-spacing: 1px;
  margin-top: -8px;
}

/* Name entry */
.greeting {
  font-size: clamp(18px, 3vw, 26px);
  font-weight: 800;
  color: var(--good);
  text-shadow: 0 2px 10px rgba(0,0,0,.5);
  margin-top: -4px;
}
.name-row { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; justify-content: center; }
#name-input {
  width: min(320px, 70vw);
  padding: 13px 18px;
  font-family: var(--body);
  font-size: 20px;
  text-align: center;
  color: #2a1605;
  background: var(--parchment);
  border: 3px solid #6b4a26;
  border-radius: 8px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#name-input::placeholder { color: rgba(58,36,21,.5); }
#name-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,184,66,.35); }
.name-row .btn { margin-top: 0; padding: 14px 40px; font-size: 22px; }

/* Leaderboard — "wanted" bounty board on parchment */
.board {
  width: min(360px, 84vw);
  color: #3a2415;
  background:
    radial-gradient(120% 140% at 50% 0%, #f3e3bd, #d9bd87);
  border: 3px solid #6b4a26;
  border-radius: 6px;
  padding: 12px 16px 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,.5), inset 0 0 30px rgba(120,80,30,.25);
}
.board h3 {
  font-family: var(--display);
  font-size: 18px; letter-spacing: 1px;
  margin-bottom: 8px; text-align: center;
  color: #6b2e10;
  border-bottom: 2px dashed #6b4a26;
  padding-bottom: 6px;
}
.board-list { list-style: none; display: flex; flex-direction: column; gap: 1px; }
.board-list li {
  display: flex; align-items: center;
  padding: 5px 8px; border-radius: 4px;
  font-size: 17px;
}
.board-list li:nth-child(odd) { background: rgba(107,74,38,.10); }
.board-list li.me {
  background: rgba(192,57,43,.22);
  box-shadow: inset 0 0 0 2px rgba(107,46,16,.6);
  font-weight: 700;
}
.b-rank { width: 30px; opacity: .8; font-weight: 700; }
.b-name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-score { color: #8a3a12; font-weight: 700; }
.board-empty { justify-content: center; opacity: .65; font-style: italic; }

/* Game over */
.badge {
  font-size: 22px; font-weight: 900; letter-spacing: 1px;
  color: #05070f; background: var(--good);
  padding: 8px 20px; border-radius: 30px;
  animation: pulse 1s infinite alternate;
}
@keyframes pulse { from { transform: scale(1);} to { transform: scale(1.08);} }

.stats { display: flex; gap: 34px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.stats > div { display: flex; flex-direction: column; align-items: center; }
.stats span { font-family: var(--display); font-size: 40px; color: var(--accent); line-height: 1; }
.stats small { font-size: 12px; letter-spacing: 2px; opacity: .7; margin-top: 6px; }

/* Loading spinner */
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 5px solid rgba(255,255,255,.2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile / small screens ---------- */
@media (max-width: 600px) {
  #hud { padding: 10px 12px; }
  .hud-left .hud-score { font-size: 20px; }
  .hud-left .hud-best { font-size: 11px; }
  .hud-center { min-width: 46vw; }
  #time { font-size: 15px; }
  .combo { font-size: 24px; }
  .hud-right { min-width: 64px; }

  .overlay { gap: 12px; padding: 18px; }
  .overlay .tag { font-size: 14px; }
  .name-row { flex-direction: column; align-items: center; }
  #name-input { width: min(320px, 82vw); }
  .stats { gap: 18px; }
  .stats span { font-size: 30px; }
  .board { width: min(360px, 90vw); }

  #mute { width: 40px; height: 40px; font-size: 18px; bottom: 10px; right: 10px; }
}

/* Devices without a hover-capable pointer (phones/tablets): no cursor anyway */
@media (hover: none) {
  #game { cursor: default; }
}
