:root {
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0f1a;
  font-family: 'Segoe UI', system-ui, sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.hidden {
  display: none !important;
}

#leaderboard {
  position: fixed;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  width: 190px;
  background: rgba(10, 15, 26, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  z-index: 10;
  backdrop-filter: blur(4px);
  font-size: 13px;
}

#pause-btn {
  position: fixed;
  top: calc(12px + var(--sat));
  right: calc(14px + var(--sar) + 190px);
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 15, 26, 0.7);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  z-index: 11;
  display: flex;
  align-items: center;
  justify-content: center;
}

#pause-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

.lb-title {
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 8px;
}

#lb-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.lb-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
}

.lb-row .lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
}

.lb-row .lb-score {
  color: #d1d5db;
  font-variant-numeric: tabular-nums;
}

.lb-row.me {
  color: #fbbf24;
  font-weight: 700;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 18, 0.72);
  backdrop-filter: blur(3px);
  z-index: 20;
  overflow-y: auto;
  padding-top: var(--sat);
  padding-bottom: var(--sab);
}

.panel {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 32px 40px;
  text-align: center;
  color: #fff;
  min-width: 360px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.title {
  font-size: 44px;
  font-weight: 800;
  background: linear-gradient(90deg, #22c55e, #eab308, #ef4444);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.subtitle {
  color: #9ca3af;
  font-size: 14px;
  margin-bottom: 22px;
}

.panel h2 {
  font-size: 26px;
  margin-bottom: 8px;
}

#go-score {
  color: #d1d5db;
  font-size: 16px;
  margin-bottom: 20px;
}

#name-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
  text-align: center;
}

#name-input:focus,
#login-email:focus,
#login-pass:focus,
#reg-email:focus,
#reg-user:focus,
#reg-pass:focus {
  border-color: #22c55e;
}

#nationality-select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: #1f2937;
  color: #fff;
  font-size: 15px;
  outline: none;
  margin-bottom: 12px;
  cursor: pointer;
}

#login-email,
#login-pass,
#reg-email,
#reg-user,
#reg-pass {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 16px;
  outline: none;
  margin-bottom: 10px;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.auth-tabs button {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  color: #9ca3af;
  font-weight: 600;
}

.auth-tabs button.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.5);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
}

.btn-row button {
  flex: 1;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-weight: 600;
}

.btn-secondary:hover {
  filter: brightness(1.2);
}

#auth-msg {
  min-height: 18px;
  font-size: 13px;
  color: #f87171;
  margin-bottom: 10px;
}

#logged-box {
  margin-bottom: 14px;
}

#logged-info {
  font-size: 16px;
  margin-bottom: 4px;
}

#logged-record {
  font-size: 13px;
  color: #fbbf24;
  margin-bottom: 12px;
}

button {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(90deg, #22c55e, #16a34a);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

button:hover {
  filter: brightness(1.1);
}

button:active {
  transform: scale(0.97);
}

.hint {
  margin-top: 16px;
  color: #6b7280;
  font-size: 12px;
}
