:root {
  color-scheme: dark;
  --bg: #07080e;
  --panel: rgba(9, 16, 27, 0.72);
  --panel-strong: rgba(10, 18, 32, 0.9);
  --text: #edf6ff;
  --muted: #9db0c9;
  --cyan: #3be3ff;
  --green: #8ffd8f;
  --red: #ff526b;
  --amber: #ffd166;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 22%, rgba(59, 227, 255, 0.16), transparent 32%),
    linear-gradient(135deg, #05070d 0%, #111827 42%, #090b16 100%);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(12, 23, 38, 0.86);
  color: var(--text);
  min-width: 74px;
  min-height: 38px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
}

button:hover,
button:focus-visible {
  border-color: rgba(59, 227, 255, 0.75);
  outline: none;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  background: rgba(3, 7, 14, 0.78);
  color: var(--text);
  font: inherit;
  letter-spacing: 0;
  padding: 9px 10px;
}

input:focus {
  border-color: rgba(59, 227, 255, 0.78);
  outline: none;
}

.shell {
  position: relative;
  width: 100vw;
  height: 100vh;
}

.shell::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border: 0 solid rgba(255, 82, 107, 0);
  transition: border-color 120ms ease, border-width 120ms ease;
}

.shell.is-hit::after {
  border-width: 6px;
  border-color: rgba(255, 82, 107, 0.82);
}

#glCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #03040a;
}

.hud {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(260px, 0.95fr) minmax(520px, 2fr) auto;
  gap: 14px;
  align-items: start;
  pointer-events: none;
}

.brand,
.stats,
.hud-actions,
.status-panel,
.leaderboard-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 72px;
  min-height: 72px;
  max-height: 72px;
  padding: 12px 14px;
  overflow: hidden;
  border-radius: 8px;
}

.brand-logo {
  width: 118px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 6px;
  background:
    rgba(255, 255, 255, 0.92)
    url("assets/kopano-labs-logo.png?v=20260505-leaderboard") center / cover no-repeat;
  padding: 4px;
  box-shadow: 0 0 22px rgba(59, 227, 255, 0.28);
}

.brand > div:last-child {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1rem, 2vw, 1.55rem);
  line-height: 1.05;
}

.stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(66px, 1fr));
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.stats div {
  min-height: 72px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.stats strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1rem, 1.8vw, 1.42rem);
  line-height: 1;
}

.hud-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 72px;
  padding: 12px;
  border-radius: 8px;
  pointer-events: auto;
}

.pilot-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  max-width: 142px;
  padding: 0 10px;
  overflow: hidden;
  border: 1px solid rgba(143, 253, 143, 0.22);
  border-radius: 6px;
  background: rgba(21, 73, 56, 0.35);
  color: #dfffe5;
  font-size: 0.78rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-panel {
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: min(560px, calc(100vw - 32px));
  transform: translateX(-50%);
  padding: 18px 20px;
  border-radius: 8px;
  text-align: center;
  pointer-events: none;
}

.status-panel.is-hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.status-panel h2 {
  margin-bottom: 8px;
  font-size: clamp(1.3rem, 3.5vw, 2.4rem);
}

.status-panel p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.control-line {
  margin-top: 10px;
  color: #d9e7ff;
  font-size: 0.92rem;
}

.leaderboard-panel {
  position: absolute;
  top: 108px;
  right: 18px;
  z-index: 2;
  width: min(330px, calc(100vw - 36px));
  padding: 12px;
  border-radius: 8px;
  pointer-events: auto;
}

.leaderboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.leaderboard-head h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.1;
}

.leaderboard-actions {
  display: flex;
  gap: 6px;
}

.leaderboard-head button {
  min-width: 70px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.78rem;
}

#shareWhatsappButton {
  border-color: rgba(37, 211, 102, 0.55);
  background: linear-gradient(135deg, rgba(37, 211, 102, 0.92), rgba(18, 140, 70, 0.92));
  color: #03130a;
}

#shareWhatsappButton:hover,
#shareWhatsappButton:focus-visible {
  border-color: rgba(143, 253, 143, 0.9);
  background: linear-gradient(135deg, rgba(63, 230, 122, 0.95), rgba(28, 168, 88, 0.95));
}

#shareWhatsappButton.is-hidden {
  display: none;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  padding: 0;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 76px;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  padding: 7px 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.045);
}

.leaderboard-rank {
  color: var(--amber);
  font-weight: 900;
  text-align: center;
}

.leaderboard-pilot {
  min-width: 0;
  overflow: hidden;
  color: #f5fbff;
  font-size: 0.88rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: var(--green);
  font-size: 0.86rem;
  font-weight: 900;
  text-align: right;
}

.leaderboard-meta {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 0.72rem;
}

.leaderboard-empty,
.leaderboard-status {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.leaderboard-empty {
  padding: 8px 2px;
}

.leaderboard-status {
  min-height: 18px;
  margin: 10px 0 0;
}

.event-toast {
  position: absolute;
  top: 108px;
  left: 50%;
  min-width: 180px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(8, 14, 24, 0.82);
  color: #f8fbff;
  font-weight: 800;
  text-align: center;
  transform: translateX(-50%) translateY(-10px);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(10px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.event-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%);
}

.account-modal {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.58);
  pointer-events: auto;
}

.account-modal.is-hidden {
  display: none;
}

.account-card {
  width: min(430px, calc(100vw - 36px));
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 16, 28, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  padding: 20px;
}

.account-logo {
  display: block;
  width: 168px;
  height: 72px;
  border-radius: 6px;
  background:
    rgba(255, 255, 255, 0.94)
    url("assets/kopano-labs-logo.png?v=20260505-leaderboard") center / cover no-repeat;
  padding: 6px;
  margin-bottom: 14px;
}

.account-card h2 {
  margin-bottom: 8px;
  font-size: 1.45rem;
}

.account-copy,
.account-status,
.account-summary {
  color: var(--muted);
  line-height: 1.45;
}

.account-summary {
  display: grid;
  gap: 3px;
  margin: 14px 0 4px;
  padding: 10px 12px;
  border: 1px solid rgba(143, 253, 143, 0.16);
  border-radius: 6px;
  background: rgba(21, 73, 56, 0.22);
}

.account-summary span,
.account-summary strong {
  overflow-wrap: anywhere;
}

.account-summary span {
  color: #d9e7ff;
  font-size: 0.82rem;
  font-weight: 800;
}

.account-summary strong {
  color: var(--green);
  font-size: 0.98rem;
}

.account-card label {
  display: block;
  margin: 12px 0 6px;
  color: #d9e7ff;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.account-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.account-actions button {
  flex: 1 1 0;
  min-width: 0;
}

.account-secondary-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.account-secondary-actions button {
  min-width: 112px;
  min-height: 34px;
  color: #ffe4e8;
}

.account-status {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 0.86rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.kasi-comm {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  pointer-events: auto;
}

.kasi-comm-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid rgba(59, 227, 255, 0.45);
  border-radius: 8px;
  background: rgba(8, 14, 24, 0.86);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  pointer-events: auto;
}

.kasi-comm-toggle-icon {
  font-size: 1rem;
}

.kasi-comm-body {
  display: flex;
  flex-direction: column;
  width: min(320px, calc(100vw - 36px));
  max-height: min(420px, calc(100vh - 220px));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.kasi-comm.is-collapsed .kasi-comm-body {
  display: none;
}

.kasi-comm-head {
  padding: 12px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.kasi-comm-head h2 {
  margin-bottom: 4px;
  font-size: 1rem;
  line-height: 1.1;
}

.kasi-comm-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  min-height: 14px;
}

.kasi-comm-list {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  overflow-y: auto;
  list-style: none;
}

.kasi-comm-row {
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.82rem;
  line-height: 1.35;
}

.kasi-comm-row.is-self {
  border-color: rgba(143, 253, 143, 0.35);
  background: rgba(21, 73, 56, 0.42);
}

.kasi-comm-row .kasi-comm-author {
  display: block;
  margin-bottom: 2px;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.kasi-comm-row .kasi-comm-text {
  color: #f4f9ff;
  overflow-wrap: anywhere;
}

.kasi-comm-empty {
  padding: 6px 2px;
  color: var(--muted);
  font-size: 0.82rem;
  list-style: none;
}

.kasi-comm-form {
  display: flex;
  gap: 6px;
  padding: 10px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.kasi-comm-form input {
  flex: 1 1 auto;
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.86rem;
}

.kasi-comm-form button {
  min-width: 64px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.8rem;
}

@media (max-width: 760px) {
  .hud {
    top: 10px;
    left: 10px;
    right: 10px;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .brand,
  .stats div,
  .hud-actions {
    min-height: 54px;
  }

  .brand {
    height: 58px;
    max-height: 58px;
    padding: 9px 10px;
  }

  .brand-logo {
    width: 84px;
    height: 42px;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(72px, 1fr));
  }

  .stats div {
    padding: 9px 8px;
  }

  .stats span {
    font-size: 0.63rem;
  }

  .hud-actions {
    flex-wrap: wrap;
    justify-content: stretch;
    padding: 8px;
  }

  .pilot-badge,
  .hud-actions button {
    flex: 1 1 0;
    min-width: 0;
  }

  .pilot-badge {
    max-width: none;
  }

  .status-panel {
    bottom: 12px;
    padding: 14px;
  }

  .leaderboard-panel {
    top: 248px;
    left: 10px;
    right: 10px;
    width: auto;
    padding: 10px;
  }

  .leaderboard-list {
    max-height: 126px;
  }

  .leaderboard-row {
    grid-template-columns: 24px minmax(0, 1fr) 66px;
    min-height: 32px;
    padding: 6px;
  }

  .leaderboard-meta {
    display: none;
  }

  .event-toast {
    top: 202px;
  }

  .kasi-comm {
    left: 10px;
    bottom: 110px;
  }

  .kasi-comm-body {
    width: calc(100vw - 32px);
    max-height: 240px;
  }
}
