/* Early-2000s aesthetic — inspired by 8bitnintendo.science */
*, *::after, *::before {
  box-sizing: border-box;
}

html {
  background-color: #000;
  background-image: url("/web/assets/site/batsbg.gif");
  background-repeat: repeat;
  image-rendering: pixelated;
}

body.rh-page {
  background: transparent;
  color: #fff;
  font-family: "Times New Roman", Times, serif;
  image-rendering: pixelated;
  padding: 2rem 50px;
  min-height: 100svh;
  margin: 0;
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

body.rh-page input,
body.rh-page textarea,
body.rh-page select {
  user-select: text;
  -webkit-user-select: text;
  cursor: text;
}

body.rh-page a,
body.rh-page button,
body.rh-page .rh-start-btn,
body.rh-page .rh-timetrial-link,
body.rh-page .rh-home-link,
body.rh-page .rh-more-info,
body.rh-page .rh-watch-link {
  cursor: pointer;
}

a {
  color: #1e90ff;
}

a:visited {
  color: #6a5acd;
}

.rh-page .container {
  max-width: 120ch;
  margin-inline: auto;
  position: relative;
}

.rh-home .container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.rh-home .container > * {
  width: 100%;
  max-width: min(100%, 900px);
}

.rh-page .text3d {
  width: 100%;
  max-width: min(100%, 900px);
  display: block;
  margin: 0 auto 1rem;
  image-rendering: auto;
}

.rh-home .rh-worm-row {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(1.5rem, 6vw, 4rem);
  margin: 1.25rem 0;
}

.rh-home .rh-worm-row img {
  flex: 0 0 auto;
  display: block;
  width: clamp(52px, 11vw, 96px);
  max-width: 96px;
  height: auto;
  image-rendering: pixelated;
}

.rh-home .rh-worm-row img.rh-worm-flip {
  transform: scaleX(-1);
}

.rh-page h1,
.rh-page h2,
.rh-page h3 {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
}

.rh-page h1 {
  font-size: 2rem;
  color: #ff0;
  animation: rh-glow 1s infinite alternate;
  margin: 0;
  text-align: center;
}

.rh-disclaimer {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: clamp(0.95rem, 2.2vw, 1.25rem);
  font-weight: 700;
  line-height: 1.45;
  color: #ff0;
  animation: rh-glow 1s infinite alternate;
  margin: 0.5rem auto 1.25rem;
  padding: 0 0.5rem;
  max-width: 52ch;
  text-align: center;
}

.rh-page h2 {
  font-size: 1.6rem;
  color: #ff0;
}

.rh-page .header {
  margin: 0.5rem 0 0;
  text-align: center;
  width: 100%;
}

.rh-gundam {
  display: block;
  max-width: min(100%, 520px);
  margin: 0 auto;
  image-rendering: auto;
}

.rh-nav {
  text-align: center;
  margin: 1.5rem 0;
}

.rh-timetrial-link {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: #ff0 !important;
  text-decoration: underline;
  text-shadow: red 2px 2px 4px;
}

.rh-timetrial-link:hover {
  color: #fff !important;
}

.rh-timetrial-link:visited {
  color: #ff0 !important;
}

.rh-site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 2rem;
  padding-bottom: 1rem;
  font-family: "Times New Roman", Times, serif;
  font-size: 0.85rem;
  color: #aaa;
  text-align: center;
}

.rh-brand {
  padding-top: 2rem;
}

.rh-brand .container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.rh-brand .text3d {
  max-width: min(100%, 900px);
  height: auto;
}

.rh-browser-logo {
  display: inline-block;
  height: 1.25rem;
  width: auto;
  vertical-align: middle;
  image-rendering: auto;
}

.rh-browser-logo--chrome,
.rh-browser-logo--netscape,
.rh-browser-logo--ie {
  height: 1.15rem;
}

.rh-browser-logo--ie {
  margin-right: -0.25rem;
}

.rh-home-link {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1rem;
  color: #1e90ff;
}

.rh-hero-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  margin: 1.25rem 0 1rem;
}

.rh-start-btn {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  padding: 0.65rem 2.25rem;
  border: 3px outset #888;
  background: linear-gradient(180deg, #444 0%, #222 100%);
  color: #ff0;
  cursor: pointer;
  text-decoration: none;
  text-shadow: red 1px 1px 3px;
}

.rh-start-btn:hover {
  border-style: inset;
  color: #fff;
}

.rh-more-info-wrap {
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  width: auto;
  margin: 0;
  text-align: right;
}

.rh-leaderboard-stack {
  position: relative;
  width: 100%;
  max-width: min(100%, 720px);
  margin: 0.85rem auto 0;
  padding-top: 1.65rem;
}

.rh-leaderboard-stack > .rh-more-info-wrap {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
}

.rh-leaderboard-stack .timetrial-leaderboard {
  margin: 0;
}

.rh-leaderboard-stack .rh-more-info-worm {
  transform: translateY(22%);
}

.rh-leaderboard-stack .rh-more-info-bubble {
  left: auto;
  right: 0;
  transform: none;
}

.rh-leaderboard-stack .rh-more-info-bubble::before {
  left: auto;
  right: 1.25rem;
  margin-left: 0;
}

.rh-leaderboard-stack .rh-more-info-bubble::after {
  left: auto;
  right: 1.05rem;
  margin-left: 0;
}

.rh-more-info {
  display: inline-flex;
  align-items: flex-end;
  gap: 0.45rem;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ff0;
  cursor: help;
  text-shadow: red 1px 1px 3px;
  outline: none;
  line-height: 1.2;
}

.rh-more-info-label {
  display: inline-block;
  padding-bottom: 0.1rem;
}

.rh-more-info:hover,
.rh-more-info:focus-visible {
  color: #fff;
}

.rh-more-info-worm-wrap {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
  flex-shrink: 0;
}

/* GIF is 60×60 with ~17px transparent padding below the foot. */
.rh-more-info-worm {
  display: block;
  width: clamp(40px, 9vw, 48px);
  height: clamp(40px, 9vw, 48px);
  image-rendering: pixelated;
  transform: translateY(28%);
  pointer-events: none;
}

.rh-more-info-bubble {
  position: absolute;
  bottom: calc(100% + 0.35rem);
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: max-content;
  max-width: min(88vw, 19rem);
  padding: 0.75rem 0.95rem;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.45;
  color: #111;
  text-align: left;
  text-shadow: none;
  background: #fff;
  border: 3px solid #000;
  border-radius: 1.1rem;
  box-shadow: 4px 4px 0 #000;
  pointer-events: none;
}

.rh-more-info-bubble::before {
  content: "";
  position: absolute;
  bottom: -11px;
  left: 50%;
  margin-left: -9px;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid #fff;
  z-index: 1;
}

.rh-more-info-bubble::after {
  content: "";
  position: absolute;
  bottom: -16px;
  left: 50%;
  margin-left: -11px;
  width: 0;
  height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 15px solid #000;
}

.rh-more-info-bubble[hidden] {
  display: none !important;
}

@media (max-width: 700px) {
  .rh-more-info-bubble {
    transform: translateX(-50%);
    max-width: min(92vw, 16rem);
  }

  .rh-leaderboard-stack .rh-more-info-bubble {
    right: 0;
    transform: none;
  }

  .rh-leaderboard-stack .rh-more-info-bubble::before {
    left: auto;
    right: 1.25rem;
    margin-left: 0;
  }

  .rh-leaderboard-stack .rh-more-info-bubble::after {
    left: auto;
    right: 1.05rem;
    margin-left: 0;
  }
}

/* Leaderboard table — 8bitnintendo.science style */
[data-rh-view].rh-timetrial .container {
  display: flex;
  flex-direction: column;
  align-items: center;
}

[data-rh-view].rh-timetrial .container > * {
  width: 100%;
  max-width: min(100%, 900px);
}

.rh-timetrial .the-list {
  max-width: min(100%, 720px);
}

.rh-page .the-list {
  position: relative;
  max-width: 100%;
  margin: 2rem auto;
}

.rh-page table {
  width: 100%;
  background: #000;
  border-collapse: collapse;
}

.rh-page table thead {
  position: sticky;
  top: -2px;
  background: #000;
  z-index: 1;
}

.rh-page table td,
.rh-page table th {
  padding: 1ch;
  border: 1px solid #666;
}

.rh-page table td.rank,
.rh-page table th.rank {
  position: sticky;
  left: 0;
  background: #000;
  text-align: center;
  width: 5ch;
}

.rh-page .the-list table#ranking th {
  white-space: nowrap;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  color: #ff0;
}

.rh-page .the-list table#ranking td.timestamp {
  text-align: center;
  font-family: Consolas, Monaco, "Courier New", monospace;
}

.rh-page .the-list table#ranking td.replay {
  text-align: center;
}

.rh-page .the-list table td.map,
.rh-page .the-list table th.map {
  text-align: center;
}

.rh-map-link {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-weight: 700;
  color: #ff0 !important;
  text-decoration: underline;
  text-shadow: red 1px 1px 3px;
}

.rh-map-link:hover {
  color: #fff !important;
}

.rh-map-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 1rem 1.25rem;
  width: 100%;
  max-width: min(100%, 720px);
  margin: 0 auto 1rem;
}

.rh-map-choice {
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  align-content: end;
  gap: 0.45rem;
  padding: 0.55rem;
  border: 3px ridge #666;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  min-width: 11rem;
}

.rh-map-choice--active {
  border-color: #ff0;
  box-shadow: 0 0 0 2px #ff0, 0 0 18px rgba(255, 255, 0, 0.35);
}

.rh-map-choice-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rh-map-choice-preview {
  display: block;
  width: min(100%, 220px);
  max-height: 150px;
  height: auto;
  object-fit: contain;
  align-self: end;
  border: 2px solid #444;
  image-rendering: pixelated;
  background: #000;
}

.rh-map-choice-name {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ff0;
  text-shadow: red 1px 1px 3px;
  line-height: 1.2;
  text-align: center;
}

.rh-map-picker-wrap--map-only {
  margin-bottom: 0.5rem;
}

.rh-map-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  max-width: min(100%, 280px);
  margin: 0 auto 0.5rem;
  padding: 0;
  border: none;
}

.rh-map-hero[hidden] {
  display: none !important;
}

.rh-map-hero-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 220px;
  height: 180px;
  padding: 0.55rem;
  border: 3px ridge #666;
  background: rgba(0, 0, 0, 0.45);
  box-sizing: border-box;
}

.rh-map-hero-box--active {
  border-color: #ff0;
  box-shadow: 0 0 0 2px #ff0, 0 0 18px rgba(255, 255, 0, 0.35);
}

.rh-map-hero-preview {
  display: block;
  width: 200px;
  height: 150px;
  object-fit: contain;
  border: 2px solid #444;
  image-rendering: pixelated;
  background: #000;
}

.rh-map-hero-caption {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  text-align: center;
}

.rh-map-hero-name {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: #ff0;
  text-shadow: red 1px 1px 3px;
  line-height: 1.2;
  text-align: center;
}

.rh-random-map-link {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #ff0;
  text-decoration: underline;
  text-shadow: red 1px 1px 3px;
  cursor: pointer;
  line-height: 1.3;
}

.rh-random-map-link:hover {
  color: #fff;
}

.rh-leaderboard-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  width: 100%;
  margin: 0 0 0.5rem;
}

.rh-leaderboard-head h2 {
  margin: 0;
}

.rh-leaderboard-head .rh-timetrial-extra-links {
  margin: 0;
  padding: 0;
  width: auto;
  max-width: none;
  justify-content: flex-end;
}

.rh-map-hub-note {
  width: 100%;
  max-width: min(100%, 720px);
  margin: 0.25rem auto 0.35rem;
  padding: 0 1ch;
  text-align: left;
}

.rh-map-hub-note[hidden] {
  display: none !important;
}

.rh-timetrial-extra-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  justify-content: center;
  width: 100%;
  max-width: min(100%, 720px);
  margin: 0.35rem auto 0.75rem;
  padding: 0 1ch;
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 0.95rem;
}

.rh-timetrial-extra-links a {
  color: #8cf;
}

.rh-user-maps-section {
  width: 100%;
  max-width: min(100%, 720px);
  margin: 0 auto;
  padding: 0 1ch;
}

.rh-user-maps-intro {
  margin: 0 0 1rem;
  color: #ccc;
  font-size: 0.9rem;
  line-height: 1.45;
}

.rh-user-maps-empty {
  margin: 0;
  color: #aaa;
  font-style: italic;
}

.rh-user-maps-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.rh-user-map-item {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid #444;
  background: #111;
}

.rh-user-map-preview {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 1px solid #333;
}

.rh-user-map-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  color: #ff0;
}

.rh-user-map-meta {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #aaa;
}

.rh-user-map-actions {
  margin: 0;
}

.rh-start-btn--compact {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

.rh-user-map-item--loading,
.rh-user-map-item--error {
  grid-template-columns: 1fr;
  font-style: italic;
  color: #aaa;
}

.rh-user-map-item--error {
  color: #f88;
}

@media (max-width: 520px) {
  .rh-user-map-item {
    grid-template-columns: 1fr;
  }
}

.rh-page .the-list img.medal {
  width: 4ch;
  vertical-align: middle;
}

.rh-page .the-list .rh-watch-link {
  font-family: "Comic Sans MS", "Comic Sans", cursive, sans-serif;
  font-size: 0.95rem;
  white-space: nowrap;
}

.rh-page .the-list tr.rh-ladder-you td {
  background: #1a1a3a;
  font-weight: 700;
}

.rh-page .the-list tr.rh-ladder-empty td,
.rh-page .the-list tr.rh-ladder-error td {
  text-align: center;
  font-style: italic;
  color: #aaa;
}

.rh-page .the-list tr.rh-ladder-error td {
  color: #f88;
  font-style: normal;
}

.rh-page .nav-links {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.rh-auth-dock {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 1200;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: 0.65rem 0.75rem;
  border: 1px solid #555;
  border-radius: 8px;
  background: rgba(8, 8, 12, 0.92);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  font-size: 0.82rem;
  line-height: 1.3;
}

.rh-auth-dock--logged-in {
  padding: 0.5rem 0.65rem;
  text-align: right;
}

.rh-auth-dock--logged-in .rh-auth-login {
  display: none !important;
}

.rh-auth-dock--logged-in .rh-auth-user {
  margin: 0 0 0.35rem;
}

.rh-auth-dock--logged-in .rh-auth-actions {
  margin-top: 0;
}

.rh-auth-dock[hidden],
.rh-auth-login[hidden],
.rh-auth-actions[hidden] {
  display: none !important;
}

.rh-auth-user {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: #ccc;
  text-align: right;
}

.rh-auth-user-link {
  color: #ff0;
  text-decoration: none;
}

.rh-auth-user-link:hover {
  text-decoration: underline;
}

.rh-player-link {
  color: #ff0;
  text-decoration: none;
}

.rh-player-link:hover {
  text-decoration: underline;
}

.rh-profile-section-title {
  margin: 1.25rem 0 0.5rem;
  font-size: 1rem;
  color: #ff0;
}

.rh-profile-hint {
  margin: 0 0 0.5rem;
  color: #888;
  font-size: 0.78rem;
}

.rh-profile-status {
  margin: 0.5rem 0;
  color: #aaa;
  font-style: italic;
}

.rh-profile-error-page {
  margin: 0.5rem 0;
  color: #f88;
}

.rh-player-profile h2 {
  margin-bottom: 0.75rem;
}

body.timetrial-profile {
  overflow-y: auto;
  max-height: 100svh;
}

#rh-view-profile .container {
  overflow-y: visible;
  padding-bottom: 2rem;
}

.rh-player-profile .rh-profile-table {
  table-layout: fixed;
  width: 100%;
  max-width: 34rem;
}

.rh-player-profile .rh-profile-table th.rank,
.rh-player-profile .rh-profile-table td.rank {
  width: 3.25rem;
  position: static;
}

.rh-player-profile .rh-profile-table th.map,
.rh-player-profile .rh-profile-table td.map {
  width: 38%;
}

.rh-player-profile .rh-profile-table th.timestamp,
.rh-player-profile .rh-profile-table td.timestamp {
  width: 28%;
}

.rh-player-profile .rh-profile-table th.replay,
.rh-player-profile .rh-profile-table td.replay {
  width: 22%;
}

.rh-player-profile img.medal,
.rh-player-profile img.medal--inline {
  display: inline-block;
  width: 1em !important;
  height: 1em !important;
  max-width: 1em;
  object-fit: contain;
  vertical-align: middle;
}

.rh-page .the-list td.rank {
  line-height: 1.2;
  white-space: nowrap;
}

.rh-auth-login {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.rh-auth-login-label {
  color: #aaa;
  font-size: 0.78rem;
  white-space: nowrap;
}

.rh-auth-providers {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.rh-auth-provider {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid #555;
  border-radius: 6px;
  background: #1a1a1a;
  text-decoration: none;
  line-height: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.rh-auth-provider:hover {
  background: #2a2a2a;
  border-color: #888;
}

.rh-auth-provider svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
}

.rh-auth-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.rh-auth-mini {
  padding: 0.15rem 0.45rem;
  border: 1px solid #555;
  border-radius: 4px;
  background: #1a1a1a;
  color: #bbb;
  font: inherit;
  font-size: 0.72rem;
  cursor: pointer;
}

.rh-auth-mini:hover {
  color: #ff0;
  border-color: #777;
}

.rh-auth-btn {
  display: inline-block;
  padding: 0.35rem 0.65rem;
  border: 2px ridge #666;
  background: #222;
  color: #ff0;
  font: inherit;
  font-size: 0.85rem;
  text-decoration: none;
  cursor: pointer;
}

.rh-auth-btn:hover {
  background: #333;
  color: #ff0;
}

.rh-profile-setup {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid #444;
}

.rh-profile-title {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: #ff0;
  text-align: right;
}

.rh-profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rh-profile-form label {
  font-size: 0.72rem;
  color: #aaa;
  text-align: right;
}

.rh-profile-form input {
  padding: 0.35rem 0.5rem;
  background: #000;
  color: #fff;
  border: 1px solid #666;
  font: inherit;
  font-size: 0.82rem;
}

.rh-profile-error {
  margin: 0;
  color: #f88;
  font-size: 0.72rem;
  text-align: right;
}

.rh-auth-btn--primary {
  align-self: flex-end;
  margin-top: 0.15rem;
  font-size: 0.78rem;
}

@media (max-width: 700px) {
  .rh-auth-dock {
    top: 0.5rem;
    right: 0.5rem;
    width: min(15rem, calc(100vw - 1rem));
    padding: 0.5rem 0.6rem;
  }
}

@keyframes rh-glow {
  from { text-shadow: red 2px 4px 8px; }
  to { text-shadow: red 2px 4px 1px; }
}

@media (max-width: 1000px) {
  body.rh-page {
    margin: 0;
    padding: 2rem 1rem;
    font-size: 0.9em;
  }

  .rh-page h1 {
    font-size: 1.4rem;
  }

  .rh-page h2 {
    font-size: 1.2rem;
  }
}

@media (max-width: 700px) {
  .rh-home .rh-worm-row {
    gap: 1rem;
  }

  .rh-home .rh-worm-row img {
    width: clamp(40px, 18vw, 72px);
    max-width: 72px;
  }
}
