:root {
  --ink: #18201f;
  --muted: #66706c;
  --panel: rgba(255, 255, 255, 0.94);
  --line: rgba(24, 32, 31, 0.14);
  --green: #1f8f5f;
  --danger: #d9574a;
  --shadow: 0 14px 42px rgba(24, 32, 31, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body,
.app,
.map-screen,
#map {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: #e6ece5;
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input {
  font: inherit;
}

.map-screen {
  position: relative;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#gameLayer {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.hud,
.bottom-sheet {
  position: absolute;
  z-index: 3;
}

.top-hud {
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.brand,
.gps-chip,
.stats-bar,
.bottom-sheet,
.player-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand {
  padding: 10px 12px;
}

.brand span {
  display: block;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.icon-button {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.icon-button img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.text-icon {
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.gps-chip {
  top: max(76px, calc(env(safe-area-inset-top) + 64px));
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.gps-chip.active .dot {
  background: var(--green);
  box-shadow: 0 0 0 7px rgba(31, 143, 95, 0.16);
}

.stats-bar {
  top: max(76px, calc(env(safe-area-inset-top) + 64px));
  right: 12px;
  display: grid;
  grid-template-columns: repeat(4, minmax(44px, 1fr));
  overflow: hidden;
}

.stats-bar div {
  min-width: 0;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  text-align: center;
}

.stats-bar div:last-child {
  border-right: 0;
}

.stats-bar strong,
.stats-bar span {
  display: block;
}

.stats-bar strong {
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
}

.stats-bar span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.bottom-sheet {
  left: 12px;
  right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  padding: 10px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.primary,
.secondary {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 900;
}

.primary {
  color: #fff;
  background: var(--ink);
}

.primary.recording {
  background: var(--danger);
}

.secondary {
  border-color: var(--line);
  color: var(--ink);
  background: #fff;
}

.full {
  width: 100%;
}

.leaderboard {
  margin-top: 8px;
}

.leaderboard summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.leaderboard ol {
  display: grid;
  gap: 6px;
  padding: 8px 0 0;
  margin: 0;
  list-style: none;
}

.leaderboard li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
}

.leaderboard span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: flex-end;
  padding: 12px;
  background: rgba(24, 32, 31, 0.32);
}

.modal.open {
  display: flex;
}

.player-form {
  width: 100%;
  padding: 18px;
}

.player-form h1 {
  margin: 0 0 16px;
  font-size: 24px;
}

.player-form label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.player-form span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.player-form input {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.existing-player-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.existing-title {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.existing-players {
  display: grid;
  gap: 8px;
}

.existing-player {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.existing-player img {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: cover;
}

.existing-player span,
.existing-player strong,
.existing-player small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.existing-player strong {
  font-size: 14px;
}

.existing-player small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

@media (min-width: 800px) {
  .bottom-sheet,
  .modal {
    max-width: 430px;
  }

  .modal {
    left: auto;
  }
}
