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

body {
  background: radial-gradient(circle at center, #162032 0%, #090d16 100%);
  color: #e2e8f0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-x: hidden;
  padding: 12px;
}

.page-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: center;
  gap: 14px;
  width: 100%;
  max-width: 1360px;
}

/* ================= PANEL LEADERBOARD IZQUIERDO ================= */
.leaderboard-panel {
  width: 296px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: rgba(15, 23, 42, 0.90);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  max-height: 650px;
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(71, 85, 105, 0.5);
  padding-bottom: 8px;
}

.lb-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.lb-trophy {
  font-size: 16px;
}

.lb-header h2 {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #f8fafc;
}

.lb-status {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
}

.lb-status.online {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.5);
}

.lb-status.local {
  background: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.lb-nick-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-nick-box label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lb-nick-row {
  display: flex;
  gap: 6px;
}

.lb-nick-row input {
  flex: 1;
  min-width: 0;
  background: #0b1120;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 6px 9px;
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  user-select: text;
  outline: none;
}

.lb-nick-row input:focus {
  border-color: #38bdf8;
}

.lb-nick-row button {
  background: #0284c7;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.lb-nick-row button:hover {
  background: #0ea5e9;
}

.lb-tabs {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
}

.lb-tab {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 5px;
  padding: 5px 2px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.12s ease;
}

.lb-tab:hover {
  color: #f8fafc;
  border-color: #64748b;
}

.lb-tab.active {
  background: rgba(56, 189, 248, 0.22);
  border-color: #38bdf8;
  color: #38bdf8;
}

.lb-columns {
  display: grid;
  grid-template-columns: 28px 1fr 72px 46px;
  gap: 6px;
  font-size: 10px;
  font-weight: 800;
  color: #64748b;
  letter-spacing: 0.05em;
  padding: 0 6px;
}

.lb-columns span:nth-child(3),
.lb-columns span:nth-child(4) {
  text-align: right;
}

.lb-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 2px;
}

.lb-row {
  display: grid;
  grid-template-columns: 28px 1fr 72px 46px;
  align-items: center;
  gap: 6px;
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(51, 65, 85, 0.6);
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
}

.lb-row.top-1 {
  border-color: rgba(250, 204, 21, 0.65);
  background: rgba(250, 204, 21, 0.10);
}

.lb-row.top-2 {
  border-color: rgba(203, 213, 225, 0.5);
}

.lb-row.top-3 {
  border-color: rgba(251, 146, 60, 0.5);
}

.lb-row.is-me {
  box-shadow: inset 2px 0 0 #38bdf8;
}

.lb-rank {
  font-weight: 800;
  text-align: center;
  font-size: 12px;
}

.lb-name {
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-time {
  font-family: Consolas, 'Courier New', monospace;
  font-weight: 700;
  color: #fde047;
  text-align: right;
  font-size: 12px;
}

.lb-score {
  font-family: Consolas, 'Courier New', monospace;
  color: #94a3b8;
  text-align: right;
  font-size: 11px;
}

.lb-empty {
  text-align: center;
  color: #64748b;
  font-size: 12px;
  padding: 24px 8px;
  border: 1px dashed #334155;
  border-radius: 8px;
}

.lb-footer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid rgba(71, 85, 105, 0.45);
  padding-top: 8px;
}

.lb-toast {
  font-size: 11px;
  color: #94a3b8;
  min-height: 16px;
}

.lb-toast.ok {
  color: #34d399;
}

.lb-toast.warn {
  color: #fbbf24;
}

.lb-toast.info {
  color: #38bdf8;
}

.lb-refresh {
  background: #1e293b;
  border: 1px solid #475569;
  color: #e2e8f0;
  border-radius: 6px;
  padding: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.lb-refresh:hover:not(:disabled) {
  background: #334155;
}

.lb-refresh:disabled {
  opacity: 0.55;
  cursor: wait;
}

/* ================= ÁREA DEL JUEGO ================= */
.app-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  flex: 1;
  min-width: 0;
  max-width: 1024px;
}

.top-bar {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(71, 85, 105, 0.55);
  border-radius: 10px;
  padding: 8px 14px;
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 3px 8px;
  border-radius: 5px;
}

.brand h1 {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #f8fafc;
}

.controls-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: #94a3b8;
}

kbd {
  display: inline-block;
  background: #1e293b;
  border: 1px solid #475569;
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  color: #f1f5f9;
  margin-right: 2px;
}

.stage-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.65), 0 0 0 2px rgba(51, 65, 85, 0.8);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: #0b1120;
  cursor: crosshair;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

@media (max-width: 1080px) {
  body {
    overflow-y: auto;
  }
  .page-layout {
    flex-direction: column-reverse;
    align-items: center;
  }
  .leaderboard-panel {
    width: 100%;
    max-width: 1024px;
    max-height: 320px;
  }
}
