:root {
  color-scheme: dark;
  --sn-blue: #0c2a73;
  --sn-ivory: #f3eee4;
  --sn-gold: #c4a15a;
  --glass: rgba(8, 14, 24, 0.48);
  --glass-border: rgba(220, 236, 255, 0.16);
  font-family: Outfit, "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #071018;
  touch-action: none;
  user-select: none;
}

canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.chrome {
  position: fixed;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.chrome > * {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

.player-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: #e8f2ff;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

.player-bar button {
  appearance: none;
  border: 0;
  background: #0c2a73;
  color: #f3eee4;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.view-btn,
.rank-btn {
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

.view-btn {
  position: absolute;
  top: 62px;
  right: 16px;
  appearance: none;
  border: 1px solid rgba(196, 161, 90, 0.55);
  background: #0c2a73;
  color: #f3eee4;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.hud-chip {
  position: absolute;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 22px 16px 8px 14px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: #f4f7fb;
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}

.hud-chip .hud-kicker {
  position: absolute;
  top: 7px;
  left: 14px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #9eb4c8;
}

.hud-chip strong {
  font-family: Syne, Outfit, sans-serif;
  font-size: 26px;
  font-weight: 800;
  display: inline-block;
}

.hud-chip .hud-unit {
  font-size: 12px;
  color: #9eb4c8;
  font-weight: 600;
}

.hud-speed {
  top: 16px;
  left: 16px;
}

.player-bar:not(.hidden) ~ .hud-speed {
  top: 62px;
}

.hud-wind {
  top: 114px;
  right: 16px;
  flex-direction: column;
  align-items: flex-end;
  min-width: 148px;
}

.hud-wind strong,
.hud-wind .hud-kicker {
  text-align: right;
}

.hud-wind .hud-kicker {
  left: auto;
  right: 14px;
}

.hud-dist {
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
}

.hud-hint {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: #e8f2ff;
  font-size: 15px;
  font-weight: 600;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  white-space: nowrap;
}

.hud-flash {
  position: absolute;
  left: 50%;
  top: 26%;
  transform: translateX(-50%);
  font-family: Syne, Outfit, sans-serif;
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  color: #d7ecff;
  text-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.view-btn[data-mode="chase"] {
  background: #c4a15a;
  color: #102033;
  border-color: #f3eee4;
}

.rank-btn {
  position: absolute;
  top: 14px;
  right: 16px;
  appearance: none;
  border: 1px solid rgba(196, 161, 90, 0.55);
  background: #0c2a73;
  color: #f3eee4;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.rank-card h2 {
  text-align: center;
  font-size: 28px;
  margin: 4px 0 16px;
  color: #102033;
}

.rank-list {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  min-height: 48px;
}

.rank-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 8px 4px;
  border-bottom: 1px solid rgba(12, 42, 115, 0.1);
  font-size: 15px;
  color: #102033;
}

.rank-list li.mine {
  font-weight: 700;
  color: #0c2a73;
}

.rank-list .rank-pos {
  color: #c4a15a;
  font-weight: 700;
}

.rank-card #rank-close {
  appearance: none;
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: #0c2a73;
  color: #f3eee4;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 16px;
  cursor: pointer;
}

.gate-logos {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: min(280px, 100%);
  margin: 10px auto 16px;
}

.gate-logos .gate-logo {
  position: static;
  width: 100%;
  height: auto;
  margin: 0;
  object-fit: contain;
}

.gate-logos .gate-logo-at {
  width: min(220px, 86%);
}

#rank-overlay.gate {
  z-index: 11;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(6, 12, 20, 0.38);
  touch-action: auto;
}

.gate-card h1 {
  font-family: Syne, Outfit, sans-serif;
  font-size: 34px;
  letter-spacing: 0.04em;
  text-align: center;
  color: #102033;
}

.gate-card {
  width: min(420px, 100%);
  padding: 28px 26px 24px;
  border-radius: 22px;
  background: rgba(243, 238, 228, 0.92);
  color: #0c2a73;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  user-select: text;
  backdrop-filter: blur(24px) saturate(1.2);
  -webkit-backdrop-filter: blur(24px) saturate(1.2);
}

.gate-kicker {
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #c4a15a;
  text-align: center;
}

.gate-logo {
  display: block;
  width: min(280px, 100%);
  height: auto;
  margin: 10px auto 18px;
}

.gate-copy {
  margin: 10px 0 18px;
  font-size: 15px;
  line-height: 1.45;
  color: #3a4a5c;
  text-align: center;
}

.gate-card label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.gate-card input {
  width: 100%;
  border: 1px solid rgba(12, 42, 115, 0.22);
  background: #fffdf8;
  color: #102033;
  font: inherit;
  font-size: 18px;
  padding: 12px 14px;
  border-radius: 12px;
  outline: none;
}

.gate-card input:focus {
  border-color: #0c2a73;
  box-shadow: 0 0 0 3px rgba(12, 42, 115, 0.15);
}

.gate-error {
  margin: 8px 0 0;
  color: #9a2b32;
  font-size: 13px;
}

.gate-card button[type="submit"],
.gate-card .gate-rank {
  appearance: none;
  width: 100%;
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  background: #0c2a73;
  color: #f3eee4;
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  padding: 13px 16px;
  cursor: pointer;
}

.gate-card .gate-rank {
  margin-top: 8px;
  background: transparent;
  color: #0c2a73;
  border: 1px solid rgba(12, 42, 115, 0.28);
}
