/* ========================================================
   RUNANDGUN // page layout, HUD and menus
   The game itself is drawn on the canvas in game.js.
   ======================================================== */

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

html, body {
  height: 100%;
  background: var(--tc-bg-canvas);
  color: var(--tc-text-main);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; }

kbd {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  background: var(--tc-bg-pill);
  border-radius: 5px;
  padding: 1px 6px;
  margin-right: 3px;
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.35);
}

/* ================= FRAME ================= */
.rg-shell {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rg-frame {
  position: relative;
  height: 100%;
  width: min(100%, calc(100vh * 0.6));
  overflow: hidden;
  background: #d8b98a;
  box-shadow: var(--shadow-lg);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

@media (min-width: 700px) {
  .rg-frame {
    height: calc(100% - 32px);
    border-radius: 22px;
  }
}

#rg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ================= HUD ================= */
.rg-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 0;
  padding-top: max(12px, env(safe-area-inset-top));
  pointer-events: none;
}

.rg-hud > * { pointer-events: auto; }

.rg-distance {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  font-variant-numeric: tabular-nums;
}

.rg-distance small {
  font-size: 16px;
  font-weight: 700;
  margin-left: 2px;
  opacity: 0.85;
}

.rg-icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: rgba(27, 28, 31, 0.72);
  backdrop-filter: blur(6px);
  color: var(--tc-text-main);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.2s ease;
}

.rg-icon-btn:hover { background: rgba(27, 28, 31, 0.9); }

.rg-subhud {
  position: absolute;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.rg-best {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.rg-weapon {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(27, 28, 31, 0.78);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 5px 12px 5px 12px;
  font-size: 12.5px;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.rg-weapon[hidden] { display: none; }

.rg-weapon-bar {
  width: 70px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

#hud-weapon-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: var(--tc-accent-yellow);
}

/* ================= OVERLAYS ================= */
.rg-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(20, 21, 24, 0.55);
  backdrop-filter: blur(3px);
  animation: rgFade 0.25s ease-out;
  overflow-y: auto;
}

.rg-overlay[hidden] { display: none; }

@keyframes rgFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.rg-card {
  width: 100%;
  max-width: 360px;
  margin: auto;
  background: var(--tc-bg-card);
  border-radius: 22px;
  padding: 26px 22px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: rgPop 0.3s ease-out;
}

.rg-card-small { max-width: 260px; }

@keyframes rgPop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.rg-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 12px;
}

.rg-title span { color: var(--tc-accent-yellow); }

.rg-lead {
  font-size: 14px;
  color: var(--tc-text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.rg-howto {
  list-style: none;
  display: grid;
  gap: 6px;
  text-align: left;
  font-size: 13px;
  color: var(--tc-text-muted);
  background: var(--tc-bg-surface);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}

.dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 3px;
  margin-right: 5px;
  vertical-align: 0;
}

.dot-blue { background: #3d9bff; }
.dot-red { background: #ff5a5a; }

.rg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.rg-btn:hover { transform: translateY(-1px); }

.rg-btn-primary {
  background: var(--tc-accent-yellow);
  color: var(--tc-text-dark);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25), 0 8px 20px rgba(240, 181, 77, 0.2);
}

.rg-btn-primary:hover { background: #f5c265; }

.rg-btn-ghost {
  background: transparent;
  color: var(--tc-text-muted);
}

.rg-btn-ghost:hover { color: var(--tc-text-main); background: var(--tc-bg-surface); transform: none; }

#btn-play { width: 100%; padding: 14px; font-size: 16px; }

/* Leaderboard */
.rg-board {
  margin-top: 20px;
  text-align: left;
}

.rg-board h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--tc-text-dim);
  margin-bottom: 8px;
}

.rg-board ol {
  list-style: none;
  display: grid;
  gap: 4px;
  counter-reset: rank;
}

.rg-board li {
  counter-increment: rank;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--tc-bg-surface);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13.5px;
}

.rg-board li::before {
  content: counter(rank);
  width: 16px;
  font-weight: 800;
  color: var(--tc-text-dim);
}

.rg-board li:nth-child(1)::before { color: #f0b54d; }
.rg-board li:nth-child(2)::before { color: #c9ccd4; }
.rg-board li:nth-child(3)::before { color: #d08c5a; }

.rg-board .name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rg-board .dist {
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.rg-board li.is-new {
  box-shadow: inset 0 0 0 1.5px rgba(240, 181, 77, 0.65);
}

.rg-board .empty {
  justify-content: center;
  color: var(--tc-text-dim);
}

.rg-board .empty::before { display: none; }

/* Game over */
.rg-over-label {
  font-size: 14px;
  color: var(--tc-text-muted);
}

.rg-over-distance {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 2px 0 4px;
}

.rg-over-best {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--tc-text-dim);
  margin-bottom: 16px;
  min-height: 1em;
}

.rg-over-best.is-record { color: var(--tc-accent-yellow); }

.rg-name-form {
  text-align: left;
  background: var(--tc-bg-surface);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 16px;
}

.rg-name-form[hidden] { display: none; }

.rg-name-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--tc-text-muted);
  margin-bottom: 8px;
}

.rg-name-row {
  display: flex;
  gap: 8px;
}

.rg-name-row input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--tc-bg-input);
  color: var(--tc-text-main);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 1px var(--tc-border-subtle);
}

.rg-name-row input:focus {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35), 0 0 0 1.5px rgba(240, 181, 77, 0.65);
}

.rg-name-row .rg-btn { padding: 10px 16px; }

.rg-over-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.rg-pause-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 16px;
}
